2121 */
2222
2323import com .walmartlabs .concord .client2 .*;
24- import com .walmartlabs .concord .client2 .ProcessListFilter ;
2524import org .junit .jupiter .api .AfterEach ;
2625import org .junit .jupiter .api .Test ;
2726
@@ -43,21 +42,9 @@ public void tearDown() throws Exception {
4342 }
4443
4544 /**
46- * Test subscription to unknown repositories only:
47- * <pre>
48- * # project A
49- * # a default onPush trigger for the default branch
50- * triggers:
51- * - github:
52- * entryPoint: onPush
53- *
54- * # project G
55- * # accepts only specific commit authors
56- * triggers:
57- * - github:
58- * author: ".*xyz.*"
59- * entryPoint: onPush
60- * </pre>
45+ * Checks if "conditions->sender" works.
46+ * Tests filtering by "sender" in events that originate from "known"
47+ * and "unknown" (not registered in any Concord project) GitHub repositories.
6148 */
6249 @ Test
6350 public void testFilterBySender () throws Exception {
@@ -66,47 +53,41 @@ public void testFilterBySender() throws Exception {
6653 String orgXName = "orgX_" + randomString ();
6754 orgApi .createOrUpdateOrg (new OrganizationEntry ().name (orgXName ));
6855
69- Path repo = initRepo ("githubTests/repos/v2/defaultTrigger" );
70- String branch = "branch_" + randomString ();
71- createNewBranch (repo , branch , "githubTests/repos/v2/defaultTriggerWithSender" );
72-
73- // Project A
74- // master branch + a default trigger
56+ // project A uses a default trigger without conditions
57+ // should trigger on any event for the matching "known" repository
58+ // i.e. the event must come from a GitHub URL that is added to a Concord project
7559 String projectAName = "projectA_" + randomString ();
7660 String repoAName = "repoA_" + randomString ();
7761 Path projectARepo = initProjectAndRepo (orgXName , projectAName , repoAName , null , initRepo ("githubTests/repos/v2/defaultTrigger" ));
7862 refreshRepo (orgXName , projectAName , repoAName );
7963
80- // Project G
81- // accepts only specific commit authors
64+ // project G accepts only specific event senders but from any repository
65+ // (including events from GitHub URLs that are not registered in any Concord project)
8266 String projectGName = "projectG_" + randomString ();
8367 String repoGName = "repoG_" + randomString ();
84- Path projectBRepo = initProjectAndRepo (orgXName , projectGName , repoGName , null , initRepo ("githubTests/repos/v2/defaultTriggerWithSender " ));
68+ initProjectAndRepo (orgXName , projectGName , repoGName , null , initRepo ("githubTests/repos/v2/anyRepoWithSender " ));
8569 refreshRepo (orgXName , projectGName , repoGName );
8670
87- // ---
88-
71+ // send an a projectARepo event from a random sender
8972 sendEvent ("githubTests/events/direct_branch_push.json" , "push" ,
9073 "_FULL_REPO_NAME" , toRepoName (projectARepo ),
9174 "_REF" , "refs/heads/master" ,
92- "_USER_NAME" , "aknowndude" ,
75+ "_USER_NAME" , "arandomdude" + randomString () ,
9376 "_USER_LDAP_DN" , "" );
9477
9578 // A's triggers should be activated
96- ProcessEntry procA = waitForAProcess (orgXName , projectAName , "github" );
97- expectNoProceses (orgXName , projectGName , null );
98-
99- // ---
79+ waitForAProcess (orgXName , projectAName , "github" );
80+ // G's triggers should NOT be activated, the event is not from not the right sender
81+ expectNoProcesses (orgXName , projectGName , null );
10082
10183 // see https://github.com/walmartlabs/concord/issues/435
10284 // wait a bit to reliably filter out subsequent processes of projectA
10385 Thread .sleep (1000 );
10486 OffsetDateTime now = OffsetDateTime .now ().truncatedTo (ChronoUnit .SECONDS );
10587
106- // ---
107-
88+ // send an a projectARepo event (again), this time from the user expected by the G trigger
10889 sendEvent ("githubTests/events/direct_branch_push.json" , "push" ,
109- "_FULL_REPO_NAME" , toRepoName ( projectBRepo ),
90+ "_FULL_REPO_NAME" , "org" + randomString () + "/" + "repo" + randomString (), // a random ("unknown") GitHub repository
11091 "_REF" , "refs/heads/master" ,
11192 "_USER_NAME" , "somecooldude" ,
11293 "_USER_LDAP_DN" , "" );
@@ -115,9 +96,9 @@ public void testFilterBySender() throws Exception {
11596 waitForAProcess (orgXName , projectGName , "github" );
11697
11798 // no A's are expected
118- expectNoProceses (orgXName , projectAName , now );
99+ expectNoProcesses (orgXName , projectAName , now );
119100
120- // ---
101+ // clean up
121102
122103 deleteOrg (orgXName );
123104 }
0 commit comments