diff --git a/spec/openapi.yaml b/spec/openapi.yaml index 49fe2e295182754e999fe8e6c970a29a5a732fca..9005fa9849edb81a4a114017c07d5a6b2fdb7d7d 100644 --- a/spec/openapi.yaml +++ b/spec/openapi.yaml @@ -286,7 +286,6 @@ components: required: - provider - repoUrl - - strictMode - commits properties: provider: @@ -299,9 +298,6 @@ components: repoUrl: type: string description: the outward facing URL of the repo the commit belongs to. - strictMode: - type: boolean - description: Whether to strictly apply validation regardless of project matching estimatedLoc: type: - integer @@ -371,7 +367,6 @@ components: required: - time - trackedProject - - strictMode - fingerprint - errorCount - passed @@ -383,9 +378,6 @@ components: trackedProject: type: boolean description: Whether the project is tracked in PMI and is an Eclipse project. - strictMode: - type: boolean - description: Whether strict mode was enforced for the validation. fingerprint: type: string description: The unique fingerprint to use when looking up commit data diff --git a/src/main/java/org/eclipsefoundation/git/eca/api/models/GithubWebhookRequest.java b/src/main/java/org/eclipsefoundation/git/eca/api/models/GithubWebhookRequest.java index e68392db3e0f3b901b081a83cfe5dfce45f9265f..540ccdf66becdcdced25c70a9fff6b1b3f7c0219 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/api/models/GithubWebhookRequest.java +++ b/src/main/java/org/eclipsefoundation/git/eca/api/models/GithubWebhookRequest.java @@ -29,6 +29,7 @@ import com.google.auto.value.AutoValue; @AutoValue @JsonDeserialize(builder = AutoValue_GithubWebhookRequest.Builder.class) public abstract class GithubWebhookRequest { + private static final int REPO_FULL_NAME_PARTS = 2; public abstract Installation getInstallation(); @@ -57,7 +58,7 @@ public abstract class GithubWebhookRequest { */ public static GithubWebhookRequest buildFromTracking(GithubWebhookTracking tracking) { String[] repoNameParts = tracking.getRepositoryFullName().split("\\/"); - if (repoNameParts.length != 2) { + if (repoNameParts.length != REPO_FULL_NAME_PARTS) { throw new IllegalStateException("A repo full name should always have 2 parts, organization name and repo name: " + TransformationHelper.formatLog(tracking.getRepositoryFullName())); } diff --git a/src/main/java/org/eclipsefoundation/git/eca/helper/ProjectHelper.java b/src/main/java/org/eclipsefoundation/git/eca/helper/ProjectHelper.java index ad72341ffd7b989c61db9c16d49a40eb6a5ce2e1..bf3370a174f9268adede516770236ca57b713788 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/helper/ProjectHelper.java +++ b/src/main/java/org/eclipsefoundation/git/eca/helper/ProjectHelper.java @@ -26,6 +26,7 @@ import org.eclipsefoundation.efservices.api.models.Project.ProjectParticipant; import org.eclipsefoundation.efservices.services.ProjectService; import org.eclipsefoundation.git.eca.model.ValidationRequest; import org.eclipsefoundation.git.eca.namespace.ProviderType; +import org.eclipsefoundation.utils.helper.TransformationHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,15 +43,10 @@ import jakarta.ws.rs.core.MultivaluedHashMap; */ @ApplicationScoped public final class ProjectHelper { - /** - * - */ private static final String NULL_REPO_MESSAGE = "Can not match null repo URL to projects"; - private static final Logger LOGGER = LoggerFactory.getLogger(ProjectHelper.class); - @Inject CachingService cache; @Inject @@ -80,7 +76,7 @@ public final class ProjectHelper { LOGGER.warn("Could not find any projects to match against"); return Collections.emptyList(); } - LOGGER.debug("Checking projects for repos that end with: {}", repoUrl); + LOGGER.debug("Checking projects for repos that end with: {}", TransformationHelper.formatLog(repoUrl)); // check if the website repo matches first, returning that project if it's found Optional<Project> siteProjectMatch = availableProjects diff --git a/src/main/java/org/eclipsefoundation/git/eca/model/Commit.java b/src/main/java/org/eclipsefoundation/git/eca/model/Commit.java index a4c15f5ba045306d3c939eeaa10dd59f98009a1f..a21506d8da481286cb4279cc45cae8c898019cb4 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/model/Commit.java +++ b/src/main/java/org/eclipsefoundation/git/eca/model/Commit.java @@ -17,6 +17,7 @@ import java.util.List; import jakarta.annotation.Nullable; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.PropertyNamingStrategies.LowerCamelCaseStrategy; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonNaming; @@ -52,6 +53,7 @@ public abstract class Commit { public abstract Boolean getHead(); @Nullable + @JsonIgnore public abstract ZonedDateTime getLastModificationDate(); public static Builder builder() { diff --git a/src/main/java/org/eclipsefoundation/git/eca/model/ValidationRequest.java b/src/main/java/org/eclipsefoundation/git/eca/model/ValidationRequest.java index 3d29f7a91b4a06be809d8f3002b0780c93d4ab28..54ad98b5ee64d8582e8ca304c9303d8bb0c8ffe1 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/model/ValidationRequest.java +++ b/src/main/java/org/eclipsefoundation/git/eca/model/ValidationRequest.java @@ -47,16 +47,10 @@ public abstract class ValidationRequest { @Nullable public abstract Integer getEstimatedLoc(); - - @Nullable - @JsonProperty("strictMode") - @Deprecated - public abstract Boolean getStrictMode(); - public abstract Builder toBuilder(); public static Builder builder() { - return new AutoValue_ValidationRequest.Builder().setStrictMode(false).setCommits(new ArrayList<>()); + return new AutoValue_ValidationRequest.Builder().setCommits(new ArrayList<>()); } @AutoValue.Builder @@ -71,10 +65,6 @@ public abstract class ValidationRequest { public abstract Builder setEstimatedLoc(@Nullable Integer estimatedLoc); - @JsonProperty("strictMode") - @Deprecated - public abstract Builder setStrictMode(@Nullable Boolean strictMode); - public abstract ValidationRequest build(); } } diff --git a/src/main/java/org/eclipsefoundation/git/eca/model/ValidationResponse.java b/src/main/java/org/eclipsefoundation/git/eca/model/ValidationResponse.java index ad46fe49f12066d2b80159628a7daa6b8dbb42a4..ba072eb7fe20e339dcdb47381704bf2f9cf9d210 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/model/ValidationResponse.java +++ b/src/main/java/org/eclipsefoundation/git/eca/model/ValidationResponse.java @@ -45,9 +45,6 @@ public abstract class ValidationResponse { public abstract boolean getTrackedProject(); - @Deprecated - public abstract boolean getStrictMode(); - @Nullable public abstract String getFingerprint(); @@ -62,11 +59,7 @@ public abstract class ValidationResponse { /** @param error message to add to the API response */ public void addError(String hash, String error, APIStatusCode code) { - if (this.getTrackedProject() || this.getStrictMode()) { - getCommits().computeIfAbsent(getHashKey(hash), k -> CommitStatus.builder().build()).addError(error, code); - } else { - getCommits().computeIfAbsent(getHashKey(hash), k -> CommitStatus.builder().build()).addWarning(error, code); - } + getCommits().computeIfAbsent(getHashKey(hash), k -> CommitStatus.builder().build()).addError(error, code); } public static String getHashKey(String hash) { @@ -89,7 +82,6 @@ public abstract class ValidationResponse { public static Builder builder() { return new AutoValue_ValidationResponse.Builder() - .setStrictMode(false) .setTrackedProject(false) .setTime(ZonedDateTime.now()) .setCommits(new HashMap<>()); @@ -104,9 +96,6 @@ public abstract class ValidationResponse { public abstract Builder setTrackedProject(boolean trackedProject); - @Deprecated - public abstract Builder setStrictMode(boolean strictMode); - public abstract Builder setFingerprint(@Nullable String fingerprint); public abstract ValidationResponse build(); diff --git a/src/main/java/org/eclipsefoundation/git/eca/resource/OIDCResource.java b/src/main/java/org/eclipsefoundation/git/eca/resource/OIDCResource.java index 043e36df7959dc7c70cf95367e07b52f7600a282..e7ffa8cfa5b41b86a12799614530b3d4220bfa45 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/resource/OIDCResource.java +++ b/src/main/java/org/eclipsefoundation/git/eca/resource/OIDCResource.java @@ -2,6 +2,8 @@ package org.eclipsefoundation.git.eca.resource; import java.net.URI; +import org.jboss.resteasy.reactive.RestResponse.Status; + import io.quarkus.security.Authenticated; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; @@ -17,6 +19,6 @@ public class OIDCResource { @GET public Response login(@QueryParam("redirect") URI redirect) { - return Response.status(302).location(redirect).build(); + return Response.status(Status.FOUND).location(redirect).build(); } } diff --git a/src/main/java/org/eclipsefoundation/git/eca/resource/ValidationResource.java b/src/main/java/org/eclipsefoundation/git/eca/resource/ValidationResource.java index d45923abdbe9f4779eafc7676010bfd6e2c17280..cc0cd08ebca96e668a7804ac863be31f33642cfa 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/resource/ValidationResource.java +++ b/src/main/java/org/eclipsefoundation/git/eca/resource/ValidationResource.java @@ -78,6 +78,7 @@ public class ValidationResource extends CommonResource { */ @POST public Response validate(ValidationRequest req) { + LOGGER.error("request: {}", req); List<String> messages = checkRequest(req); // only process if we have no errors if (messages.isEmpty()) { @@ -164,7 +165,7 @@ public class ValidationResource extends CommonResource { private List<String> checkRequest(ValidationRequest req) { // check that we have commits to validate List<String> messages = new ArrayList<>(); - if (req.getCommits() == null || req.getCommits().isEmpty()) { + if (req.getCommits() == null) { messages.add("A commit is required to validate"); } // check that we have a type set diff --git a/src/main/java/org/eclipsefoundation/git/eca/service/impl/CachedUserService.java b/src/main/java/org/eclipsefoundation/git/eca/service/impl/CachedUserService.java index cfb9bfd7b18b3b4e12528a1ef5da77666016eadf..68e09ec26437aa305a7f4d5dc04fd4ce0f53cae9 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/service/impl/CachedUserService.java +++ b/src/main/java/org/eclipsefoundation/git/eca/service/impl/CachedUserService.java @@ -29,6 +29,7 @@ import org.eclipsefoundation.efservices.services.ProfileService; import org.eclipsefoundation.git.eca.api.BotsAPI; import org.eclipsefoundation.git.eca.config.MailValidationConfig; import org.eclipsefoundation.git.eca.service.UserService; +import org.eclipsefoundation.utils.helper.TransformationHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -79,10 +80,10 @@ public class CachedUserService implements UserService { CacheWrapper<EfUser> result = cache.get(mail, new MultivaluedHashMap<>(), EfUser.class, () -> retrieveUser(mail)); Optional<EfUser> user = result.getData(); if (user.isPresent()) { - LOGGER.debug("Found user with email {}", mail); + LOGGER.debug("Found user with email {}", TransformationHelper.formatLog(mail)); return user.get(); } - LOGGER.debug("Could not find user with email {}", mail); + LOGGER.debug("Could not find user with email {}", TransformationHelper.formatLog(mail)); return null; } @@ -93,10 +94,10 @@ public class CachedUserService implements UserService { } Optional<EfUser> user = profile.fetchUserByGhHandle(username, true); if (user.isPresent()) { - LOGGER.debug("Found user with name {}", username); + LOGGER.debug("Found user with name {}", TransformationHelper.formatLog(username)); return user.get(); } - LOGGER.debug("Could not find user with name {}", username); + LOGGER.debug("Could not find user with name {}", TransformationHelper.formatLog(username)); return null; } diff --git a/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultSystemHookService.java b/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultSystemHookService.java index eb24c5dba511ca143f2bde96fb29fd685030f929..51fb5e9a3701292de05ef59d2c0fe79bba3f4545 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultSystemHookService.java +++ b/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultSystemHookService.java @@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.rest.client.inject.RestClient; -import org.eclipsefoundation.caching.model.CacheWrapper; import org.eclipsefoundation.caching.service.CachingService; import org.eclipsefoundation.git.eca.api.GitlabAPI; import org.eclipsefoundation.git.eca.api.models.GitlabProjectResponse; @@ -116,12 +115,12 @@ public class DefaultSystemHookService implements SystemHookService { try { LOGGER.debug("Tracking creation of project: [id: {}, path: {}]", hook.getProjectId(), hook.getPathWithNamespace()); - CacheWrapper<GitlabProjectResponse> response = cache + Optional<GitlabProjectResponse> response = cache .get(Integer.toString(hook.getProjectId()), new MultivaluedHashMap<>(), GitlabProjectResponse.class, - () -> api.getProjectInfo(apiToken, hook.getProjectId())); - - if (response.getData().isPresent()) { - PrivateProjectEvent dto = mapToDto(hook, response.getData().get()); + () -> api.getProjectInfo(apiToken, hook.getProjectId())) + .getData(); + if (response.isPresent()) { + PrivateProjectEvent dto = mapToDto(hook, response.get()); dao.add(new RDBMSQuery<>(wrapper, filters.get(PrivateProjectEvent.class)), Arrays.asList(dto)); } else { LOGGER.error("No info for project: [id: {}, path: {}]", hook.getProjectId(), hook.getPathWithNamespace()); @@ -133,8 +132,7 @@ public class DefaultSystemHookService implements SystemHookService { } /** - * Retrieves the event record for the project that has been deleted. Adds the deletionDate field and updates the DB - * record. + * Retrieves the event record for the project that has been deleted. Adds the deletionDate field and updates the DB record. * * @param wrapper the request wrapper containing all uri, ip, and query params * @param hook the incoming system hook @@ -162,8 +160,7 @@ public class DefaultSystemHookService implements SystemHookService { } /** - * Retrieves the event record for the project that has been renamed. Updates the projectPath field and creates a new DB - * record. + * Retrieves the event record for the project that has been renamed. Updates the projectPath field and creates a new DB record. * * @param wrapper the request wrapper containing all uri, ip, and query params * @param hook the incoming system hook diff --git a/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationService.java b/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationService.java index 583c256f596c577121faec59ff6ad54e404c4de9..ee792336f2d017382b7c4c15422b581657a44973 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationService.java +++ b/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationService.java @@ -63,6 +63,8 @@ import jakarta.ws.rs.core.Response.Status; public class DefaultValidationService implements ValidationService { private static final Logger LOGGER = LoggerFactory.getLogger(DefaultValidationService.class); + private static final int PROCESSING_TIMEOUT_IN_SECONDS = 30; + @Inject MailValidationConfig config; @Inject @@ -178,7 +180,7 @@ public class DefaultValidationService implements ValidationService { .with(ValidationResponsePart.class, list -> list); LOGGER.trace("Starting parallel processing w/ lvl {} concurrency", parallelProcessingConfig.threadsPerValidation()); - return out.await().atMost(Duration.of(30, ChronoUnit.SECONDS)); + return out.await().atMost(Duration.of(PROCESSING_TIMEOUT_IN_SECONDS, ChronoUnit.SECONDS)); } /** @@ -447,10 +449,13 @@ public class DefaultValidationService implements ValidationService { * @return true if the commit does not need to be (re)validated, false otherwise. */ private boolean isValidationStatusCurrentAndValid(Optional<CommitValidationStatus> status, Commit c) { - return status.isPresent() && status.get().getErrors().isEmpty() && c.getAuthor() != null - && StringUtils.isNotBlank(status.get().getUserMail()) - && status.get().getUserMail().equalsIgnoreCase(c.getAuthor().getMail()) - && (c.getLastModificationDate() == null || status.get().getLastModified().equals(c.getLastModificationDate())); + boolean statusIsCurrentAndValid = status.isPresent() && status.get().getErrors().isEmpty(); + boolean userMailIsSetAndMatches = (status.isPresent() && StringUtils.isNotBlank(status.get().getUserMail()) + && status.get().getUserMail().equalsIgnoreCase(c.getAuthor().getMail())); + boolean lastModificationDateIsCurrent = c.getLastModificationDate() == null + || (status.isPresent() && status.get().getLastModified().equals(c.getLastModificationDate())); + + return statusIsCurrentAndValid && c.getAuthor() != null && userMailIsSetAndMatches && lastModificationDateIsCurrent; } /** @@ -504,7 +509,6 @@ public class DefaultValidationService implements ValidationService { private ValidationResponse generateBaseResponse(ValidationRequest req, List<Project> filteredProjects) { return ValidationResponse .builder() - .setStrictMode(Boolean.TRUE.equals(req.getStrictMode())) .setTrackedProject(!filteredProjects.isEmpty()) .setFingerprint(CommitHelper.generateRequestHash(req)) .build(); diff --git a/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationStatusService.java b/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationStatusService.java index 00d19252fd348e5cd08cd5edccaa38369290b89b..cf73bf24249ed4a683771a00adb6bbb6a42f4805 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationStatusService.java +++ b/src/main/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationStatusService.java @@ -32,6 +32,7 @@ import org.eclipsefoundation.git.eca.model.CommitStatus; import org.eclipsefoundation.git.eca.model.ValidationRequest; import org.eclipsefoundation.git.eca.model.ValidationResponse; import org.eclipsefoundation.git.eca.namespace.GitEcaParameterNames; +import org.eclipsefoundation.git.eca.service.UserService; import org.eclipsefoundation.git.eca.service.ValidationStatusService; import org.eclipsefoundation.http.model.RequestWrapper; import org.eclipsefoundation.persistence.dao.PersistenceDao; @@ -57,6 +58,8 @@ public class DefaultValidationStatusService implements ValidationStatusService { PersistenceDao dao; @Inject FilterService filters; + @Inject + UserService users; @Override public List<CommitValidationStatus> getHistoricValidationStatus(RequestWrapper wrapper, String fingerprint) { @@ -155,7 +158,6 @@ public class DefaultValidationStatusService implements ValidationStatusService { m.setAuthorEmail(c.getAuthor().getMail()); m.setCommitterEmail(c.getCommitter().getMail()); m.setStatusCode(err.getCode().getValue()); - // TODO add a checked way to set this m.setEclipseId(null); // if a committer status, provide the committer external ID, otherwise pass author external ID m diff --git a/src/main/java/org/eclipsefoundation/git/eca/tasks/GithubInstallationUpdateTask.java b/src/main/java/org/eclipsefoundation/git/eca/tasks/GithubInstallationUpdateTask.java index 5b24ae85a00893e52c5458aaddbdd57bab0340b2..d5380d66c198b3af005acf9d31ef47fd4785af20 100644 --- a/src/main/java/org/eclipsefoundation/git/eca/tasks/GithubInstallationUpdateTask.java +++ b/src/main/java/org/eclipsefoundation/git/eca/tasks/GithubInstallationUpdateTask.java @@ -98,8 +98,6 @@ public class GithubInstallationUpdateTask { // trace log the installations for more context LOGGER.debug("Found {} installations to cache", installations.size()); - // create a common timestamp for easier lookups of stale entries - Date startingTimestamp = new Date(); // from installations, build records and start the processing for each entry List<GithubApplicationInstallation> installationRecords = installations .stream() @@ -115,6 +113,8 @@ public class GithubInstallationUpdateTask { return; } + // create a common timestamp for easier lookups of stale entries + Date startingTimestamp = new Date(); // build query to do cleanup of stale records MultivaluedMap<String, String> params = new MultivaluedHashMap<>(); params.add(GitEcaParameterNames.APPLICATION_ID_RAW, Integer.toString(config.github().appId())); diff --git a/src/main/resources/templates/simple_fingerprint_ui.html b/src/main/resources/templates/simple_fingerprint_ui.html index 4bc08da854c4363359037871e75fb5216f360113..d42a28c3dc3a0e592663d7cc592573dba3def5c5 100644 --- a/src/main/resources/templates/simple_fingerprint_ui.html +++ b/src/main/resources/templates/simple_fingerprint_ui.html @@ -174,7 +174,7 @@ {/if} </section> - <aside id="main-sidebar-secondy" role="complementary" class="col-md-6 col-sm-8 margin-bottom-60" aria-label="eclipse-contributor-agreement"> + <aside id="main-sidebar-secondy" class="col-md-6 col-sm-8 margin-bottom-60" aria-label="eclipse-contributor-agreement"> <div class="region region-sidebar-second solstice-region-element-count-2"> <section id="block-site-login-eclipse-eca-sle-eca-lookup-tool" class="margin-bottom-30 clearfix"> @@ -200,7 +200,7 @@ {/if} </section> <section id="block-eclipse-api-github-eclipse-api-github-links" class="main-sidebar-default-margin"> - <ul id="leftnav" class="ul-left-nav fa-ul hidden-print" role="tablist"> + <ul id="leftnav" class="ul-left-nav fa-ul hidden-print"> <li class="separator"><a class="separator" href="https://www.eclipse.org/legal/eca/"> ECA </a></li> <li class="main-sidebar-item main-sidebar-item-indented"> <i class="fa fa-caret-right fa-fw" aria-hidden="true"></i> diff --git a/src/test/java/org/eclipsefoundation/git/eca/helper/CommitHelperTest.java b/src/test/java/org/eclipsefoundation/git/eca/helper/CommitHelperTest.java index 9678eda50dccfa438f8baaa4f447726dd53f66ee..a20fe1bf1a36224e2815a05620fb70dbf902e12c 100644 --- a/src/test/java/org/eclipsefoundation/git/eca/helper/CommitHelperTest.java +++ b/src/test/java/org/eclipsefoundation/git/eca/helper/CommitHelperTest.java @@ -48,7 +48,7 @@ class CommitHelperTest { // basic known good commit baseCommit = Commit .builder() - .setBody(String.format("Sample body content\n\nSigned-off-by: %s <%s>", testUser.getName(), testUser.getMail())) + .setBody(String.format("Sample body content%n%nSigned-off-by: %s <%s>", testUser.getName(), testUser.getMail())) .setHash("abc123f") .setHead(false) .setParents(new ArrayList<>()) @@ -129,7 +129,6 @@ class CommitHelperTest { // generate initial fingerprint ValidationRequest vr = ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/sample")) .setCommits(commits) @@ -138,7 +137,6 @@ class CommitHelperTest { // generate request with different repo url vr = ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/other-sample")) .setCommits(commits) @@ -166,7 +164,6 @@ class CommitHelperTest { // generate initial fingerprint ValidationRequest vr = ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/sample")) .setCommits(commits) @@ -185,7 +182,6 @@ class CommitHelperTest { // generate request with different repo url vr = ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/other-sample")) .setCommits(commits) @@ -216,7 +212,6 @@ class CommitHelperTest { commits.add(c1); return ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/sample")) .setCommits(commits) diff --git a/src/test/java/org/eclipsefoundation/git/eca/resource/ReportsResourceTest.java b/src/test/java/org/eclipsefoundation/git/eca/resource/ReportsResourceTest.java index 5ea2e7a8cb7f5428f4f9396f06c11320bd9935a6..305d0520de4153c5d39b38306cdb3d076aba2f85 100644 --- a/src/test/java/org/eclipsefoundation/git/eca/resource/ReportsResourceTest.java +++ b/src/test/java/org/eclipsefoundation/git/eca/resource/ReportsResourceTest.java @@ -79,7 +79,7 @@ class ReportsResourceTest { SchemaNamespaceHelper.ERROR_SCHEMA_PATH); /* - * GET /reports/gitlab/private-projects + * Call: Get /reports/gitlab/private-projects */ @Test void getPrivProjReport_success() { @@ -102,7 +102,7 @@ class ReportsResourceTest { } /* - * GET /reports/gitlab/private-projects?status=active + * Call: Get /reports/gitlab/private-projects?status=active */ @Test void getPrivProjReportActive_success() { @@ -148,7 +148,7 @@ class ReportsResourceTest { } /* - * GET /reports/webhooks/gitlab/system?since={date} + * Call: Get /reports/webhooks/gitlab/system?since={date} */ @Test void getPrivProjReportSince_success() { @@ -176,7 +176,7 @@ class ReportsResourceTest { } /* - * GET /reports/gitlab/private-projects?until={date} + * Call: Get /reports/gitlab/private-projects?until={date} */ @Test void getPrivProjReportUntil_success() { @@ -204,7 +204,7 @@ class ReportsResourceTest { } /* - * GET /reports/webhooks/gitlab/system?since={date}&until={date} + * Call: Get /reports/webhooks/gitlab/system?since={date}&until={date} */ @Test void getPrivProjReportRange_success() { 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 8bc5f73aba4fa061593f834338c4073085d24e63..3cbeac44ff68e542aa8842e7bd72d19e3df0425d 100644 --- a/src/test/java/org/eclipsefoundation/git/eca/resource/ValidationResourceTest.java +++ b/src/test/java/org/eclipsefoundation/git/eca/resource/ValidationResourceTest.java @@ -42,6 +42,7 @@ import org.junit.jupiter.api.Test; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import io.quarkus.logging.Log; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.security.TestSecurity; import io.quarkus.test.security.oidc.Claim; @@ -293,7 +294,7 @@ class ValidationResourceTest { .setAuthor(USER_BARSHALL) .setCommitter(USER_BARSHALL) .setBody(String - .format("Change-Id: 0000000000000001\nSigned-off-by: %s <%s>", USER_BARSHALL.getName(), USER_BARSHALL.getMail())) + .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()) @@ -312,7 +313,7 @@ class ValidationResourceTest { .setAuthor(USER_BARSHALL) .setCommitter(USER_BARSHALL) .setBody(String - .format("Signed-off-by: %s <%s>\nChange-Id: 0000000000000001", USER_BARSHALL.getName(), USER_BARSHALL.getMail())) + .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()) @@ -331,7 +332,7 @@ class ValidationResourceTest { .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(), + .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") @@ -488,14 +489,7 @@ class ValidationResourceTest { @Test void testValidate_success_noCommits() { - - // We do not block contributions to non-project repos - EndpointTestBuilder - .from(VALIDATE_SUCCESS_CASE) - .doPost(createGitHubRequest("http://www.github.com/eclipsefdn/prototype.git", Collections.emptyList())) - .run(); - - // Strictmode shouldn't affect the result + // empty commits should be a valid case though an unnecessary one EndpointTestBuilder .from(VALIDATE_SUCCESS_CASE) .doPost(createGitHubRequest("http://www.github.com/eclipsefdn/prototype.git", Collections.emptyList())) @@ -522,13 +516,8 @@ class ValidationResourceTest { .setCommits(Arrays.asList(c1)) .build(); - // We do not block contributions to non-project repos - EndpointTestBuilder.from(VALIDATE_SUCCESS_CASE).doPost(req).run(); - - req = req.toBuilder().build(); - - // Strictmode shouldn't affect the result - EndpointTestBuilder.from(VALIDATE_SUCCESS_CASE).doPost(req).run(); + // the provider is required to submit the request + EndpointTestBuilder.from(VALIDATE_FORBIDDEN_CASE).doPost(req).run(); } /* @@ -687,10 +676,7 @@ class ValidationResourceTest { String val = json.writeValueAsString(createGitHubRequest("http://www.github.com/eclipsefdn/prototype", Arrays.asList(c1))); // should pass as grunter2 is the GH handle for the user - EndpointTestBuilder - .from(VALIDATE_SUCCESS_CASE) - .doPost(val) - .run(); + EndpointTestBuilder.from(VALIDATE_SUCCESS_CASE).doPost(val).run(); } @Test diff --git a/src/test/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationServiceTest.java b/src/test/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationServiceTest.java index 6e43af89f46b85dd51464a9f680ca25cc0015a68..d51c7ee912850eea3d79cd8ae0825c9ea2bba6e7 100644 --- a/src/test/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationServiceTest.java +++ b/src/test/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationServiceTest.java @@ -65,7 +65,6 @@ class DefaultValidationServiceTest { .setEstimatedLoc(0) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/test")) - .setStrictMode(true) .build(), wrap); // should have 1 error, with a certain commit as the source diff --git a/src/test/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationStatusServiceTest.java b/src/test/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationStatusServiceTest.java index 93a09b85b63282df06528c32879db37e79841be1..a26b0f991ad7abb776c6f9261541e0d6c172c135 100644 --- a/src/test/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationStatusServiceTest.java +++ b/src/test/java/org/eclipsefoundation/git/eca/service/impl/DefaultValidationStatusServiceTest.java @@ -114,7 +114,6 @@ class DefaultValidationStatusServiceTest { commits.add(c1); ValidationRequest vr = ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/sample")) .setCommits(commits) @@ -143,7 +142,6 @@ class DefaultValidationStatusServiceTest { commits.add(c1); ValidationRequest vr = ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/test")) .setCommits(commits) @@ -182,7 +180,6 @@ class DefaultValidationStatusServiceTest { commits.add(c1); ValidationRequest vr = ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/sample")) .setCommits(commits) @@ -223,7 +220,6 @@ class DefaultValidationStatusServiceTest { commits.add(c1); return ValidationRequest .builder() - .setStrictMode(false) .setProvider(ProviderType.GITHUB) .setRepoUrl(URI.create("http://www.github.com/eclipsefdn/sample")) .setCommits(commits)