diff --git a/src/main/java/org/eclipsefoundation/git/eca/api/models/Project.java b/src/main/java/org/eclipsefoundation/git/eca/api/models/Project.java index f04d4b0eb85d8d66a12db38ba30986af7bf31697..7b30c1be33557fbbf24efc8c0bf4957355b86c50 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/api/models/Project.java +++ b/src/main/java/org/eclipsefoundation/git/eca/api/models/Project.java @@ -23,8 +23,7 @@ import com.google.auto.value.AutoValue; import com.google.auto.value.extension.memoized.Memoized; /** - * Represents a project in the Eclipse API, along with the users and repos that - * exist within the context of the project. + * Represents a project in the Eclipse API, along with the users and repos that exist within the context of the project. * * @author Martin Lowe * @@ -53,6 +52,8 @@ public abstract class Project { public abstract GitlabProject getGitlab(); + public abstract GithubProject getGithub(); + @Nullable @Memoized public String getSpecWorkingGroup() { @@ -71,8 +72,12 @@ public abstract class Project { public static Builder builder() { // adds empty lists as default values - return new AutoValue_Project.Builder().setRepos(new ArrayList<>()).setCommitters(new ArrayList<>()) - .setGithubRepos(new ArrayList<>()).setGitlabRepos(new ArrayList<>()).setGerritRepos(new ArrayList<>()); + return new AutoValue_Project.Builder() + .setRepos(new ArrayList<>()) + .setCommitters(new ArrayList<>()) + .setGithubRepos(new ArrayList<>()) + .setGitlabRepos(new ArrayList<>()) + .setGerritRepos(new ArrayList<>()); } @AutoValue.Builder @@ -98,6 +103,8 @@ public abstract class Project { public abstract Builder setGitlab(GitlabProject gitlab); + public abstract Builder setGithub(GithubProject github); + public abstract Project build(); } @@ -145,6 +152,28 @@ public abstract class Project { } } + @AutoValue + @JsonDeserialize(builder = AutoValue_Project_GithubProject.Builder.class) + public abstract static class GithubProject { + public abstract String getOrg(); + + public abstract List<String> getIgnoredRepos(); + + public static Builder builder() { + return new AutoValue_Project_GithubProject.Builder(); + } + + @AutoValue.Builder + @JsonPOJOBuilder(withPrefix = "set") + public abstract static class Builder { + public abstract Builder setOrg(String org); + + public abstract Builder setIgnoredRepos(List<String> ignoredRepos); + + public abstract GithubProject build(); + } + } + /** * Does not use autovalue as the value should be mutable. * diff --git a/src/main/java/org/eclipsefoundation/git/eca/service/impl/PaginationProjectsService.java b/src/main/java/org/eclipsefoundation/git/eca/service/impl/PaginationProjectsService.java index d360d2e0d739a1f597175e99efcaf62e9682e937..9b48cac9ea16cec2a7aa5faf46d72f4f96897a9b 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/service/impl/PaginationProjectsService.java +++ b/src/main/java/org/eclipsefoundation/git/eca/service/impl/PaginationProjectsService.java @@ -23,6 +23,7 @@ import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; +import org.apache.commons.lang3.StringUtils; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.context.ManagedExecutor; import org.eclipse.microprofile.rest.client.inject.RestClient; @@ -166,11 +167,11 @@ public class PaginationProjectsService implements ProjectsService { } LOGGER.debug("Checking projects for repos that end with: {}", repoUrl); + String projectNamespace = URI.create(repoUrl).getPath().substring(1).toLowerCase(); // filter the projects based on the repo URL. At least one repo in project must // match the repo URL to be valid switch (provider) { case GITLAB: - String projectNamespace = URI.create(repoUrl).getPath().substring(1).toLowerCase(); return availableProjects .stream() .filter(p -> projectNamespace.startsWith(p.getGitlab().getProjectGroup() + "/") @@ -179,7 +180,9 @@ public class PaginationProjectsService implements ProjectsService { case GITHUB: return availableProjects .stream() - .filter(p -> p.getGithubRepos().stream().anyMatch(re -> re.getUrl() != null && re.getUrl().endsWith(repoUrl))) + .filter(p -> p.getGithubRepos().stream().anyMatch(re -> re.getUrl() != null && re.getUrl().endsWith(repoUrl)) + || (StringUtils.isNotBlank(p.getGithub().getOrg()) && projectNamespace.startsWith(p.getGithub().getOrg()) + && p.getGithub().getIgnoredRepos().stream().noneMatch(repoUrl::endsWith))) .collect(Collectors.toList()); case GERRIT: return availableProjects diff --git a/src/test/java/org/eclipsefoundation/git/eca/resource/ValidationResourceTest.java b/src/test/java/org/eclipsefoundation/git/eca/resource/ValidationResourceTest.java index 4edac6e3616288983830828bfbfd72c96ff753c6..144bec7874df81c929a7924a31f226f0c4878c50 100644 --- a/src/test/java/org/eclipsefoundation/git/eca/resource/ValidationResourceTest.java +++ b/src/test/java/org/eclipsefoundation/git/eca/resource/ValidationResourceTest.java @@ -45,9 +45,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.quarkus.test.junit.QuarkusTest; /** - * Tests for verifying end to end validation via the endpoint. Uses restassured - * to create pseudo requests, and Mock API endpoints to ensure that all data is - * kept internal for test checks. + * Tests for verifying end to end validation via the endpoint. Uses restassured to create pseudo requests, and Mock API + * endpoints to ensure that all data is kept internal for test checks. * * @author Martin Lowe * @author Zachary Sabourin @@ -62,34 +61,24 @@ class ValidationResourceTest { /* * USERS */ - public static final GitUser USER_WIZARD = GitUser.builder().setName("The Wizard") - .setMail("code.wiz@important.co") - .build(); - public static final GitUser USER_GRUNTS = GitUser.builder().setName("Grunts McGee") - .setMail("grunt@important.co") - .build(); - public static final GitUser USER_BARSHALL = GitUser.builder().setName("Barshall Blathers") - .setMail("slom@eclipse-foundation.org").build(); - public static final GitUser USER_RANDO = GitUser.builder().setName("Rando Calressian") - .setMail("rando@nowhere.co") - .build(); - public static final GitUser USER_NEWBIE = GitUser.builder().setName("Newbie Anon") - .setMail("newbie@important.co") + public static final GitUser USER_WIZARD = GitUser.builder().setName("The Wizard").setMail("code.wiz@important.co").build(); + public static final GitUser USER_GRUNTS = GitUser.builder().setName("Grunts McGee").setMail("grunt@important.co").build(); + public static final GitUser USER_BARSHALL = GitUser + .builder() + .setName("Barshall Blathers") + .setMail("slom@eclipse-foundation.org") .build(); + public static final GitUser USER_RANDO = GitUser.builder().setName("Rando Calressian").setMail("rando@nowhere.co").build(); + public static final GitUser USER_NEWBIE = GitUser.builder().setName("Newbie Anon").setMail("newbie@important.co").build(); /* * BOTS */ - public static final GitUser BOT_PROJBOT = GitUser.builder().setName("projbot").setMail("1.bot@eclipse.org") - .build(); - public static final GitUser BOT_PROJ_GH = GitUser.builder().setName("protobot-gh") - .setMail("2.bot-github@eclipse.org").build(); - public static final GitUser BOT_PROTOBOT = GitUser.builder().setName("protobot").setMail("2.bot@eclipse.org") - .build(); - public static final GitUser BOT_PROTO_GH = GitUser.builder().setName("protobot-gh") - .setMail("2.bot-github@eclipse.org").build(); - public static final GitUser BOT_SPECBOT = GitUser.builder().setName("specbot").setMail("3.bot@eclipse.org") - .build(); + public static final GitUser BOT_PROJBOT = GitUser.builder().setName("projbot").setMail("1.bot@eclipse.org").build(); + public static final GitUser BOT_PROJ_GH = GitUser.builder().setName("protobot-gh").setMail("2.bot-github@eclipse.org").build(); + public static final GitUser BOT_PROTOBOT = GitUser.builder().setName("protobot").setMail("2.bot@eclipse.org").build(); + public static final GitUser BOT_PROTO_GH = GitUser.builder().setName("protobot-gh").setMail("2.bot-github@eclipse.org").build(); + public static final GitUser BOT_SPECBOT = GitUser.builder().setName("specbot").setMail("3.bot@eclipse.org").build(); /* * BODY PARAMS @@ -102,29 +91,32 @@ class ValidationResourceTest { public static final Commit SUCCESS_COMMIT_WIZARD = createStandardUsercommit(USER_WIZARD, USER_WIZARD); // Best case request body - public static final ValidationRequest VALIDATE_SUCCESS_BODY = createGitHubRequest(false, - "http://www.github.com/eclipsefdn/sample", Arrays.asList(SUCCESS_COMMIT_WIZARD)); + public static final ValidationRequest VALIDATE_SUCCESS_BODY = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", + Arrays.asList(SUCCESS_COMMIT_WIZARD)); /* * BASIC VALIDATE CASES */ - public static final EndpointTestCase VALIDATE_SUCCESS_CASE = TestCaseHelper.prepareTestCase(ECA_BASE_URL, - new String[] {}, SchemaNamespaceHelper.VALIDATION_RESPONSE_SCHEMA_PATH) - .setBodyValidationParams(SUCCESS_BODY_PARAMS).build(); + public static final EndpointTestCase VALIDATE_SUCCESS_CASE = TestCaseHelper + .prepareTestCase(ECA_BASE_URL, new String[] {}, SchemaNamespaceHelper.VALIDATION_RESPONSE_SCHEMA_PATH) + .setBodyValidationParams(SUCCESS_BODY_PARAMS) + .build(); public static final EndpointTestCase VALIDATE_FORBIDDEN_CASE = TestCaseHelper .prepareTestCase(ECA_BASE_URL, new String[] {}, SchemaNamespaceHelper.VALIDATION_RESPONSE_SCHEMA_PATH) - .setStatusCode(403).setBodyValidationParams(FAIL_SINGLE_ERR_BODY_PARAMS).build(); + .setStatusCode(403) + .setBodyValidationParams(FAIL_SINGLE_ERR_BODY_PARAMS) + .build(); /* * LOOKUP CASES */ - public static final EndpointTestCase LOOKUP_SUCCESS_CASE = TestCaseHelper.buildSuccessCase(LOOKUP_URL, - new String[] { "slom@eclipse-foundation.org" }, ""); - public static final EndpointTestCase LOOKUP_FORBIDDEN_CASE = TestCaseHelper.buildForbiddenCase(LOOKUP_URL, - new String[] { "newbie@important.co" }, ""); - public static final EndpointTestCase LOOKUP_NOT_FOUND_CASE = TestCaseHelper.buildNotFoundCase(LOOKUP_URL, - new String[] { "dummy@fake.co" }, ""); + public static final EndpointTestCase LOOKUP_SUCCESS_CASE = TestCaseHelper + .buildSuccessCase(LOOKUP_URL, new String[] { "slom@eclipse-foundation.org" }, ""); + public static final EndpointTestCase LOOKUP_FORBIDDEN_CASE = TestCaseHelper + .buildForbiddenCase(LOOKUP_URL, new String[] { "newbie@important.co" }, ""); + public static final EndpointTestCase LOOKUP_NOT_FOUND_CASE = TestCaseHelper + .buildNotFoundCase(LOOKUP_URL, new String[] { "dummy@fake.co" }, ""); @Inject CachingService cs; @@ -162,8 +154,7 @@ class ValidationResourceTest { throw new RuntimeException(e); } - Assertions.assertTrue( - matchesJsonSchemaInClasspath(SchemaNamespaceHelper.VALIDATION_REQUEST_SCHEMA_PATH).matches(in)); + Assertions.assertTrue(matchesJsonSchemaInClasspath(SchemaNamespaceHelper.VALIDATION_REQUEST_SCHEMA_PATH).matches(in)); } @Test @@ -172,106 +163,151 @@ class ValidationResourceTest { commits.add(SUCCESS_COMMIT_WIZARD); - Commit c2 = Commit.builder().setAuthor(USER_GRUNTS).setCommitter(USER_GRUNTS) + Commit c2 = Commit + .builder() + .setAuthor(USER_GRUNTS) + .setCommitter(USER_GRUNTS) .setBody("Signed-off-by: Grunts McGee<grunt@important.co>") - .setHash("c044dca1847c94e709601651339f88a5c82e3cc7").setSubject("Add in feature") - .setParents(Arrays.asList("46bb69bf6aa4ed26b2bf8c322ae05bef0bcc5c10")).build(); + .setHash("c044dca1847c94e709601651339f88a5c82e3cc7") + .setSubject("Add in feature") + .setParents(Arrays.asList("46bb69bf6aa4ed26b2bf8c322ae05bef0bcc5c10")) + .build(); commits.add(c2); - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", commits)); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", commits)); } @Test void validateMergeCommit() { - Commit c1 = Commit.builder().setAuthor(USER_RANDO).setCommitter(USER_RANDO) + Commit c1 = Commit + .builder() + .setAuthor(USER_RANDO) + .setCommitter(USER_RANDO) .setBody(String.format("Signed-off-by: %s <%s>", USER_RANDO.getName(), USER_RANDO.getMail())) - .setHash(UUID.randomUUID().toString()).setSubject("All of the things") - .setParents(Arrays.asList("46bb69bf6aa4ed26b2bf8c322ae05bef0bcc5c10", - "46bb69bf6aa4ed26b2bf8c322ae05bef0bcc5c11")) + .setHash(UUID.randomUUID().toString()) + .setSubject("All of the things") + .setParents(Arrays.asList("46bb69bf6aa4ed26b2bf8c322ae05bef0bcc5c10", "46bb69bf6aa4ed26b2bf8c322ae05bef0bcc5c11")) .build(); // No errors expected, should pass as only commit is a valid merge commit - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); } @Test void validateCommitNoSignOffCommitter() { - Commit c1 = Commit.builder().setAuthor(USER_GRUNTS).setCommitter(USER_GRUNTS).setBody("") + Commit c1 = Commit + .builder() + .setAuthor(USER_GRUNTS) + .setCommitter(USER_GRUNTS) + .setBody("") .setHash(UUID.randomUUID().toString()) - .setSubject("All of the things").setParents(Collections.emptyList()).build(); + .setSubject("All of the things") + .setParents(Collections.emptyList()) + .build(); // Should be valid as Grunt is a committer on the prototype project - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); } @Test void validateCommitNoSignOffNonCommitter() { - Commit c1 = Commit.builder().setAuthor(USER_WIZARD).setCommitter(USER_WIZARD).setBody("") + Commit c1 = Commit + .builder() + .setAuthor(USER_WIZARD) + .setCommitter(USER_WIZARD) + .setBody("") .setHash(UUID.randomUUID().toString()) - .setSubject("All of the things").setParents(Collections.emptyList()).build(); + .setSubject("All of the things") + .setParents(Collections.emptyList()) + .build(); // Should be valid as wizard has signed ECA - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype.git", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype.git", Arrays.asList(c1))); } @Test void validateCommitInvalidSignOff() { - Commit c1 = Commit.builder().setAuthor(USER_BARSHALL).setCommitter(USER_BARSHALL) + Commit c1 = Commit + .builder() + .setAuthor(USER_BARSHALL) + .setCommitter(USER_BARSHALL) .setBody(String.format("Signed-off-by: %s <%s>", USER_BARSHALL.getName(), "barshallb@personal.co")) - .setHash(UUID.randomUUID().toString()).setSubject("All of the things") - .setParents(Collections.emptyList()).build(); + .setHash(UUID.randomUUID().toString()) + .setSubject("All of the things") + .setParents(Collections.emptyList()) + .build(); // Should be valid as signed off by footer is no longer checked - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype.git", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype.git", Arrays.asList(c1))); } @Test void validateCommitSignOffMultipleFooterLines_Last() { - Commit c1 = Commit.builder().setAuthor(USER_BARSHALL).setCommitter(USER_BARSHALL) - .setBody(String.format("Change-Id: 0000000000000001\nSigned-off-by: %s <%s>", USER_BARSHALL.getName(), - USER_BARSHALL.getMail())) - .setHash(UUID.randomUUID().toString()).setSubject("All of the things") - .setParents(Collections.emptyList()).build(); + Commit c1 = Commit + .builder() + .setAuthor(USER_BARSHALL) + .setCommitter(USER_BARSHALL) + .setBody(String + .format("Change-Id: 0000000000000001\nSigned-off-by: %s <%s>", USER_BARSHALL.getName(), USER_BARSHALL.getMail())) + .setHash(UUID.randomUUID().toString()) + .setSubject("All of the things") + .setParents(Collections.emptyList()) + .build(); - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); } @Test void validateCommitSignOffMultipleFooterLines_First() { - Commit c1 = Commit.builder().setAuthor(USER_BARSHALL).setCommitter(USER_BARSHALL) - .setBody(String.format("Signed-off-by: %s <%s>\nChange-Id: 0000000000000001", USER_BARSHALL.getName(), - USER_BARSHALL.getMail())) - .setHash(UUID.randomUUID().toString()).setSubject("All of the things") - .setParents(Collections.emptyList()).build(); + Commit c1 = Commit + .builder() + .setAuthor(USER_BARSHALL) + .setCommitter(USER_BARSHALL) + .setBody(String + .format("Signed-off-by: %s <%s>\nChange-Id: 0000000000000001", USER_BARSHALL.getName(), USER_BARSHALL.getMail())) + .setHash(UUID.randomUUID().toString()) + .setSubject("All of the things") + .setParents(Collections.emptyList()) + .build(); - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); } @Test void validateCommitSignOffMultipleFooterLines_Multiple() { - Commit c1 = Commit.builder().setAuthor(USER_BARSHALL).setCommitter(USER_BARSHALL) - .setBody(String.format( - "Change-Id: 0000000000000001\\nSigned-off-by: %s <%s>\nSigned-off-by: %s <%s>", - USER_BARSHALL.getName(), USER_BARSHALL.getMail(), USER_BARSHALL.getName(), - "barshallb@personal.co")) - .setHash(UUID.randomUUID().toString()).setSubject("All of the things") - .setParents(Collections.emptyList()).build(); + Commit c1 = Commit + .builder() + .setAuthor(USER_BARSHALL) + .setCommitter(USER_BARSHALL) + .setBody(String + .format("Change-Id: 0000000000000001\\nSigned-off-by: %s <%s>\nSigned-off-by: %s <%s>", USER_BARSHALL.getName(), + USER_BARSHALL.getMail(), USER_BARSHALL.getName(), "barshallb@personal.co")) + .setHash(UUID.randomUUID().toString()) + .setSubject("All of the things") + .setParents(Collections.emptyList()) + .build(); - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); } @Test void validateWorkingGroupSpecAccess() { // CASE 1: WG Spec project write access valid - ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/tck-proto", + ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn-tck/tck-proto", Arrays.asList(SUCCESS_COMMIT_WIZARD)); // Should be valid as Wizard has spec project write access + is committer @@ -280,24 +316,33 @@ class ValidationResourceTest { // CASE 2: No WG Spec proj write access Commit c1 = createStandardUsercommit(USER_GRUNTS, USER_GRUNTS); - vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/tck-proto", Arrays.asList(c1)); + vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn-tck/tck-proto", Arrays.asList(c1)); // Should be invalid as Grunt does not have spec project write access // Should have 2 errors, as both users get validated Map<String, Object> bodyParams = new HashMap<>(FAIL_DOUBLE_ERR_BODY_PARAMS); bodyParams.put("commits." + c1.getHash() + ".errors[0].code", APIStatusCode.ERROR_SPEC_PROJECT.getValue()); - RestAssuredTemplates.testPost(TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "") - .setStatusCode(403).setBodyValidationParams(bodyParams).build(), vr); + RestAssuredTemplates + .testPost(TestCaseHelper + .prepareTestCase(ECA_BASE_URL, new String[] {}, "") + .setStatusCode(403) + .setBodyValidationParams(bodyParams) + .build(), vr); } + /* + * ECA SIGNATURE STATE TESTS + */ + @Test void validateNoECA_author() { Commit c1 = createStandardUsercommit(USER_NEWBIE, USER_WIZARD); // Error should be singular + that there's no ECA on file - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); } @Test @@ -305,19 +350,23 @@ class ValidationResourceTest { Commit c1 = createStandardUsercommit(USER_WIZARD, USER_NEWBIE); // Error count should be 1 for just the committer access - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); } @Test void validateNoECA_both() { Commit c1 = createStandardUsercommit(USER_NEWBIE, USER_NEWBIE); - ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", - Arrays.asList(c1)); + ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1)); - RestAssuredTemplates.testPost(TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "") - .setStatusCode(403).setBodyValidationParams(FAIL_DOUBLE_ERR_BODY_PARAMS).build(), vr); + RestAssuredTemplates + .testPost(TestCaseHelper + .prepareTestCase(ECA_BASE_URL, new String[] {}, "") + .setStatusCode(403) + .setBodyValidationParams(FAIL_DOUBLE_ERR_BODY_PARAMS) + .build(), vr); } @Test @@ -326,8 +375,9 @@ class ValidationResourceTest { // Error should be singular + that there's no Eclipse Account on file for author // Status 403 (forbidden) is the standard return for invalid requests - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); } @Test @@ -336,8 +386,9 @@ class ValidationResourceTest { // Error should be singular + that there's no Eclipse Account on file for committer // Status 403 (forbidden) is the standard return for invalid requests - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); } @Test @@ -345,17 +396,44 @@ class ValidationResourceTest { Commit c1 = createStandardUsercommit(USER_GRUNTS, USER_RANDO); // Should be valid as project is not tracked - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample-not-tracked", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample-not-tracked", Arrays.asList(c1))); + } + + @Test + void validate_ignoredRepo_success() { + // rando is not on the TCK project, so this would fail for a tracked repo, but not an ignored repo + Commit c1 = createStandardUsercommit(USER_RANDO, USER_RANDO); + + // Should be valid as repo is ignored + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn-tck/tck-ignored", Arrays.asList(c1))); + } + + @Test + void validate_ignoredRepo_failure_strictMode() { + // rando is not on the TCK project, so this would fail in strict mode + Commit c1 = createStandardUsercommit(USER_RANDO, USER_RANDO); + + // Should be valid as repo is ignored + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, + createGitHubRequest(true, "http://www.github.com/eclipsefdn-tck/tck-ignored", Arrays.asList(c1))); } + /* + * BOT ACCESS TESTS + */ + @Test void validateBotCommiterAccessGithub() { Commit c1 = createNoBodyCommit(BOT_PROJBOT, BOT_PROJBOT); // Should be valid as bots should only commit on their own projects (including aliases) - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); } @Test @@ -363,8 +441,9 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROJBOT, BOT_PROJBOT); // Should be valid as bots can commit on any untracked project (legacy support) - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample-untracked", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample-untracked", Arrays.asList(c1))); } @Test @@ -372,8 +451,9 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROJ_GH, BOT_PROJ_GH); // Should be invalid as bots should only commit on their own projects (including aliases) - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); } @Test @@ -381,8 +461,9 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROTOBOT, BOT_PROTOBOT); // Should be invalid as wrong email was used for bot (uses Gerrit bot email) - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, + createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1))); } @Test @@ -390,8 +471,9 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROTO_GH, BOT_PROTO_GH); // Should be valid as bots should only commit on their own projects (including aliases) - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, createGitLabRequest(false, - "https://gitlab.eclipse.org/eclipse/dash-second/dash.handbook.test", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitLabRequest(false, "https://gitlab.eclipse.org/eclipse/dash-second/dash.handbook.test", Arrays.asList(c1))); } @Test @@ -399,8 +481,9 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROTO_GH, BOT_PROTO_GH); // Should be valid as bots can commit on any untracked project (legacy support) - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, createGitLabRequest(false, - "https://gitlab.eclipse.org/eclipse/dash/mirror/dash.handbook.untracked", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGitLabRequest(false, + "https://gitlab.eclipse.org/eclipse/dash/mirror/dash.handbook.untracked", Arrays.asList(c1))); } @Test @@ -408,8 +491,9 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_SPECBOT, BOT_SPECBOT); // Should be invalid as bots should only commit on their own projects - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, createGitLabRequest(false, - "https://gitlab.eclipse.org/eclipse/dash-second/dash.handbook.test", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, + createGitLabRequest(false, "https://gitlab.eclipse.org/eclipse/dash-second/dash.handbook.test", Arrays.asList(c1))); } @Test @@ -417,8 +501,9 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_SPECBOT, BOT_SPECBOT); // Should be valid as wrong email was used, but is still bot email alias (uses Gerrit bot email) - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGitLabRequest(false, "https://gitlab.eclipse.org/eclipse/dash/dash.git", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, + createGitLabRequest(false, "https://gitlab.eclipse.org/eclipse/dash/dash.git", Arrays.asList(c1))); } @Test @@ -426,8 +511,8 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROTOBOT, BOT_PROTOBOT); // Should be valid as bots should only commit on their own projects (including aliases) - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } @Test @@ -435,8 +520,8 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROTOBOT, BOT_PROTOBOT); // Should be valid as bots can commit on any untracked project (legacy support) - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGerritRequest(true, "/gitroot/sample/untracked.project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGerritRequest(true, "/gitroot/sample/untracked.project", Arrays.asList(c1))); } @Test @@ -444,8 +529,8 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_SPECBOT, BOT_SPECBOT); // Should be invalid as bots should only commit on their own projects (wrong project) - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } @Test @@ -453,8 +538,8 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROTO_GH, BOT_PROTO_GH); // Should be valid as wrong email was used, but is still bot email alias - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } @Test @@ -463,10 +548,14 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(BOT_PROTO_GH, GitUser.builder().setName("protobot-gh").build()); // Should be invalid as there is no email (refuse commit, not server error) - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } + /* + * NO REPLY TESTS + */ + @Test void validateGithubNoReply_legacy() { GitUser g1 = GitUser.builder().setName("grunter").setMail("grunter@users.noreply.github.com").build(); @@ -474,33 +563,31 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(g1, g1); // Should be valid as grunter used a no-reply Github account and has a matching GH handle - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } @Test void validateGithubNoReply_success() { // sometimes the user ID and user name are reversed - GitUser g1 = GitUser.builder().setName("grunter").setMail("123456789+grunter@users.noreply.github.com") - .build(); + GitUser g1 = GitUser.builder().setName("grunter").setMail("123456789+grunter@users.noreply.github.com").build(); Commit c1 = createNoBodyCommit(g1, g1); // Should be valid as grunter used a no-reply Github account and has a matching GH handle - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } @Test void validateGithubNoReply_nomatch() { - GitUser g1 = GitUser.builder().setName("some_guy").setMail("123456789+some_guy@users.noreply.github.com") - .build(); + GitUser g1 = GitUser.builder().setName("some_guy").setMail("123456789+some_guy@users.noreply.github.com").build(); Commit c1 = createNoBodyCommit(g1, g1); // Should be invalid as no user exists with "Github" handle that matches some_guy - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } @Test @@ -510,10 +597,14 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(g1, g1); // Should be invalid as no user exists with "Github" handle that matches some_guy - RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_FORBIDDEN_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } + /* + * ALLOW LIST TESTS + */ + @Test void validateAllowListAuthor_success() { GitUser g1 = GitUser.builder().setName("grunter").setMail("grunter@users.noreply.github.com").build(); @@ -522,8 +613,8 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(g2, g1); // Should be valid as grunter used a no-reply Github account and has a matching GH handle - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } @Test @@ -534,8 +625,8 @@ class ValidationResourceTest { Commit c1 = createNoBodyCommit(g1, g2); // Should be valid as grunter used a no-reply Github account and has a matching GH handle - RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, - createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); + RestAssuredTemplates + .testPost(VALIDATE_SUCCESS_CASE, createGerritRequest(true, "/gitroot/sample/gerrit.other-project", Arrays.asList(c1))); } /* @@ -543,26 +634,24 @@ class ValidationResourceTest { */ @Test void validateRevalidation_success() { - ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", - Arrays.asList(SUCCESS_COMMIT_WIZARD)); + ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(SUCCESS_COMMIT_WIZARD)); RestAssuredTemplates.testPost(VALIDATE_SUCCESS_CASE, vr); Map<String, Object> bodyParams = new HashMap<>(SUCCESS_BODY_PARAMS); - bodyParams.put("commits." + SUCCESS_COMMIT_WIZARD.getHash() + ".messages[0].code", - APIStatusCode.SUCCESS_SKIPPED.getValue()); + bodyParams.put("commits." + SUCCESS_COMMIT_WIZARD.getHash() + ".messages[0].code", APIStatusCode.SUCCESS_SKIPPED.getValue()); // repeat call to test that skipped status is passed - RestAssuredTemplates.testPost(TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "") - .setBodyValidationParams(bodyParams).build(), vr); + RestAssuredTemplates + .testPost(TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "").setBodyValidationParams(bodyParams).build(), + vr); } @Test void validateRevalidation_errors() { Commit c1 = createStandardUsercommit(USER_NEWBIE, USER_WIZARD); - ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", - Arrays.asList(c1)); + ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1)); // should fail with 1 error RestAssuredTemplates.testPost(VALIDATE_FORBIDDEN_CASE, vr); @@ -571,8 +660,12 @@ class ValidationResourceTest { bodyParams.put("commits." + c1.getHash() + ".errors[0].code", APIStatusCode.ERROR_AUTHOR.getValue()); // repeat call to test that previously run check still fails - RestAssuredTemplates.testPost(TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "") - .setStatusCode(403).setBodyValidationParams(bodyParams).build(), vr); + RestAssuredTemplates + .testPost(TestCaseHelper + .prepareTestCase(ECA_BASE_URL, new String[] {}, "") + .setStatusCode(403) + .setBodyValidationParams(bodyParams) + .build(), vr); } @Test @@ -593,46 +686,51 @@ class ValidationResourceTest { Map<String, Object> bodyParams = new HashMap<>(FAIL_SINGLE_ERR_BODY_PARAMS); bodyParams.put("commits." + c2.getHash() + ".errors[0].code", APIStatusCode.ERROR_AUTHOR.getValue()); - bodyParams.put("commits." + SUCCESS_COMMIT_WIZARD.getHash() + ".messages[0].code", - APIStatusCode.SUCCESS_SKIPPED.getValue()); + bodyParams.put("commits." + SUCCESS_COMMIT_WIZARD.getHash() + ".messages[0].code", APIStatusCode.SUCCESS_SKIPPED.getValue()); // repeat call to test that previously run check still fails - RestAssuredTemplates.testPost(TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "") - .setStatusCode(403).setBodyValidationParams(bodyParams).build(), vr); + RestAssuredTemplates + .testPost(TestCaseHelper + .prepareTestCase(ECA_BASE_URL, new String[] {}, "") + .setStatusCode(403) + .setBodyValidationParams(bodyParams) + .build(), vr); } @Test void validateRevalidation_commitUpdatedAfterError() { Commit c1 = createStandardUsercommit(USER_NEWBIE, USER_WIZARD); - ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", - Arrays.asList(c1)); + ValidationRequest vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1)); Map<String, Object> bodyParams = new HashMap<>(FAIL_SINGLE_ERR_BODY_PARAMS); bodyParams.put("commits." + c1.getHash() + ".errors[0].code", APIStatusCode.ERROR_AUTHOR.getValue()); - EndpointTestCase testCase = TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "") - .setStatusCode(403).setBodyValidationParams(bodyParams).build(); + EndpointTestCase testCase = TestCaseHelper + .prepareTestCase(ECA_BASE_URL, new String[] {}, "") + .setStatusCode(403) + .setBodyValidationParams(bodyParams) + .build(); RestAssuredTemplates.testPost(testCase, vr); // simulate fixed ECA by updating author and using same hash - c1 = Commit.builder().setAuthor(USER_WIZARD).setCommitter(USER_WIZARD) - .setBody(String.format("Signed-off-by: %s <%s>", - USER_WIZARD.getName(), USER_WIZARD.getMail())) + c1 = Commit + .builder() + .setAuthor(USER_WIZARD) + .setCommitter(USER_WIZARD) + .setBody(String.format("Signed-off-by: %s <%s>", USER_WIZARD.getName(), USER_WIZARD.getMail())) .setHash(c1.getHash()) .setSubject("All of the things") .setParents(Arrays.asList("46bb69bf6aa4ed26b2bf8c322ae05bef0bcc5c10")) .build(); - vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", - Arrays.asList(c1)); + vr = createGitHubRequest(false, "http://www.github.com/eclipsefdn/sample", Arrays.asList(c1)); bodyParams = new HashMap<>(SUCCESS_BODY_PARAMS); bodyParams.put("commits." + c1.getHash() + ".messages[0].code", APIStatusCode.SUCCESS_DEFAULT.getValue()); - testCase = TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "") - .setBodyValidationParams(bodyParams).build(); + testCase = TestCaseHelper.prepareTestCase(ECA_BASE_URL, new String[] {}, "").setBodyValidationParams(bodyParams).build(); RestAssuredTemplates.testPost(testCase, vr); } @@ -657,7 +755,8 @@ class ValidationResourceTest { // The default commit for most users. Used for most user tests private static Commit createStandardUsercommit(GitUser author, GitUser committer) { - return Commit.builder() + return Commit + .builder() .setAuthor(author) .setCommitter(committer) .setBody(String.format("Signed-off-by: %s <%s>", author.getName(), author.getMail())) @@ -669,7 +768,8 @@ class ValidationResourceTest { // The default commit for bots. Used for most bot tests private static Commit createNoBodyCommit(GitUser author, GitUser committer) { - return Commit.builder() + return Commit + .builder() .setAuthor(author) .setCommitter(committer) .setHash(UUID.randomUUID().toString()) @@ -679,7 +779,8 @@ class ValidationResourceTest { } private static ValidationRequest createGitHubRequest(boolean strictMode, String repoUrl, List<Commit> commits) { - return ValidationRequest.builder() + return ValidationRequest + .builder() .setStrictMode(strictMode) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create(repoUrl)) @@ -688,7 +789,8 @@ class ValidationResourceTest { } private static ValidationRequest createGitLabRequest(boolean strictMode, String repoUrl, List<Commit> commits) { - return ValidationRequest.builder() + return ValidationRequest + .builder() .setStrictMode(strictMode) .setProvider(ProviderType.GITLAB) .setRepoUrl(URI.create(repoUrl)) @@ -697,7 +799,8 @@ class ValidationResourceTest { } private static ValidationRequest createGerritRequest(boolean strictMode, String repoUrl, List<Commit> commits) { - return ValidationRequest.builder() + return ValidationRequest + .builder() .setStrictMode(strictMode) .setProvider(ProviderType.GERRIT) .setRepoUrl(URI.create(repoUrl)) diff --git a/src/test/java/org/eclipsefoundation/git/eca/test/api/MockProjectsAPI.java b/src/test/java/org/eclipsefoundation/git/eca/test/api/MockProjectsAPI.java index e52ff5ce3e1e78b391b8adf15d8efba67c7902b5..0528b1ea0497f4772e52e731a45f168b74736f6c 100644 --- a/src/test/java/org/eclipsefoundation/git/eca/test/api/MockProjectsAPI.java +++ b/src/test/java/org/eclipsefoundation/git/eca/test/api/MockProjectsAPI.java @@ -28,6 +28,7 @@ import org.eclipsefoundation.git.eca.api.ProjectsAPI; import org.eclipsefoundation.git.eca.api.models.InterestGroupData; import org.eclipsefoundation.git.eca.api.models.Project; import org.eclipsefoundation.git.eca.api.models.InterestGroupData.Descriptor; +import org.eclipsefoundation.git.eca.api.models.Project.GithubProject; import org.eclipsefoundation.git.eca.api.models.Project.GitlabProject; import org.eclipsefoundation.git.eca.api.models.Project.Repo; import org.eclipsefoundation.git.eca.api.models.Project.User; @@ -52,8 +53,6 @@ public class MockProjectsAPI implements ProjectsAPI { r2.setUrl("http://www.github.com/eclipsefdn/test"); Repo r3 = new Repo(); r3.setUrl("http://www.github.com/eclipsefdn/prototype.git"); - Repo r4 = new Repo(); - r4.setUrl("http://www.github.com/eclipsefdn/tck-proto"); Repo r5 = new Repo(); r5.setUrl("/gitroot/sample/gerrit.project.git"); Repo r6 = new Repo(); @@ -78,6 +77,7 @@ public class MockProjectsAPI implements ProjectsAPI { .setCommitters(Arrays.asList(u1, u2)) .setProjectLeads(Collections.emptyList()) .setGitlab(GitlabProject.builder().setIgnoredSubGroups(Collections.emptyList()).setProjectGroup("").build()) + .setGithub(GithubProject.builder().setIgnoredRepos(Collections.emptyList()).setOrg("").build()) .build(); src.add(p1); @@ -93,6 +93,7 @@ public class MockProjectsAPI implements ProjectsAPI { .setProjectLeads(Collections.emptyList()) .setGitlab( GitlabProject.builder().setIgnoredSubGroups(Collections.emptyList()).setProjectGroup("eclipse/dash-second").build()) + .setGithub(GithubProject.builder().setIgnoredRepos(Collections.emptyList()).setOrg("").build()) .build(); src.add(p2); @@ -103,13 +104,18 @@ public class MockProjectsAPI implements ProjectsAPI { .setName("Spec project") .setProjectId("spec.proj") .setSpecProjectWorkingGroup(map) - .setGithubRepos(Arrays.asList(r4)) + .setGithubRepos(Collections.emptyList()) .setGitlabRepos(Arrays.asList(r7)) .setGitlab(GitlabProject .builder() .setIgnoredSubGroups(Arrays.asList("eclipse/dash/mirror")) .setProjectGroup("eclipse/dash") .build()) + .setGithub(GithubProject + .builder() + .setIgnoredRepos(Arrays.asList("eclipsefdn-tck/tck-ignored")) + .setOrg("eclipsefdn-tck") + .build()) .setCommitters(Arrays.asList(u1, u2)) .setProjectLeads(Collections.emptyList()) .build();