diff --git a/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/identityminustrust/TokenRequestTest.java b/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/identityminustrust/TokenRequestTest.java index 6c481935..ff88fada 100644 --- a/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/identityminustrust/TokenRequestTest.java +++ b/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/identityminustrust/TokenRequestTest.java @@ -55,7 +55,7 @@ @DirtiesContext @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = { ManagedIdentityWalletsApplication.class }) @ContextConfiguration(initializers = { TestContextInitializer.class }) -public class TokenRequestTest { +class TokenRequestTest { private static final ObjectMapper MAPPER = new ObjectMapper(); @@ -125,7 +125,7 @@ public void initWallets() { @Test @SneakyThrows - public void testPresentationQueryWithToken() { + void testPresentationQueryWithToken() { // when String body = "audience=%s&client_id=%s&client_secret=%s&grant_type=client_credentials&bearer_access_scope=org.eclipse.tractusx.vc.type:MembershipCredential:read"; String requestBody = String.format(body, bpn, clientId, clientSecret); diff --git a/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java b/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java index 0ca47e62..1f3953f9 100644 --- a/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java +++ b/miw/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/TestUtils.java @@ -98,8 +98,7 @@ public static ResponseEntity createWallet(String bpn, String name, TestR HttpEntity entity = new HttpEntity<>(request, headers); - ResponseEntity exchange = testTemplate.exchange(RestURI.WALLETS, HttpMethod.POST, entity, String.class); - return exchange; + return testTemplate.exchange(RestURI.WALLETS, HttpMethod.POST, entity, String.class); } diff --git a/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/RevocationService.java b/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/RevocationService.java index e6033e8a..4dff1776 100644 --- a/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/RevocationService.java +++ b/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/RevocationService.java @@ -363,7 +363,7 @@ public String extractBpnFromURL(String url) { if (matcher.find()) { return matcher.group(1).toUpperCase(); } else { - throw new Exception("No match found"); + throw new IllegalArgumentException("No match found"); } } diff --git a/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/validation/VerifiableCredentialValidator.java b/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/validation/VerifiableCredentialValidator.java index 00947e53..d049f11f 100644 --- a/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/validation/VerifiableCredentialValidator.java +++ b/revocation-service/src/main/java/org/eclipse/tractusx/managedidentitywallets/revocation/validation/VerifiableCredentialValidator.java @@ -59,7 +59,7 @@ private boolean validateCredentialSubject( for (Map subject : credentialSubjects) { // Extract the 'id' of the credential subject if it exists Object subjectId = subject.get("id"); - if (subjectId == null || !(subjectId instanceof String)) { + if (!(subjectId instanceof String)) { addConstraintViolation(context, "credentialSubject.id must be a valid String"); return false; } diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/MIWSettingsTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/MIWSettingsTest.java index c04163e8..4ee8efe2 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/MIWSettingsTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/MIWSettingsTest.java @@ -50,6 +50,7 @@ void testMIWSettingsWithNullVCContexts() { @Test void testMIWSettingsWithEmptyVCContexts() { - assertThrows(IllegalArgumentException.class, () -> new MIWSettings(List.of())); + List list = List.of(); + assertThrows(IllegalArgumentException.class, () -> new MIWSettings(list)); } } diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/security/CustomAuthenticationConverterTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/security/CustomAuthenticationConverterTest.java index a918b0fe..b5b050c6 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/security/CustomAuthenticationConverterTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/config/security/CustomAuthenticationConverterTest.java @@ -36,19 +36,6 @@ class CustomAuthenticationConverterTest { - private static final String VALID = - "eyJhbGciOiJSUzI1NiIsImFscGhhIjoiZzB1ZjNycjlycnN2cHlhcTVuamg4In0.eyJpc3MiOiJEaW5vQ2hpZXNhLmdpdGh1Yi5pbyIsInN1YiI6Im1heGluZSIsImF1ZCI6ImlkcmlzIiwiaWF0IjoxNzAyNjUwMTc2LCJleHAiOjE3MDI2NTA3NzYsInJlc291cmNlX2FjY2VzcyI6eyJyZXNvdXJjZUlkIjp7InJvbGVzIjpbImRlaV9tdWRhIl19fX0.wTv9GBX3AuRO8UIsAuu2YJU77ai-wchDyxRn-_yX9PeHt23vCmp_JAbkkdMdyLAWWOKncjgNeG-4lB9RCBsjmbdb1imujUrAocp3VZQqNg6OVaNV58kdsIpNNF9S8XlFI4hr1BANrw2rWJDkTRu1id-Fu-BVE1BF7ySCKHS_NaY3e7yXQM-jtU63z5FBpPvfMF-La3blPle93rgut7V3LlG-tNOp93TgFzGrQQXuJUsew34T0u4OlQa3TjQuMdZMTy0SVSLSpIzAqDsAkHv34W6SdY1p6FVQ14TfawRLkrI2QY-YM_dCFAEE7KqqnUrVVyw6XG1ydeFDuX8SJuQX7g"; - - private static final String MISSING_RESOURCE_ID = - "{\n" + " \"resource_access\": {\n" + " }\n" + "}"; - - private static final String MISSING_ROLES = - "{\n" - + " \"resource_access\": {\n" - + " \"resourceId\": {\n" - + " }\n" - + " }\n" - + "}"; @Test void shouldConvertSuccessfullyWithAuthorities() { @@ -92,7 +79,6 @@ void shouldConvertSuccessfullyWithoutAuthoritiesWhenRolesMissing() { @Test void shouldConvertSuccessfullyWithoutAuthoritiesWhenResourceAccessMissing() { - Map resourceId = Map.of("resourceId", Map.of()); Map resourceAccess = Map.of("resource_access", Map.of()); Jwt jwt = diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/controllers/RevocationApiControllerTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/controllers/RevocationApiControllerTest.java index ff11b541..6f0379f4 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/controllers/RevocationApiControllerTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/controllers/RevocationApiControllerTest.java @@ -27,6 +27,7 @@ import org.eclipse.tractusx.managedidentitywallets.revocation.constant.RevocationApiEndpoints; import org.eclipse.tractusx.managedidentitywallets.revocation.dto.CredentialStatusDto; import org.eclipse.tractusx.managedidentitywallets.revocation.dto.StatusEntryDto; +import org.eclipse.tractusx.managedidentitywallets.revocation.dto.StatusListCredentialSubject; import org.eclipse.tractusx.managedidentitywallets.revocation.services.RevocationService; import org.eclipse.tractusx.managedidentitywallets.revocation.utils.BitSetManager; import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredential; @@ -99,13 +100,12 @@ void whenPostCreateStatusListVC_thenReturnStatus() throws Exception { RevocationPurpose.REVOCATION.name(), validIndex, // this value is within the range [0, BitSetManager.BITSET_SIZE - 1] "https://example.com/revocations/credentials/" + BPN + "/revocation/1", - "BitstringStatusListEntry"); + StatusListCredentialSubject.TYPE_ENTRY); given(revocationService.createStatusList(statusEntryDto, "token")) .willReturn(credentialStatusDto); when(revocationService.extractBpnFromDid(DID)).thenReturn(BPN); Principal mockPrincipal = mockPrincipal(BPN); - var name = mockPrincipal.getName(); // When & Then mockMvc .perform( @@ -142,7 +142,7 @@ void whenPostRevokeCredential_thenReturnOkStatus() throws Exception { "revocation", validIndex, // this value is within the range [0, BitSetManager.BITSET_SIZE - 1] "http://example.com/credentials/" + BPN + "/revocation/1", - "BitstringStatusListEntry"); + StatusListCredentialSubject.TYPE_ENTRY); doNothing().when(revocationService).revoke(credentialStatusDto, "token"); when(revocationService.extractBpnFromURL(any())).thenReturn(BPN); @@ -201,23 +201,4 @@ private VerifiableCredential createVerifiableCredentialTestData() { VerifiableCredential credential = new VerifiableCredential(credentialData); return credential; } - - private VerifiableCredential createVerifiableCredentialTestDataInvalidDID() { - Map credentialData = new HashMap<>(); - credentialData.put("id", UUID.randomUUID().toString()); - credentialData.put("issuer", "https://issuer.example.com"); - credentialData.put("issuanceDate", Instant.now().toString()); - // Include 'type' field as a list because VerifiableCredential expects it to be non-null and a - // list - credentialData.put("type", List.of("VerifiableCredential", "StatusListCredential")); - Map subjectData = new HashMap<>(); - subjectData.put("id", "subjectId"); - subjectData.put("type", "StatusList2021Credential"); - // 'credentialSubject' can be either a List or a single Map according to the code, so I'm - // keeping it as a single Map - credentialData.put("credentialSubject", subjectData); - credentialData.put("@context", VerifiableCredential.DEFAULT_CONTEXT.toString()); - VerifiableCredential credential = new VerifiableCredential(credentialData); - return credential; - } } diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/CredentialStatusDtoTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/CredentialStatusDtoTest.java index 43235a50..83e966ff 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/CredentialStatusDtoTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/CredentialStatusDtoTest.java @@ -50,7 +50,7 @@ void validCredentialStatusDto_CreatesSuccessfully() { "revocation", validIndex, // this value is within the range [0, BitSetManager.BITSET_SIZE - 1] "statusListCredential", - "BitstringStatusListEntry"); + StatusListCredentialSubject.TYPE_ENTRY); // Assert assertNotNull(dto); @@ -58,7 +58,7 @@ void validCredentialStatusDto_CreatesSuccessfully() { assertEquals("revocation", dto.statusPurpose()); assertEquals(validIndex, dto.statusListIndex()); assertEquals("statusListCredential", dto.statusListCredential()); - assertEquals("BitstringStatusListEntry", dto.type()); + assertEquals(StatusListCredentialSubject.TYPE_ENTRY, dto.type()); } @ParameterizedTest @@ -89,7 +89,7 @@ void anyParameterIsBlank_ThrowsValidationException() { "revocation", "0", "statusListCredential", - "BitstringStatusListEntry")) + StatusListCredentialSubject.TYPE_ENTRY)) .isEmpty()); assertFalse( @@ -100,7 +100,7 @@ void anyParameterIsBlank_ThrowsValidationException() { "revocation", "0", "", // statusListCredential is blank - "BitstringStatusListEntry")) + StatusListCredentialSubject.TYPE_ENTRY)) .isEmpty()); } @@ -113,7 +113,7 @@ void invalidStatusPurpose_ThrowsIllegalArgumentException() { IllegalArgumentException.class, () -> { new CredentialStatusDto( - "id", invalidPurpose, "0", "statusListCredential", "BitstringStatusListEntry"); + "id", invalidPurpose, "0", "statusListCredential", StatusListCredentialSubject.TYPE_ENTRY); }); } @@ -137,14 +137,14 @@ void validStatusPurpose_DoesNotThrowException() { assertDoesNotThrow( () -> { new CredentialStatusDto( - "id", validPurpose, "0", "statusListCredential", "BitstringStatusListEntry"); + "id", validPurpose, "0", "statusListCredential", StatusListCredentialSubject.TYPE_ENTRY); }); } @Test @DisplayName("type is valid") void validType_DoesNotThrowException() { - String validType = "BitstringStatusListEntry"; + String validType = StatusListCredentialSubject.TYPE_ENTRY; assertDoesNotThrow( () -> { diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/StatusListCredentialSubjectTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/StatusListCredentialSubjectTest.java index 246c8473..f720cf9b 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/StatusListCredentialSubjectTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/StatusListCredentialSubjectTest.java @@ -55,8 +55,8 @@ void builderCreatesObjectWithCorrectValues() { @Test void defaultConstantsAreCorrect() { // Assert - assertEquals("BitstringStatusListEntry", StatusListCredentialSubject.TYPE_ENTRY); - assertEquals("BitstringStatusList", StatusListCredentialSubject.TYPE_LIST); + assertEquals("StatusList2021Entry", StatusListCredentialSubject.TYPE_ENTRY); + assertEquals("StatusList2021Credential", StatusListCredentialSubject.TYPE_LIST); assertEquals("id", StatusListCredentialSubject.SUBJECT_ID); assertEquals("type", StatusListCredentialSubject.SUBJECT_TYPE); assertEquals("statusPurpose", StatusListCredentialSubject.SUBJECT_STATUS_PURPOSE); diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/TokenResponeTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/TokenResponeTest.java index 6b040616..4e686960 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/TokenResponeTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/dto/TokenResponeTest.java @@ -26,7 +26,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; -public class TokenResponeTest { +class TokenResponseTest { @Test void getAndSetAccessToken() { // Arrange @@ -38,7 +38,7 @@ void getAndSetAccessToken() { // Assert String actualToken = tokenResponse.getAccessToken(); - assertEquals(expectedToken, actualToken, "someAccessToken123"); + assertEquals(expectedToken, "someAccessToken123", actualToken); } @Test @@ -65,6 +65,6 @@ void setAccessTokenWithEmptyString() { // Assert String actualToken = tokenResponse.getAccessToken(); - assertEquals(expectedToken, actualToken, ""); + assertEquals(expectedToken, "", actualToken); } } diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/HttpClientServiceTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/HttpClientServiceTest.java index 6f530935..31d929f9 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/HttpClientServiceTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/HttpClientServiceTest.java @@ -26,7 +26,6 @@ import org.eclipse.tractusx.managedidentitywallets.revocation.dto.TokenResponse; import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredential; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; @@ -91,10 +90,6 @@ public static void beforeAll() { ReflectionTestUtils.setField(httpClientService, "miwUrl", wm1.baseUrl()); } - @BeforeEach - void setUp() { - } - @Test void testGetBearerToken_Success() { String expectedToken = "mockToken"; @@ -131,7 +126,7 @@ void testSignStatusListVC_Success() { tokenResponse.setAccessToken("123456"); wm1.stubFor(post("/token").willReturn(jsonResponse(tokenResponse, 200))); wm1.stubFor( - post("/api/credentials?isRevocable=false") + post("/api/credentials?revocable=false") .willReturn(jsonResponse(statusListCredential.getCredential(), 200))); VerifiableCredential signedCredential = assertDoesNotThrow( diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/RevocationServiceTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/RevocationServiceTest.java index 728ec0d2..6c97acc7 100644 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/RevocationServiceTest.java +++ b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/RevocationServiceTest.java @@ -21,7 +21,6 @@ package org.eclipse.tractusx.managedidentitywallets.revocation.services; -import com.fasterxml.jackson.core.JsonProcessingException; import lombok.SneakyThrows; import org.eclipse.tractusx.managedidentitywallets.commons.constant.CredentialStatus; import org.eclipse.tractusx.managedidentitywallets.commons.constant.StringPool; @@ -40,7 +39,6 @@ import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredential; import org.eclipse.tractusx.ssi.lib.model.verifiable.credential.VerifiableCredentialSubject; import org.eclipse.tractusx.ssi.lib.proof.LinkedDataProofValidation; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -76,7 +74,6 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.times; import static org.mockito.Mockito.when; @@ -142,7 +139,7 @@ void shouldVerifyStatusActive() { "http://this-is-my-domain/api/v1/revocations/credentials/" + TestUtil.extractBpnFromDid(issuer) + "/revocation/1"); - when(credentialStatusDto.type()).thenReturn("BitstringStatusListEntry"); + when(credentialStatusDto.type()).thenReturn("StatusList2021Entry"); try (MockedStatic utils = Mockito.mockStatic(LinkedDataProofValidation.class)) { @@ -152,7 +149,7 @@ void shouldVerifyStatusActive() { }).thenReturn(mock); Mockito.when(mock.verify(Mockito.any(VerifiableCredential.class))).thenReturn(true); Map status = revocationService.verifyStatus(credentialStatusDto); - Assertions.assertTrue(status.get(StringPool.STATUS).equals(CredentialStatus.ACTIVE.getName())); + assertEquals(status.get(StringPool.STATUS), CredentialStatus.ACTIVE.getName()); } } @@ -188,7 +185,7 @@ void shouldVerifyStatusRevoke() { "http://this-is-my-domain/api/v1/revocations/credentials/" + TestUtil.extractBpnFromDid(issuer) + "/revocation/1"); - when(credentialStatusDto.type()).thenReturn("BitstringStatusListEntry"); + when(credentialStatusDto.type()).thenReturn("StatusList2021Entry"); try (MockedStatic utils = Mockito.mockStatic(LinkedDataProofValidation.class)) { LinkedDataProofValidation mock = Mockito.mock(LinkedDataProofValidation.class); utils.when(() -> { @@ -197,7 +194,7 @@ void shouldVerifyStatusRevoke() { Mockito.when(mock.verify(Mockito.any(VerifiableCredential.class))).thenReturn(true); Map status = revocationService.verifyStatus(credentialStatusDto); - Assertions.assertTrue(status.get(StringPool.STATUS).equals(CredentialStatus.REVOKED.getName())); + assertEquals(status.get(StringPool.STATUS), CredentialStatus.REVOKED.getName()); } } } @@ -230,10 +227,10 @@ void shouldRevokeCredential() { "http://this-is-my-domain/api/v1/revocations/credentials/" + TestUtil.extractBpnFromDid(issuer) + "/revocation/1"); - when(credentialStatusDto.type()).thenReturn("BitstringStatusListEntry"); + when(credentialStatusDto.type()).thenReturn("StatusList2021Entry"); assertDoesNotThrow(() -> revocationService.revoke(credentialStatusDto, "token")); Mockito.verify(statusListCredentialRepository, Mockito.times(1)) - .saveAndFlush(eq(statusListCredential)); + .saveAndFlush(statusListCredential); ArgumentCaptor captor = ArgumentCaptor.forClass(VerifiableCredential.class); Mockito.verify(httpClientService) @@ -274,7 +271,7 @@ void shouldThrowRevocationServiceException() { "http://this-is-my-domain/api/v1/revocations/credentials/" + TestUtil.extractBpnFromDid(issuer) + "/revocation/1"); - when(credentialStatusDto.type()).thenReturn("BitstringStatusListEntry"); + when(credentialStatusDto.type()).thenReturn("StatusList2021Entry"); try (MockedStatic utilities = Mockito.mockStatic(BitSetManager.class)) { utilities .when(() -> BitSetManager.revokeCredential(any(String.class), any(Integer.class))) @@ -370,7 +367,7 @@ void shouldCreateNewStatusListWhenFirstFull() { class GetStatusListCredential { @Test - void shouldGetList() throws JsonProcessingException { + void shouldGetList() { final var issuer = DID; var fragment = UUID.randomUUID().toString(); var encodedList = mockEmptyEncodedList(); @@ -403,39 +400,39 @@ void shouldReturnNull() { class CheckSubStringExtraction { @Test void shouldExtractBpnFromDid() { - assertEquals(revocationService.extractBpnFromDid(DID), BPN); + assertEquals(BPN, revocationService.extractBpnFromDid(DID)); } @Test void shouldExtractIdFromURL() { assertEquals( + "BPNL123456789000-revocation#1", revocationService.extractIdFromURL( - "http://this-is-my-domain/api/v1/revocations/credentials/BPNL123456789000/revocation/1"), - "BPNL123456789000-revocation#1"); + "http://this-is-my-domain/api/v1/revocations/credentials/BPNL123456789000/revocation/1")); } @Test void shouldExtractIdFromURLCaseSensitive() { assertEquals( + "BPNL123456789000-revocation#1", revocationService.extractIdFromURL( - "http://this-is-my-domain/api/v1/revocations/credentials/bpnl123456789000/revocation/1"), - "BPNL123456789000-revocation#1"); + "http://this-is-my-domain/api/v1/revocations/credentials/bpnl123456789000/revocation/1")); } @Test void shouldExtractBpnFromURL() { assertEquals( + BPN, revocationService.extractBpnFromURL( - "http://this-is-my-domain/api/v1/revocations/credentials/BPNL123456789000/revocation/1"), - BPN); + "http://this-is-my-domain/api/v1/revocations/credentials/BPNL123456789000/revocation/1")); } @Test void shouldExtractBpnFromURLCaseSensitive() { assertEquals( + BPN, revocationService.extractBpnFromURL( - "http://this-is-my-domain/api/v1/revocations/creDENTials/bpNl123456789000/revocation/1"), - BPN); + "http://this-is-my-domain/api/v1/revocations/creDENTials/bpNl123456789000/revocation/1")); } } @@ -452,7 +449,7 @@ void validCredentialStatusDto() { CredentialStatusDto dto = new CredentialStatusDto( - id, "revocation", statusIndex, statusListCredential, "BitstringStatusListEntry"); + id, "revocation", statusIndex, statusListCredential, "StatusList2021Entry"); assertDoesNotThrow(() -> revocationService.validateCredentialStatus(dto)); } @@ -468,7 +465,7 @@ void invalidStatusPurpose_ThrowsIllegalArgumentException() { CredentialStatusDto dto = new CredentialStatusDto( - id, "revocation", statusIndex, statusListCredential, "BitstringStatusListEntry"); + id, "revocation", statusIndex, statusListCredential, "StatusList2021Entry"); assertThrows( IllegalArgumentException.class, () -> revocationService.validateCredentialStatus(dto)); } @@ -483,7 +480,7 @@ void invalidId_ThrowsIllegalArgumentException() { CredentialStatusDto dto = new CredentialStatusDto( - id, "revocation", statusIndex, statusListCredential, "BitstringStatusListEntry"); + id, "revocation", statusIndex, statusListCredential, "StatusList2021Entry"); assertThrows( IllegalArgumentException.class, () -> revocationService.validateCredentialStatus(dto)); } @@ -498,7 +495,7 @@ void invalidStatusIndex_ThrowsIllegalArgumentException() { CredentialStatusDto dto = new CredentialStatusDto( - id, "revocation", statusIndex, statusListCredential, "BitstringStatusListEntry"); + id, "revocation", statusIndex, statusListCredential, "StatusList2021Entry"); assertThrows( IllegalArgumentException.class, () -> revocationService.validateCredentialStatus(dto)); } diff --git a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/StatusVerificationTest.java b/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/StatusVerificationTest.java deleted file mode 100644 index 80a83706..00000000 --- a/revocation-service/src/test/java/org/eclipse/tractusx/managedidentitywallets/revocation/services/StatusVerificationTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * ******************************************************************************* - * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ****************************************************************************** - */ - -package org.eclipse.tractusx.managedidentitywallets.revocation.services; - -import org.junit.jupiter.api.Test; - -public class StatusVerificationTest { - - - @Test - void testVerification() { - - } -} diff --git a/wallet-commons/src/test/java/org/eclipse/tractusx/managedidentitywallets/commons/ValidateTest.java b/wallet-commons/src/test/java/org/eclipse/tractusx/managedidentitywallets/commons/ValidateTest.java index 4a65cb34..f8e70467 100644 --- a/wallet-commons/src/test/java/org/eclipse/tractusx/managedidentitywallets/commons/ValidateTest.java +++ b/wallet-commons/src/test/java/org/eclipse/tractusx/managedidentitywallets/commons/ValidateTest.java @@ -30,25 +30,26 @@ class ValidateTest { @Test void validateTest() { - Assertions.assertThrows(RuntimeException.class, () -> Validate.isFalse(false).launch(new RuntimeException())); + RuntimeException runtimeException = new RuntimeException(); + Assertions.assertThrows(RuntimeException.class, () -> Validate.isFalse(false).launch(runtimeException)); - Assertions.assertThrows(RuntimeException.class, () -> Validate.isTrue(true).launch(new RuntimeException())); + Assertions.assertThrows(RuntimeException.class, () -> Validate.isTrue(true).launch(runtimeException)); - Assertions.assertThrows(RuntimeException.class, () -> Validate.isNull(null).launch(new RuntimeException())); + Assertions.assertThrows(RuntimeException.class, () -> Validate.isNull(null).launch(runtimeException)); - Assertions.assertThrows(RuntimeException.class, () -> Validate.isNotNull("Test").launch(new RuntimeException())); + Assertions.assertThrows(RuntimeException.class, () -> Validate.isNotNull("Test").launch(runtimeException)); - Assertions.assertThrows(RuntimeException.class, () -> Validate.value("").isNotEmpty().launch(new RuntimeException())); + Assertions.assertThrows(RuntimeException.class, () -> Validate.value("").isNotEmpty().launch(runtimeException)); - Assertions.assertDoesNotThrow(() -> Validate.isFalse(true).launch(new RuntimeException())); + Assertions.assertDoesNotThrow(() -> Validate.isFalse(true).launch(runtimeException)); - Assertions.assertDoesNotThrow(() -> Validate.isTrue(false).launch(new RuntimeException())); + Assertions.assertDoesNotThrow(() -> Validate.isTrue(false).launch(runtimeException)); - Assertions.assertDoesNotThrow(() -> Validate.isNull("").launch(new RuntimeException())); + Assertions.assertDoesNotThrow(() -> Validate.isNull("").launch(runtimeException)); - Assertions.assertDoesNotThrow(() -> Validate.isNotNull(null).launch(new RuntimeException())); + Assertions.assertDoesNotThrow(() -> Validate.isNotNull(null).launch(runtimeException)); - Assertions.assertDoesNotThrow(() -> Validate.value("Test").isNotEmpty().launch(new RuntimeException())); + Assertions.assertDoesNotThrow(() -> Validate.value("Test").isNotEmpty().launch(runtimeException)); } }