Skip to content

Commit

Permalink
GMS-177 Integration test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-szrnka committed Dec 10, 2024
1 parent 3ee486f commit 664dd3b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void toggleStatus_whenAuthenticationFails_thenReturnHttp403() {
}

@Test
@TestedMethod("validate_value_length")
@TestedMethod("validateValueLength")
void validateValueLength_whenAuthenticationFails_thenReturnHttp403() {
// arrange
SecretValueDto secretValueDto = SecretValueDto.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;
Expand Down Expand Up @@ -110,15 +112,15 @@ void list_whenInputIsValid_thenReturnOk() {
assertNotNull(response.getBody());

SecretListDto responseList = response.getBody();
assertEquals(2, responseList.getResultList().size());
assertEquals(1, responseList.getResultList().size());
}

@Test
@TestedMethod(GET_VALUE)
void getValue_whenInputIsValid_thenReturnOk() {
// act
HttpEntity<Void> requestEntity = new HttpEntity<>(TestUtils.getHttpHeaders(jwt));
ResponseEntity<String> response = executeHttpGet("/value/" + DemoData.SECRET_ENTITY2_ID,
ResponseEntity<String> response = executeHttpGet("/value/" + DemoData.SECRET_ENTITY_ID,
requestEntity, String.class);

// Assert
Expand Down Expand Up @@ -183,7 +185,12 @@ void rotateSecret_whenInputIsValid_thenReturnOk() {
@Test
void validateValueLength_whenInputProvided_thenReturnOk() {
// act
HttpEntity<Void> 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<SecretValueDto> requestEntity = new HttpEntity<>(secretValueDto, TestUtils.getHttpHeaders(jwt));
ResponseEntity<BooleanValueDto> response = executeHttpPost("/validate_value_length",
requestEntity, BooleanValueDto.class);

Expand Down

0 comments on commit 664dd3b

Please sign in to comment.