Skip to content
Snippets Groups Projects
Commit ceda5a74 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Merge branch 'zacharysabourin/master/72' into 'master'

feat: Add endpoint to check user ECA status via email

See merge request !92
parents a1a2d15b f31ce0b4
No related branches found
No related tags found
1 merge request!92feat: Add endpoint to check user ECA status via email
Pipeline #6861 passed
......@@ -13,6 +13,7 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
......@@ -43,6 +44,7 @@ import org.eclipsefoundation.git.eca.namespace.ProviderType;
import org.eclipsefoundation.git.eca.service.ProjectsService;
import org.eclipsefoundation.git.eca.service.UserService;
import org.eclipsefoundation.git.eca.service.ValidationService;
import org.jboss.resteasy.annotations.jaxrs.QueryParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -54,7 +56,7 @@ import io.quarkus.qute.Template;
* commits passed to this endpoint. Should be as system agnostic as possible to allow for any service to request
* validation with less reliance on services external to the Eclipse foundation.
*
* @author Martin Lowe
* @author Martin Lowe, Zachary Sabourin
*/
@Path("/eca")
@Consumes({ MediaType.APPLICATION_JSON })
......@@ -159,6 +161,23 @@ public class ValidationResource {
membershipTemplateWeb.data("statuses", statuses, "repoUrl", statuses.get(0).getRepoUrl()).render())
.build();
}
@GET
@Path("/lookup")
public Response getUserStatus(@QueryParam("email") String email) {
EclipseUser user = users.getUser(email);
if (Objects.isNull(user)) {
return Response.status(404).build();
}
if(!user.getECA().getSigned()) {
return Response.status(403).build();
}
return Response.ok().build();
}
/**
* Check if there are any issues with the validation request, returning error messages if there are issues with the
......
......@@ -49,6 +49,7 @@ import io.restassured.http.ContentType;
@QuarkusTest
class ValidationResourceTest {
public static final String ECA_BASE_URL = "/eca";
public static final String LOOKUP_URL = ECA_BASE_URL + "/lookup";
@Inject
CachingService cs;
......@@ -983,4 +984,34 @@ class ValidationResourceTest {
is(true), "errorCount", is(0), "commits." + c1.getHash() + ".messages[0].code",
not(APIStatusCode.SUCCESS_SKIPPED.getValue()));
}
/*
*
* USER LOOKUP TESTS
*
*/
@Test
void validateUserLookup_userNotFound() {
String userEmail = "dummy@fake.co";
// User should not exist - status 404
given().contentType(ContentType.JSON).when().get(LOOKUP_URL + "?email=" + userEmail).then().statusCode(404);
}
@Test
void validateUserLookup_userNoECA() {
String userEmail = "newbie@important.co";
// User exists but no ECA - status 403
given().contentType(ContentType.JSON).when().get(LOOKUP_URL + "?email=" + userEmail).then().statusCode(403);
}
@Test
void validateUserLookup_userSuccess() {
String userEmail = "slom@eclipse-foundation.org";
// User exists with ECA - status 200
given().contentType(ContentType.JSON).when().get(LOOKUP_URL + "?email=" + userEmail).then().statusCode(200);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment