From 778eeea009c9f9227de19ecc998d436ee9414b5a Mon Sep 17 00:00:00 2001 From: rmiccoli Date: Tue, 28 Nov 2023 15:56:32 +0100 Subject: [PATCH] Add test --- .../iam/api/account/find/FindAccountController.java | 4 ++-- .../api/account/find/FindAccountIntegrationTests.java | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/iam-login-service/src/main/java/it/infn/mw/iam/api/account/find/FindAccountController.java b/iam-login-service/src/main/java/it/infn/mw/iam/api/account/find/FindAccountController.java index cdb848181..6761e6cc7 100644 --- a/iam-login-service/src/main/java/it/infn/mw/iam/api/account/find/FindAccountController.java +++ b/iam-login-service/src/main/java/it/infn/mw/iam/api/account/find/FindAccountController.java @@ -44,7 +44,7 @@ public class FindAccountController { public static final String FIND_BY_LABEL_RESOURCE = "/iam/account/find/bylabel"; public static final String FIND_BY_EMAIL_RESOURCE = "/iam/account/find/byemail"; public static final String FIND_BY_USERNAME_RESOURCE = "/iam/account/find/byusername"; - public static final String FIND_BY_CERT_SUBJECT_RESOURCE = "/iam/account/find/bycertsubjectandissuer"; + public static final String FIND_BY_CERT_SUBJECT_AND_ISSUER_RESOURCE = "/iam/account/find/bycertsubjectandissuer"; public static final String FIND_BY_GROUP_RESOURCE = "/iam/account/find/bygroup/{groupUuid}"; public static final String FIND_NOT_IN_GROUP_RESOURCE = "/iam/account/find/notingroup/{groupUuid}"; @@ -78,7 +78,7 @@ public ListResponseDTO findByUsername(@RequestParam(required = true) S return service.findAccountByUsername(username); } - @RequestMapping(method = GET, value = FIND_BY_CERT_SUBJECT_RESOURCE, + @RequestMapping(method = GET, value = FIND_BY_CERT_SUBJECT_AND_ISSUER_RESOURCE, produces = ScimConstants.SCIM_CONTENT_TYPE) public ListResponseDTO findByCertSubject( @RequestParam(required = true) String certificateSubject, @RequestParam(required = true) String certificateIssuer) { diff --git a/iam-login-service/src/test/java/it/infn/mw/iam/test/api/account/find/FindAccountIntegrationTests.java b/iam-login-service/src/test/java/it/infn/mw/iam/test/api/account/find/FindAccountIntegrationTests.java index f2c2982c1..99b734c5a 100644 --- a/iam-login-service/src/test/java/it/infn/mw/iam/test/api/account/find/FindAccountIntegrationTests.java +++ b/iam-login-service/src/test/java/it/infn/mw/iam/test/api/account/find/FindAccountIntegrationTests.java @@ -15,6 +15,7 @@ */ package it.infn.mw.iam.test.api.account.find; +import static it.infn.mw.iam.api.account.find.FindAccountController.FIND_BY_CERT_SUBJECT_AND_ISSUER_RESOURCE; import static it.infn.mw.iam.api.account.find.FindAccountController.FIND_BY_EMAIL_RESOURCE; import static it.infn.mw.iam.api.account.find.FindAccountController.FIND_BY_GROUP_RESOURCE; import static it.infn.mw.iam.api.account.find.FindAccountController.FIND_BY_LABEL_RESOURCE; @@ -290,4 +291,14 @@ public void findNotInGroupWorks() throws Exception { .andExpect(jsonPath("$.Resources[1].id", is("bffc67b7-47fe-410c-a6a0-cf00173a8fbb"))); } + @Test + public void findByCertificateSubjectAndIssuerWorks() throws Exception { + + mvc.perform(get(FIND_BY_CERT_SUBJECT_AND_ISSUER_RESOURCE).param("certificateSubject", "CN=test2,O=IGI,C=IT").param("certificateIssuer", "CN=Test CA,O=IGI,C=IT")) + .andExpect(OK) + .andExpect(jsonPath("$.totalResults", is(1))) + .andExpect(jsonPath("$.Resources[0].userName", is("admin"))); + + } + }