Skip to content

Commit

Permalink
fix(issues): Resolve sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
juancgalvis committed May 20, 2024
1 parent 77b8295 commit c2d53d4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

class exceptionsTest {
class ExceptionsTest {

@Test
void generateExpetion() {
void generateException() {
SecretException ex = new SecretException("My error");
assertEquals("My error", ex.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ private Mono<String> getSecretValue(String secretName) {
}
return Mono.error(new SecretException("Secret value is not a String"));
})
.doOnError((err) -> {
logger.warning("Error retrieving the secret: " + err.getMessage());
});
.doOnError(err -> logger.warning("Error retrieving the secret: " + err.getMessage()));
}

private SsmAsyncClient buildClient(SsmAsyncClientBuilder builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Mono<String> getSecret(String secretName) {
public <T> Mono<T> getSecret(String secretName, Class<T> cls) {
return this.getSecret(secretName)
.flatMap((data -> Mono.just(GsonUtils.getInstance().stringToModel(data, cls))))
.onErrorMap((e) -> new SecretException(e.getMessage()));
.onErrorMap(e -> new SecretException(e.getMessage()));
}


Expand All @@ -67,9 +67,7 @@ private Mono<String> getSecretValue(String secretName) {
}
return Mono.error(new SecretException("Secret value is not a String"));
})
.doOnError((err) -> {
logger.warning("Error retrieving the secret: " + err.getMessage());
});
.doOnError(err -> logger.warning("Error retrieving the secret: " + err.getMessage()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void shouldGetStringSecretWithEndpoint() throws SecretException {
prepareClient("secretValue", true);
connector = new AWSParameterStoreConnector("us-east-1", "http://localhost:8080");
String secretValue = connector.getSecret("secretName");
assertEquals(secretValue, "secretValue");
assertEquals("secretValue", secretValue);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void shouldConversionOk() throws SecretException {
}

@Test
void shouldConversionFail() throws Exception {
void shouldConversionFail() {
prepareClient("test", true);
connector = new AWSSecretManagerConnector("us-east-1", builder);
assertThrows(SecretException.class, () -> connector.getSecret("SecretDBFailMock", AWSSecretDBModel.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import co.com.bancolombia.secretsmanager.api.GenericManager;
import co.com.bancolombia.secretsmanager.api.exceptions.SecretException;
import lombok.Getter;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand All @@ -12,21 +13,18 @@
*
* @author <a href="mailto:andmagom@bancolombia.com.co">Andrés Mauricio Gómez P.</a>
*/
@Getter
public class FileConnector implements GenericManager {

public static final String PATH_DOCKER_LINUX = "/run/secrets/";
public static final String PATH_DOCKER_WINDOWS = "C:\\ProgramData\\Docker\\secrets";
public static final String PATH_DOCKER_LINUX = "/run/secrets/"; // NOSONAR
public static final String PATH_DOCKER_WINDOWS = "C:\\ProgramData\\Docker\\secrets"; // NOSONAR

private String path;

public FileConnector(String path) {
setPath(path);
}

public String getPath() {
return path;
}

/**
* It sets path of secrets directory.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public class VaultSecretsManagerProperties {
private CacheProperties secretsCacheProperties= CacheProperties.builder().expireAfter(600).maxSize(100).build();

@Builder.Default
private String appRoleAuthPath = "/auth/approle/login";
private String appRoleAuthPath = "/auth/approle/login"; // NOSONAR

@Builder.Default
private String k8sAuthPath = "/auth/kubernetes/login";
private String k8sAuthPath = "/auth/kubernetes/login"; // NOSONAR

public String buildUrl() {
return String.format("%s://%s:%d%s", ssl ? "https" : "http", host, port, baseApi);
Expand Down

0 comments on commit c2d53d4

Please sign in to comment.