From ec4a13e4f3231c188d80e3ac9726a7e9a5c8fea8 Mon Sep 17 00:00:00 2001 From: Erin Schnabel Date: Tue, 11 Jun 2024 16:22:54 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20handle=20application=20approved/dec?= =?UTF-8?q?lined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/admin/api/ApplicationData.java | 1 + .../admin/api/MemberApplicationProcess.java | 25 +- .../admin/github/AdminGitHubEvents.java | 16 +- .../admin/api/ApplicationEventTest.java | 176 ++++++++++++++ .../automation/admin/api/MemberDataTest.java | 69 +----- .../admin/github/ContextHelper.java | 75 +++++- .../github/eventIssueLabeled-accepted.json | 227 ++++++++++++++++++ .../github/eventIssueLabeled-declined.json | 227 ++++++++++++++++++ .../mutableRemoveLabelsFromLabelable.json | 19 ++ .../automation/github/voting/VotingTest.java | 2 +- 10 files changed, 756 insertions(+), 81 deletions(-) create mode 100644 cf-admin-bot/src/test/java/org/commonhaus/automation/admin/api/ApplicationEventTest.java create mode 100644 cf-admin-bot/src/test/resources/github/eventIssueLabeled-accepted.json create mode 100644 cf-admin-bot/src/test/resources/github/eventIssueLabeled-declined.json create mode 100644 cf-admin-bot/src/test/resources/github/mutableRemoveLabelsFromLabelable.json diff --git a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/ApplicationData.java b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/ApplicationData.java index 24b7c61..e4a3f81 100644 --- a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/ApplicationData.java +++ b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/ApplicationData.java @@ -128,6 +128,7 @@ public static String getLogin(DataCommonItem issue) { public static boolean isMemberApplicationEvent(DataCommonItem issue, DataLabel label) { return issue.title.startsWith("Membership application:") + && !issue.closed && (ACCEPTED.equals(label.name) || DECLINED.equals(label.name)); } diff --git a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/MemberApplicationProcess.java b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/MemberApplicationProcess.java index 5f6172b..74c5c13 100644 --- a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/MemberApplicationProcess.java +++ b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/api/MemberApplicationProcess.java @@ -31,11 +31,16 @@ public class MemberApplicationProcess { @Inject CommonhausDatastore datastore; - public void handleApplicationEvent(ScopedQueryContext qc, GHIssue issue, DataCommonItem item, DataLabel label) { - if (!ApplicationData.isMemberApplicationEvent(item, label)) { - return; - } - + /** + * Handle an application event (issue label change) for a membership application. + * Not triggered by the user, but by the system when a label is added or removed from an issue. + * + * @param qc QueryContext for the repository containing the issue + * @param issue The issue that was updated + * @param item The issue as Json-derived data + * @param label The label that was added + */ + public void handleApplicationLabelAdded(ScopedQueryContext qc, GHIssue issue, DataCommonItem item, DataLabel label) { String login = ApplicationData.getLogin(item); GHUser applicant = qc.getUser(login); CommonhausUser user = datastore.getCommonhausUser(login, applicant.getId(), false, false); @@ -75,6 +80,7 @@ public void handleApplicationEvent(ScopedQueryContext qc, GHIssue issue, DataCom if (u.status().updateFromPending()) { u.status(MemberStatus.DECLINED); } + u.isMember = false; }, "Membership application declined", true, @@ -86,6 +92,15 @@ public void handleApplicationEvent(ScopedQueryContext qc, GHIssue issue, DataCom } } + /** + * User action called when a user submits or updates their membership application + * + * @param session User session + * @param qc Datastore QueryContext (for making changes to the application issue) + * @param applicationData Current application data + * @param applicationPost Application data from the user + * @return updated ApplicationData object or null on error (see QueryContext for errors) + */ public ApplicationData userUpdateApplicationIssue( MemberSession session, ScopedQueryContext qc, diff --git a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/github/AdminGitHubEvents.java b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/github/AdminGitHubEvents.java index e2792bb..ef1e1a0 100644 --- a/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/github/AdminGitHubEvents.java +++ b/cf-admin-bot/src/main/java/org/commonhaus/automation/admin/github/AdminGitHubEvents.java @@ -8,6 +8,7 @@ import jakarta.json.JsonObject; import org.commonhaus.automation.admin.AdminDataCache; +import org.commonhaus.automation.admin.api.ApplicationData; import org.commonhaus.automation.admin.api.MemberApplicationProcess; import org.commonhaus.automation.admin.config.UserManagementConfig.AttestationConfig; import org.commonhaus.automation.github.context.ActionType; @@ -86,13 +87,18 @@ public void updateMembership(GitHub github, DynamicGraphQLClient graphQLClient, * @param graphQLClient * @param issueCommentEvent */ - public void updateApplication(GitHubEvent event, GitHub github, DynamicGraphQLClient graphQLClient, + public void applicationIssueLabelAdded(GitHubEvent event, GitHub github, DynamicGraphQLClient graphQLClient, @Issue.Labeled GHEventPayload.Issue issueEvent) { + String repoFullName = issueEvent.getRepository().getFullName(); ActionType actionType = ActionType.fromString(event.getAction()); + JsonObject payload = JsonAttribute.unpack(event.getPayload()); + DataCommonItem issue = JsonAttribute.issue.commonItemFrom(payload); + DataLabel label = JsonAttribute.label.labelFrom(payload); // ignore if it isn't an issue in the datastore repository - if (!repoFullName.equals(ctx.getDataStore())) { + if (!repoFullName.equals(ctx.getDataStore()) + || !ApplicationData.isMemberApplicationEvent(issue, label)) { return; } @@ -102,15 +108,11 @@ public void updateApplication(GitHubEvent event, GitHub github, DynamicGraphQLCl issueEvent.getInstallation().getId()) .addExisting(graphQLClient); - JsonObject payload = JsonAttribute.unpack(event.getPayload()); - DataCommonItem issue = JsonAttribute.issue.commonItemFrom(payload); - DataLabel label = JsonAttribute.label.labelFrom(payload); - Log.debugf("[%s] updateApplication #%s - %s", qc.getLogId(), issue.number, actionType); try { - applicationProcess.handleApplicationEvent(qc, issueEvent.getIssue(), issue, label); + applicationProcess.handleApplicationLabelAdded(qc, issueEvent.getIssue(), issue, label); } catch (Exception e) { ctx.logAndSendEmail(qc.getLogId(), "Error with issue label event", e, null); } finally { diff --git a/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/api/ApplicationEventTest.java b/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/api/ApplicationEventTest.java new file mode 100644 index 0000000..3f6624e --- /dev/null +++ b/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/api/ApplicationEventTest.java @@ -0,0 +1,176 @@ +package org.commonhaus.automation.admin.api; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.contains; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +import java.io.IOException; +import java.util.Set; +import java.util.stream.Stream; + +import jakarta.inject.Inject; + +import org.commonhaus.automation.admin.AdminDataCache; +import org.commonhaus.automation.admin.api.CommonhausUser.MemberStatus; +import org.commonhaus.automation.admin.config.AdminConfigFile; +import org.commonhaus.automation.admin.github.AppContextService; +import org.commonhaus.automation.admin.github.ContextHelper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.kohsuke.github.GHContentBuilder; +import org.kohsuke.github.GHEvent; +import org.kohsuke.github.GHTeam; +import org.kohsuke.github.GHUser; +import org.kohsuke.github.GitHub; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.quarkiverse.githubapp.testing.GitHubAppTest; +import io.quarkiverse.githubapp.testing.GitHubAppTesting; +import io.quarkus.mailer.MockMailbox; +import io.quarkus.test.junit.QuarkusTest; +import io.smallrye.graphql.client.Response; + +@QuarkusTest +@GitHubAppTest +public class ApplicationEventTest extends ContextHelper { + + @Inject + MockMailbox mailbox; + + @Inject + AppContextService ctx; + + @Inject + ObjectMapper mapper; + + @BeforeEach + void init() throws IOException { + mailbox.clear(); + Stream.of(AdminDataCache.values()).forEach(AdminDataCache::invalidateAll); + } + + @Test + void testApplicationApproved() throws Exception { + // When a discussion is labeled, ... + // from src/test/resources/github/eventIssueLabeled-accepted.json + String issueId = "I_kwDOL8tG0s6Lx52p"; + + // preload the cache: no request to fetch labels (and check our work) + setLabels(issueId, Set.of()); + + Response removeLabel = mockResponse("src/test/resources/github/mutableRemoveLabelsFromLabelable.json"); + final GHContentBuilder builder = Mockito.mock(GHContentBuilder.class); + + GitHubAppTesting.given() + .github(mocks -> { + mocks.configFile(AdminConfigFile.NAME).fromClasspath("/cf-admin.yml"); + + GitHub botGithub = setupBotGithub(ctx, mocks); + when(botGithub.isCredentialValid()).thenReturn(true); + + setupMockTeam(mocks); + mockExistingCommonhausData(botGithub, ctx, "src/test/resources/haus-member-application.yaml"); + + mockUpdateCommonhausData(builder, botGithub, ctx); + + when(mocks.installationGraphQLClient(installationId) + .executeSync(contains("removeLabelsFromLabelable("), anyMap())) + .thenReturn(removeLabel); + }) + .when().payloadFromClasspath("/github/eventIssueLabeled-accepted.json") + .event(GHEvent.ISSUES) + .then().github(mocks -> { + + // 1) Set member flag, move status from UNKNOWN -> ACTIVE + // 2) remove application + final ArgumentCaptor contentCaptor = ArgumentCaptor.forClass(String.class); + verify(builder).content(contentCaptor.capture()); + var result = AppContextService.yamlMapper().readValue(contentCaptor.getValue(), CommonhausUser.class); + + assertThat(result.application).isNull(); + assertThat(result.isMember).isTrue(); + assertThat(result.data.status).isEqualTo(MemberStatus.ACTIVE); // changed from UNKNOWN -> PENDING + + // 3) add user to target team + GHTeam target = mocks.team("team-quorum-default".hashCode()); + verify(target).add(any(GHUser.class)); + + // 4) Close issue + verify(mocks.issue(2345115049L)).close(); + + // 5) remove application/new + verify(mocks.installationGraphQLClient(installationId), timeout(500)) + .executeSync(contains("removeLabelsFromLabelable("), anyMap()); + + verifyNoMoreInteractions(mocks.installationGraphQLClient(installationId)); + }); + + } + + @Test + void testApplicationDenied() throws Exception { + // When a discussion is labeled, ... + // from src/test/resources/github/eventIssueLabeled-accepted.json + String issueId = "I_kwDOL8tG0s6Lx52p"; + + // preload the cache: no request to fetch labels (and check our work) + setLabels(issueId, Set.of()); + + Response removeLabel = mockResponse("src/test/resources/github/mutableRemoveLabelsFromLabelable.json"); + final GHContentBuilder builder = Mockito.mock(GHContentBuilder.class); + + GitHubAppTesting.given() + .github(mocks -> { + mocks.configFile(AdminConfigFile.NAME).fromClasspath("/cf-admin.yml"); + + GitHub botGithub = setupBotGithub(ctx, mocks); + when(botGithub.isCredentialValid()).thenReturn(true); + + setupMockTeam(mocks); + mockExistingCommonhausData(botGithub, ctx, "src/test/resources/haus-member-application.yaml"); + + mockUpdateCommonhausData(builder, botGithub, ctx); + + when(mocks.installationGraphQLClient(installationId) + .executeSync(contains("removeLabelsFromLabelable("), anyMap())) + .thenReturn(removeLabel); + }) + .when().payloadFromClasspath("/github/eventIssueLabeled-declined.json") + .event(GHEvent.ISSUES) + .then().github(mocks -> { + + // 1) Set member flag, move status from UNKNOWN -> DECLINED + final ArgumentCaptor contentCaptor = ArgumentCaptor.forClass(String.class); + verify(builder).content(contentCaptor.capture()); + var result = AppContextService.yamlMapper().readValue(contentCaptor.getValue(), CommonhausUser.class); + + assertThat(result.application).isNotNull(); + assertThat(result.isMember).isFalse(); + assertThat(result.data.status).isEqualTo(MemberStatus.DECLINED); // changed from UNKNOWN -> PENDING + + // 3) add user to target team + GHTeam target = mocks.team("team-quorum-default".hashCode()); + verify(target, times(0)).add(any(GHUser.class)); + + // 4) Close issue + verify(mocks.issue(2345115049L)).close(); + + // 5) remove application/new + verify(mocks.installationGraphQLClient(installationId), timeout(500)) + .executeSync(contains("removeLabelsFromLabelable("), anyMap()); + + verifyNoMoreInteractions(mocks.installationGraphQLClient(installationId)); + }); + + } + +} diff --git a/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/api/MemberDataTest.java b/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/api/MemberDataTest.java index a087c64..55754e0 100644 --- a/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/api/MemberDataTest.java +++ b/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/api/MemberDataTest.java @@ -10,13 +10,10 @@ import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.contains; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.List; @@ -34,15 +31,12 @@ import org.commonhaus.automation.admin.github.ContextHelper; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.kohsuke.github.GHContent; import org.kohsuke.github.GHContentBuilder; -import org.kohsuke.github.GHContentUpdateResponse; import org.kohsuke.github.GHFileNotFoundException; import org.kohsuke.github.GHRepository; import org.kohsuke.github.GHUser; import org.kohsuke.github.GitHub; import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; import com.fasterxml.jackson.databind.ObjectMapper; @@ -240,7 +234,7 @@ void testGetCommonhausUserBadnessHappens() throws Exception { }) void testGetCommonhausUser() throws Exception { - mockExistingCommonhausData(); + mockExistingCommonhausData(botGithub, ctx); GHUser botUser = botGithub.getUser(botLogin); appendMockTeam(organizationName + "/team-quorum-default", botUser); @@ -276,9 +270,9 @@ void testPutAttestation() throws Exception { "draft"); String attestJson = mapper.writeValueAsString(attestation); - mockExistingCommonhausData(); // pre-existing data + mockExistingCommonhausData(botGithub, ctx); // pre-existing data - GHContentBuilder builder = mockUpdateCommonhausData(); + GHContentBuilder builder = mockUpdateCommonhausData(botGithub, ctx); GHUser botUser = botGithub.getUser(botLogin); appendMockTeam(organizationName + "/cf-voting", botUser); @@ -363,7 +357,7 @@ void testPutAttestations() throws Exception { new AttestationPost("coc", "2.0")); String attestJson = mapper.writeValueAsString(attestations); - GHContentBuilder builder = mockUpdateCommonhausData(); + GHContentBuilder builder = mockUpdateCommonhausData(botGithub, ctx); GHUser botUser = botGithub.getUser(botLogin); appendMockTeam(organizationName + "/team-quorum-default", botUser); @@ -417,7 +411,7 @@ void testGetUnknownApplication() throws Exception { GHUser botUser = botGithub.getUser(botLogin); appendMockTeam(organizationName + "/team-quorum-default", botUser); - mockExistingCommonhausData(); + mockExistingCommonhausData(botGithub, ctx); given() .log().all() @@ -440,10 +434,10 @@ void testGetInvalidApplication() throws Exception { GHUser botUser = botGithub.getUser(botLogin); appendMockTeam(organizationName + "/team-quorum-default", botUser); - mockExistingCommonhausData("src/test/resources/haus-member-application.yaml"); + mockExistingCommonhausData(botGithub, ctx, "src/test/resources/haus-member-application.yaml"); // update to remove applicationId - GHContentBuilder builder = mockUpdateCommonhausData(); + GHContentBuilder builder = mockUpdateCommonhausData(botGithub, ctx); Response queryIssue = mockResponse("src/test/resources/github/queryIssue-ApplicationBadTitle.json"); when(mockContext.mocks.installationGraphQLClient(installationId) @@ -477,7 +471,7 @@ void testGetApplicationWithFeedback() throws Exception { GHUser botUser = botGithub.getUser(botLogin); appendMockTeam(organizationName + "/team-quorum-default", botUser); - mockExistingCommonhausData("src/test/resources/haus-member-application.yaml"); + mockExistingCommonhausData(botGithub, ctx, "src/test/resources/haus-member-application.yaml"); Response queryIssue = mockResponse("src/test/resources/github/queryIssue-ApplicationMatch.json"); when(mockContext.mocks.installationGraphQLClient(installationId) @@ -490,7 +484,7 @@ void testGetApplicationWithFeedback() throws Exception { .thenReturn(queryComments); // update to fix member status - GHContentBuilder builder = mockUpdateCommonhausData(); + GHContentBuilder builder = mockUpdateCommonhausData(botGithub, ctx); given() .log().all() @@ -521,7 +515,7 @@ void testSubmitApplication() throws Exception { GHUser botUser = botGithub.getUser(botLogin); appendMockTeam(organizationName + "/team-quorum-default", botUser); - mockExistingCommonhausData("src/test/resources/haus-member-application.yaml"); + mockExistingCommonhausData(botGithub, ctx, "src/test/resources/haus-member-application.yaml"); Response queryIssue = mockResponse("src/test/resources/github/queryIssue-ApplicationMatch.json"); when(mockContext.mocks.installationGraphQLClient(installationId) @@ -539,7 +533,7 @@ void testSubmitApplication() throws Exception { String applyJson = mapper.writeValueAsString(application); // update to fix member status - GHContentBuilder builder = mockUpdateCommonhausData(); + GHContentBuilder builder = mockUpdateCommonhausData(botGithub, ctx); given() .log().all() @@ -565,45 +559,4 @@ void testSubmitApplication() throws Exception { assertThat(result.application).isNotNull(); assertThat(result.data.status).isEqualTo(MemberStatus.PENDING); // changed from UNKNOWN -> PENDING } - - void mockExistingCommonhausData() throws IOException { - mockExistingCommonhausData("src/test/resources/commonhaus-user.yaml"); - } - - void mockExistingCommonhausData(String filename) throws IOException { - GHContent content = mock(GHContent.class); - when(content.read()).thenReturn(Files.newInputStream(Path.of(filename))); - when(content.getSha()).thenReturn("1234567890abcdef"); - - GHRepository dataStore = botGithub.getRepository(ctx.getDataStore()); - when(dataStore.getFileContent(anyString())).thenReturn(content); - } - - GHContentBuilder mockUpdateCommonhausData() throws IOException { - return mockUpdateCommonhausData("src/test/resources/commonhaus-user.yaml"); - } - - GHContentBuilder mockUpdateCommonhausData(String filename) throws IOException { - GHContentBuilder builder = Mockito.mock(GHContentBuilder.class); - when(builder.content(anyString())).thenReturn(builder); - when(builder.message(anyString())).thenReturn(builder); - when(builder.path(anyString())).thenReturn(builder); - when(builder.sha(anyString())).thenReturn(builder); - - GHContent responseContent = mock(GHContent.class); - when(responseContent.read()) - .thenReturn(Files.newInputStream(Path.of(filename))); - when(responseContent.getSha()).thenReturn("1234567890adefgh"); - - GHRepository dataStore = botGithub.getRepository(ctx.getDataStore()); - when(dataStore.createContent()).thenReturn(builder); - - GHContentUpdateResponse response = Mockito.mock(GHContentUpdateResponse.class); - when(response.getContent()).thenReturn(responseContent); - - when(builder.commit()).thenReturn(response); - - return builder; - } - } diff --git a/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/github/ContextHelper.java b/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/github/ContextHelper.java index 81e7ba9..c4b6459 100644 --- a/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/github/ContextHelper.java +++ b/cf-admin-bot/src/test/java/org/commonhaus/automation/admin/github/ContextHelper.java @@ -1,6 +1,7 @@ package org.commonhaus.automation.admin.github; import static org.commonhaus.automation.github.context.BaseQueryCache.TEAM_MEMBERS; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -10,6 +11,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.HashSet; +import java.util.List; import java.util.Optional; import java.util.Set; @@ -27,6 +29,9 @@ import org.commonhaus.automation.github.context.QueryContext; import org.commonhaus.automation.github.discovery.DiscoveryAction; import org.commonhaus.automation.github.discovery.RepositoryDiscoveryEvent; +import org.kohsuke.github.GHContent; +import org.kohsuke.github.GHContentBuilder; +import org.kohsuke.github.GHContentUpdateResponse; import org.kohsuke.github.GHOrganization; import org.kohsuke.github.GHRepository; import org.kohsuke.github.GHTeam; @@ -122,13 +127,9 @@ public GitHub setupMockTeam(GitHubMockSetupContext mocks) throws IOException { when(gh.getUser(login)).thenReturn(user); } - System.out.println("testQuorum " + testQuorum.stream().map(GHUser::getLogin).toList()); - System.out.println("council " + council.stream().map(GHUser::getLogin).toList()); - System.out.println("voting " + voting.stream().map(GHUser::getLogin).toList()); - - setupMockTeam("team-quorum-default", org, testQuorum); - setupMockTeam("cf-council", org, council); - setupMockTeam("cf-voting", org, voting); + setupMockTeam(mocks, "team-quorum-default", org, testQuorum); + setupMockTeam(mocks, "cf-council", org, council); + setupMockTeam(mocks, "cf-voting", org, voting); return gh; } @@ -152,10 +153,11 @@ protected GHRepository setupMockRepository(GitHubMockSetupContext mocks, GitHub return repo; } - protected GHTeam setupMockTeam(String name, GHOrganization org, Set userSet) throws IOException { + protected GHTeam setupMockTeam(GitHubMockSetupContext mocks, String name, GHOrganization org, Set userSet) + throws IOException { setupMockTeam("commonhaus-test/" + name, userSet); - GHTeam team = Mockito.mock(GHTeam.class); + GHTeam team = mocks.team(name.hashCode()); when(team.getMembers()).thenReturn(userSet); when(team.getName()).thenReturn(name); when(org.getTeamByName(name)).thenReturn(team); @@ -192,7 +194,7 @@ public GitHub setupBotGithub(AppContextService ctx, GitHubMockSetupContext mocks RepositoryDiscoveryEvent repoEvent = new RepositoryDiscoveryEvent( DiscoveryAction.ADDED, gh, dql, installationId, dataStoreRepo, Optional.ofNullable(null)); - BaseQueryCache.LABELS.computeIfAbsent(datastoreRepoId, (k) -> new HashSet<>()).addAll(APP_LABELS); + setLabels(datastoreRepoId, APP_LABELS); ctx.repositoryDiscovered(repoEvent); ctx.attestationIds.add("member"); @@ -218,6 +220,59 @@ public Response mockResponse(String filename) { } } + public void mockExistingCommonhausData(GitHub botGithub, AppContextService ctx) throws IOException { + mockExistingCommonhausData(botGithub, ctx, "src/test/resources/commonhaus-user.yaml"); + } + + public void mockExistingCommonhausData(GitHub botGithub, AppContextService ctx, String filename) throws IOException { + GHContent content = mock(GHContent.class); + when(content.read()).thenReturn(Files.newInputStream(Path.of(filename))); + when(content.getSha()).thenReturn("1234567890abcdef"); + + GHRepository dataStore = botGithub.getRepository(ctx.getDataStore()); + when(dataStore.getFileContent(anyString())).thenReturn(content); + } + + public GHContentBuilder mockUpdateCommonhausData(GitHub botGithub, AppContextService ctx) throws IOException { + GHContentBuilder builder = Mockito.mock(GHContentBuilder.class); + return mockUpdateCommonhausData(builder, botGithub, ctx, "src/test/resources/commonhaus-user.yaml"); + } + + public GHContentBuilder mockUpdateCommonhausData(GHContentBuilder builder, GitHub botGithub, AppContextService ctx) + throws IOException { + return mockUpdateCommonhausData(builder, botGithub, ctx, "src/test/resources/commonhaus-user.yaml"); + } + + public GHContentBuilder mockUpdateCommonhausData(GHContentBuilder builder, GitHub botGithub, AppContextService ctx, String filename) throws IOException { + when(builder.content(anyString())).thenReturn(builder); + when(builder.message(anyString())).thenReturn(builder); + when(builder.path(anyString())).thenReturn(builder); + when(builder.sha(anyString())).thenReturn(builder); + + GHContent responseContent = mock(GHContent.class); + when(responseContent.read()) + .thenReturn(Files.newInputStream(Path.of(filename))); + when(responseContent.getSha()).thenReturn("1234567890adefgh"); + + GHRepository dataStore = botGithub.getRepository(ctx.getDataStore()); + when(dataStore.createContent()).thenReturn(builder); + + GHContentUpdateResponse response = Mockito.mock(GHContentUpdateResponse.class); + when(response.getContent()).thenReturn(responseContent); + + when(builder.commit()).thenReturn(response); + + return builder; + } + + public void setLabels(String id, DataLabel... labels) { + BaseQueryCache.LABELS.computeIfAbsent(id, (k) -> new HashSet<>()).addAll(List.of(labels)); + } + + public void setLabels(String id, Set labels) { + BaseQueryCache.LABELS.computeIfAbsent(id, (k) -> new HashSet<>()).addAll(labels); + } + @Override public String getLogId() { throw new UnsupportedOperationException("Unimplemented method 'getLogId'"); diff --git a/cf-admin-bot/src/test/resources/github/eventIssueLabeled-accepted.json b/cf-admin-bot/src/test/resources/github/eventIssueLabeled-accepted.json new file mode 100644 index 0000000..5c9ddd9 --- /dev/null +++ b/cf-admin-bot/src/test/resources/github/eventIssueLabeled-accepted.json @@ -0,0 +1,227 @@ +{ + "action": "labeled", + "issue": { + "url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6", + "repository_url": "https://api.github.com/repos/commonhaus-test/ops-test", + "labels_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/labels{/name}", + "comments_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/comments", + "events_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/events", + "html_url": "https://github.com/commonhaus-test/ops-test/issues/6", + "id": 2345115049, + "node_id": "I_kwDOL8tG0s6Lx52p", + "number": 6, + "title": "Membership application: Any Name (commonhaus-bot)", + "user": { + "login": "commonhaus-test-bot[bot]", + "id": 156447886, + "node_id": "BOT_kgDOCVM0jg", + "avatar_url": "https://avatars.githubusercontent.com/u/156364140?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D", + "html_url": "https://github.com/apps/commonhaus-test-bot", + "followers_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/followers", + "following_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/following{/other_user}", + "gists_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/gists{/gist_id}", + "starred_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/subscriptions", + "organizations_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/orgs", + "repos_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/repos", + "events_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/events{/privacy}", + "received_events_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/received_events", + "type": "Bot", + "site_admin": false + }, + "labels": [ + { + "id": 7065603553, + "node_id": "LA_kwDOL8tG0s8AAAABpSSN4Q", + "url": "https://api.github.com/repos/commonhaus-test/ops-test/labels/application/accepted", + "name": "application/accepted", + "color": "C7ECB7", + "default": false, + "description": "" + } + ], + "state": "open", + "locked": false, + "assignee": null, + "assignees": [ + + ], + "milestone": null, + "comments": 0, + "created_at": "2024-06-11T01:06:59Z", + "updated_at": "2024-06-11T18:33:01Z", + "closed_at": null, + "author_association": "NONE", + "active_lock_reason": null, + "body": "[ebullient](https://github.com/ebullient)\n\n> [!TIP]\n> - Include \"::response::\" in your comment to send feedback to the applicant.\n> - Add the 'application/accepted' label to accept the application.\n> - Add the 'application/declined' label to decline or reject the application.\n\n## Contribution Details\n\nTry again. I think the old one was lost.\n\n\n## Additional Notes\n\nStatus: PENDING\r\nRoles: cfc, egc, sponsor\n\n", + "reactions": { + "url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/timeline", + "performed_via_github_app": null, + "state_reason": "reopened" + }, + "label": { + "id": 7065603553, + "node_id": "LA_kwDOL8tG0s8AAAABpSSN4Q", + "url": "https://api.github.com/repos/commonhaus-test/ops-test/labels/application/accepted", + "name": "application/accepted", + "color": "C7ECB7", + "default": false, + "description": "" + }, + "repository": { + "id": 801851090, + "node_id": "R_kgDOL8tG0g", + "name": "ops-test", + "full_name": "commonhaus-test/ops-test", + "private": true, + "owner": { + "login": "commonhaus-test", + "id": 168673220, + "node_id": "O_kgDOCg2_xA", + "avatar_url": "https://avatars.githubusercontent.com/u/168673220?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/commonhaus-test", + "html_url": "https://github.com/commonhaus-test", + "followers_url": "https://api.github.com/users/commonhaus-test/followers", + "following_url": "https://api.github.com/users/commonhaus-test/following{/other_user}", + "gists_url": "https://api.github.com/users/commonhaus-test/gists{/gist_id}", + "starred_url": "https://api.github.com/users/commonhaus-test/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/commonhaus-test/subscriptions", + "organizations_url": "https://api.github.com/users/commonhaus-test/orgs", + "repos_url": "https://api.github.com/users/commonhaus-test/repos", + "events_url": "https://api.github.com/users/commonhaus-test/events{/privacy}", + "received_events_url": "https://api.github.com/users/commonhaus-test/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/commonhaus-test/ops-test", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/commonhaus-test/ops-test", + "forks_url": "https://api.github.com/repos/commonhaus-test/ops-test/forks", + "keys_url": "https://api.github.com/repos/commonhaus-test/ops-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/commonhaus-test/ops-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/commonhaus-test/ops-test/teams", + "hooks_url": "https://api.github.com/repos/commonhaus-test/ops-test/hooks", + "issue_events_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/commonhaus-test/ops-test/events", + "assignees_url": "https://api.github.com/repos/commonhaus-test/ops-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/commonhaus-test/ops-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/commonhaus-test/ops-test/tags", + "blobs_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/commonhaus-test/ops-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/commonhaus-test/ops-test/languages", + "stargazers_url": "https://api.github.com/repos/commonhaus-test/ops-test/stargazers", + "contributors_url": "https://api.github.com/repos/commonhaus-test/ops-test/contributors", + "subscribers_url": "https://api.github.com/repos/commonhaus-test/ops-test/subscribers", + "subscription_url": "https://api.github.com/repos/commonhaus-test/ops-test/subscription", + "commits_url": "https://api.github.com/repos/commonhaus-test/ops-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/commonhaus-test/ops-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/commonhaus-test/ops-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/commonhaus-test/ops-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/commonhaus-test/ops-test/merges", + "archive_url": "https://api.github.com/repos/commonhaus-test/ops-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/commonhaus-test/ops-test/downloads", + "issues_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/commonhaus-test/ops-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/commonhaus-test/ops-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/commonhaus-test/ops-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/commonhaus-test/ops-test/labels{/name}", + "releases_url": "https://api.github.com/repos/commonhaus-test/ops-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/commonhaus-test/ops-test/deployments", + "created_at": "2024-05-17T03:23:20Z", + "updated_at": "2024-06-11T01:37:05Z", + "pushed_at": "2024-06-11T01:37:02Z", + "git_url": "git://github.com/commonhaus-test/ops-test.git", + "ssh_url": "git@github.com:commonhaus-test/ops-test.git", + "clone_url": "https://github.com/commonhaus-test/ops-test.git", + "svn_url": "https://github.com/commonhaus-test/ops-test", + "homepage": null, + "size": 92, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 2, + "license": null, + "allow_forking": false, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "private", + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "main", + "custom_properties": { + + } + }, + "organization": { + "login": "commonhaus-test", + "id": 168673220, + "node_id": "O_kgDOCg2_xA", + "url": "https://api.github.com/orgs/commonhaus-test", + "repos_url": "https://api.github.com/orgs/commonhaus-test/repos", + "events_url": "https://api.github.com/orgs/commonhaus-test/events", + "hooks_url": "https://api.github.com/orgs/commonhaus-test/hooks", + "issues_url": "https://api.github.com/orgs/commonhaus-test/issues", + "members_url": "https://api.github.com/orgs/commonhaus-test/members{/member}", + "public_members_url": "https://api.github.com/orgs/commonhaus-test/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/168673220?v=4", + "description": "" + }, + "sender": { + "login": "ebullient", + "id": 808713, + "node_id": "MDQ6VXNlcjgwODcxMw==", + "avatar_url": "https://avatars.githubusercontent.com/u/808713?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ebullient", + "html_url": "https://github.com/ebullient", + "followers_url": "https://api.github.com/users/ebullient/followers", + "following_url": "https://api.github.com/users/ebullient/following{/other_user}", + "gists_url": "https://api.github.com/users/ebullient/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ebullient/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ebullient/subscriptions", + "organizations_url": "https://api.github.com/users/ebullient/orgs", + "repos_url": "https://api.github.com/users/ebullient/repos", + "events_url": "https://api.github.com/users/ebullient/events{/privacy}", + "received_events_url": "https://api.github.com/users/ebullient/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 50263360, + "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uNTAyNjMzNjA=" + } +} diff --git a/cf-admin-bot/src/test/resources/github/eventIssueLabeled-declined.json b/cf-admin-bot/src/test/resources/github/eventIssueLabeled-declined.json new file mode 100644 index 0000000..e06a570 --- /dev/null +++ b/cf-admin-bot/src/test/resources/github/eventIssueLabeled-declined.json @@ -0,0 +1,227 @@ +{ + "action": "labeled", + "issue": { + "url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6", + "repository_url": "https://api.github.com/repos/commonhaus-test/ops-test", + "labels_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/labels{/name}", + "comments_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/comments", + "events_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/events", + "html_url": "https://github.com/commonhaus-test/ops-test/issues/6", + "id": 2345115049, + "node_id": "I_kwDOL8tG0s6Lx52p", + "number": 6, + "title": "Membership application: Any Name (commonhaus-bot)", + "user": { + "login": "commonhaus-test-bot[bot]", + "id": 156447886, + "node_id": "BOT_kgDOCVM0jg", + "avatar_url": "https://avatars.githubusercontent.com/u/156364140?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D", + "html_url": "https://github.com/apps/commonhaus-test-bot", + "followers_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/followers", + "following_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/following{/other_user}", + "gists_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/gists{/gist_id}", + "starred_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/subscriptions", + "organizations_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/orgs", + "repos_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/repos", + "events_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/events{/privacy}", + "received_events_url": "https://api.github.com/users/commonhaus-test-bot%5Bbot%5D/received_events", + "type": "Bot", + "site_admin": false + }, + "labels": [ + { + "id": 7065603553, + "node_id": "LA_kwDOL8tG0s8AAAABpSSN4Q", + "url": "https://api.github.com/repos/commonhaus-test/ops-test/labels/application/accepted", + "name": "application/accepted", + "color": "C7ECB7", + "default": false, + "description": "" + } + ], + "state": "open", + "locked": false, + "assignee": null, + "assignees": [ + + ], + "milestone": null, + "comments": 0, + "created_at": "2024-06-11T01:06:59Z", + "updated_at": "2024-06-11T18:33:01Z", + "closed_at": null, + "author_association": "NONE", + "active_lock_reason": null, + "body": "[ebullient](https://github.com/ebullient)\n\n> [!TIP]\n> - Include \"::response::\" in your comment to send feedback to the applicant.\n> - Add the 'application/accepted' label to accept the application.\n> - Add the 'application/declined' label to decline or reject the application.\n\n## Contribution Details\n\nTry again. I think the old one was lost.\n\n\n## Additional Notes\n\nStatus: PENDING\r\nRoles: cfc, egc, sponsor\n\n", + "reactions": { + "url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/6/timeline", + "performed_via_github_app": null, + "state_reason": "reopened" + }, + "label": { + "id": 7065603903, + "node_id": "LA_kwDOKRPTI88AAAABhGp_7g", + "url": "https://api.github.com/repos/commonhaus-test/ops-test/labels/application/declined", + "name": "application/declined", + "color": "C7ECB7", + "default": false, + "description": "" + }, + "repository": { + "id": 801851090, + "node_id": "R_kgDOL8tG0g", + "name": "ops-test", + "full_name": "commonhaus-test/ops-test", + "private": true, + "owner": { + "login": "commonhaus-test", + "id": 168673220, + "node_id": "O_kgDOCg2_xA", + "avatar_url": "https://avatars.githubusercontent.com/u/168673220?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/commonhaus-test", + "html_url": "https://github.com/commonhaus-test", + "followers_url": "https://api.github.com/users/commonhaus-test/followers", + "following_url": "https://api.github.com/users/commonhaus-test/following{/other_user}", + "gists_url": "https://api.github.com/users/commonhaus-test/gists{/gist_id}", + "starred_url": "https://api.github.com/users/commonhaus-test/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/commonhaus-test/subscriptions", + "organizations_url": "https://api.github.com/users/commonhaus-test/orgs", + "repos_url": "https://api.github.com/users/commonhaus-test/repos", + "events_url": "https://api.github.com/users/commonhaus-test/events{/privacy}", + "received_events_url": "https://api.github.com/users/commonhaus-test/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/commonhaus-test/ops-test", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/commonhaus-test/ops-test", + "forks_url": "https://api.github.com/repos/commonhaus-test/ops-test/forks", + "keys_url": "https://api.github.com/repos/commonhaus-test/ops-test/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/commonhaus-test/ops-test/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/commonhaus-test/ops-test/teams", + "hooks_url": "https://api.github.com/repos/commonhaus-test/ops-test/hooks", + "issue_events_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/events{/number}", + "events_url": "https://api.github.com/repos/commonhaus-test/ops-test/events", + "assignees_url": "https://api.github.com/repos/commonhaus-test/ops-test/assignees{/user}", + "branches_url": "https://api.github.com/repos/commonhaus-test/ops-test/branches{/branch}", + "tags_url": "https://api.github.com/repos/commonhaus-test/ops-test/tags", + "blobs_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/commonhaus-test/ops-test/statuses/{sha}", + "languages_url": "https://api.github.com/repos/commonhaus-test/ops-test/languages", + "stargazers_url": "https://api.github.com/repos/commonhaus-test/ops-test/stargazers", + "contributors_url": "https://api.github.com/repos/commonhaus-test/ops-test/contributors", + "subscribers_url": "https://api.github.com/repos/commonhaus-test/ops-test/subscribers", + "subscription_url": "https://api.github.com/repos/commonhaus-test/ops-test/subscription", + "commits_url": "https://api.github.com/repos/commonhaus-test/ops-test/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/commonhaus-test/ops-test/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/commonhaus-test/ops-test/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/commonhaus-test/ops-test/contents/{+path}", + "compare_url": "https://api.github.com/repos/commonhaus-test/ops-test/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/commonhaus-test/ops-test/merges", + "archive_url": "https://api.github.com/repos/commonhaus-test/ops-test/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/commonhaus-test/ops-test/downloads", + "issues_url": "https://api.github.com/repos/commonhaus-test/ops-test/issues{/number}", + "pulls_url": "https://api.github.com/repos/commonhaus-test/ops-test/pulls{/number}", + "milestones_url": "https://api.github.com/repos/commonhaus-test/ops-test/milestones{/number}", + "notifications_url": "https://api.github.com/repos/commonhaus-test/ops-test/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/commonhaus-test/ops-test/labels{/name}", + "releases_url": "https://api.github.com/repos/commonhaus-test/ops-test/releases{/id}", + "deployments_url": "https://api.github.com/repos/commonhaus-test/ops-test/deployments", + "created_at": "2024-05-17T03:23:20Z", + "updated_at": "2024-06-11T01:37:05Z", + "pushed_at": "2024-06-11T01:37:02Z", + "git_url": "git://github.com/commonhaus-test/ops-test.git", + "ssh_url": "git@github.com:commonhaus-test/ops-test.git", + "clone_url": "https://github.com/commonhaus-test/ops-test.git", + "svn_url": "https://github.com/commonhaus-test/ops-test", + "homepage": null, + "size": 92, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": false, + "has_pages": false, + "has_discussions": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 2, + "license": null, + "allow_forking": false, + "is_template": false, + "web_commit_signoff_required": false, + "topics": [ + + ], + "visibility": "private", + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "main", + "custom_properties": { + + } + }, + "organization": { + "login": "commonhaus-test", + "id": 168673220, + "node_id": "O_kgDOCg2_xA", + "url": "https://api.github.com/orgs/commonhaus-test", + "repos_url": "https://api.github.com/orgs/commonhaus-test/repos", + "events_url": "https://api.github.com/orgs/commonhaus-test/events", + "hooks_url": "https://api.github.com/orgs/commonhaus-test/hooks", + "issues_url": "https://api.github.com/orgs/commonhaus-test/issues", + "members_url": "https://api.github.com/orgs/commonhaus-test/members{/member}", + "public_members_url": "https://api.github.com/orgs/commonhaus-test/public_members{/member}", + "avatar_url": "https://avatars.githubusercontent.com/u/168673220?v=4", + "description": "" + }, + "sender": { + "login": "ebullient", + "id": 808713, + "node_id": "MDQ6VXNlcjgwODcxMw==", + "avatar_url": "https://avatars.githubusercontent.com/u/808713?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ebullient", + "html_url": "https://github.com/ebullient", + "followers_url": "https://api.github.com/users/ebullient/followers", + "following_url": "https://api.github.com/users/ebullient/following{/other_user}", + "gists_url": "https://api.github.com/users/ebullient/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ebullient/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ebullient/subscriptions", + "organizations_url": "https://api.github.com/users/ebullient/orgs", + "repos_url": "https://api.github.com/users/ebullient/repos", + "events_url": "https://api.github.com/users/ebullient/events{/privacy}", + "received_events_url": "https://api.github.com/users/ebullient/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 50263360, + "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uNTAyNjMzNjA=" + } +} diff --git a/cf-admin-bot/src/test/resources/github/mutableRemoveLabelsFromLabelable.json b/cf-admin-bot/src/test/resources/github/mutableRemoveLabelsFromLabelable.json new file mode 100644 index 0000000..7d4c666 --- /dev/null +++ b/cf-admin-bot/src/test/resources/github/mutableRemoveLabelsFromLabelable.json @@ -0,0 +1,19 @@ +{ + "removeLabelsFromLabelable": { + "clientMutationId": null, + "labelable": { + "labels": { + "nodes": [ + { + "id": "LA_kwDOL8tG0s8AAAABpSSN4Q", + "name": "application/accepted" + } + ], + "pageInfo": { + "hasNextPage": false, + "endCursor": "MQ" + } + } + } + } +} diff --git a/commonhaus-bot/src/test/java/org/commonhaus/automation/github/voting/VotingTest.java b/commonhaus-bot/src/test/java/org/commonhaus/automation/github/voting/VotingTest.java index bdeb8e8..472a2cb 100644 --- a/commonhaus-bot/src/test/java/org/commonhaus/automation/github/voting/VotingTest.java +++ b/commonhaus-bot/src/test/java/org/commonhaus/automation/github/voting/VotingTest.java @@ -76,7 +76,7 @@ protected void beforeEach() { @AfterEach protected void noErrorMail() throws Exception { await().failFast(() -> mailbox.getTotalMessagesSent() != 0) - .atMost(5, TimeUnit.SECONDS); + .atMost(3, TimeUnit.SECONDS); } @Test