diff --git a/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretAdminRoleSecurityTest.java b/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretAdminRoleSecurityTest.java index 8ed922a0..f1dea3c1 100644 --- a/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretAdminRoleSecurityTest.java +++ b/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretAdminRoleSecurityTest.java @@ -89,7 +89,7 @@ void toggleStatus_whenAuthenticationFails_thenReturnHttp403() { } @Test - @TestedMethod("validate_value_length") + @TestedMethod("validateValueLength") void validateValueLength_whenAuthenticationFails_thenReturnHttp403() { // arrange SecretValueDto secretValueDto = SecretValueDto.builder() diff --git a/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretControllerTest.java b/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretControllerTest.java index 309fe6f4..d57cd814 100644 --- a/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretControllerTest.java +++ b/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretControllerTest.java @@ -156,7 +156,6 @@ void validateValueLength_whenInputProvided_thenReturnOk() { assertNotNull(response.getBody()); assertTrue(response.getBody().getValue()); assertEquals(200, response.getStatusCode().value()); - assertNull(response.getBody()); verify(secretValueSizeValidatorService).validateValueLength(any()); } } \ No newline at end of file diff --git a/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretIntegrationTest.java b/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretIntegrationTest.java index 7120bdd8..04e5b336 100644 --- a/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretIntegrationTest.java +++ b/code/gms-backend/src/test/java/io/github/gms/functions/secret/SecretIntegrationTest.java @@ -9,6 +9,7 @@ import io.github.gms.functions.secret.dto.SaveSecretRequestDto; import io.github.gms.functions.secret.dto.SecretDto; import io.github.gms.functions.secret.dto.SecretListDto; +import io.github.gms.functions.secret.dto.SecretValueDto; import io.github.gms.util.DemoData; import io.github.gms.util.TestUtils; import lombok.extern.slf4j.Slf4j; @@ -27,6 +28,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.Map; import static io.github.gms.util.TestConstants.*; import static org.junit.jupiter.api.Assertions.*; @@ -110,7 +112,7 @@ void list_whenInputIsValid_thenReturnOk() { assertNotNull(response.getBody()); SecretListDto responseList = response.getBody(); - assertEquals(2, responseList.getResultList().size()); + assertEquals(1, responseList.getResultList().size()); } @Test @@ -118,7 +120,7 @@ void list_whenInputIsValid_thenReturnOk() { void getValue_whenInputIsValid_thenReturnOk() { // act HttpEntity requestEntity = new HttpEntity<>(TestUtils.getHttpHeaders(jwt)); - ResponseEntity response = executeHttpGet("/value/" + DemoData.SECRET_ENTITY2_ID, + ResponseEntity response = executeHttpGet("/value/" + DemoData.SECRET_ENTITY_ID, requestEntity, String.class); // Assert @@ -183,7 +185,12 @@ void rotateSecret_whenInputIsValid_thenReturnOk() { @Test void validateValueLength_whenInputProvided_thenReturnOk() { // act - HttpEntity requestEntity = new HttpEntity<>(TestUtils.getHttpHeaders(jwt)); + SecretValueDto secretValueDto = SecretValueDto.builder() + .keystoreId(DemoData.KEYSTORE_ID) + .keystoreAliasId(DemoData.KEYSTORE_ALIAS_ID) + .secretValues(Map.of("value", "1234567890")) + .build(); + HttpEntity requestEntity = new HttpEntity<>(secretValueDto, TestUtils.getHttpHeaders(jwt)); ResponseEntity response = executeHttpPost("/validate_value_length", requestEntity, BooleanValueDto.class);