Skip to content

Commit

Permalink
GCP Storage - Fix for Invalid protocol (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsloan authored Jun 19, 2024
1 parent 48f0b66 commit c66974b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Either<ConfigException, ConfigWrapperSource> fromConfigDef(ConfigD

@Override
public Optional<String> getString(String key) {
return Optional.ofNullable(abstractConfig.getString(key));
return Optional.ofNullable(abstractConfig.getString(key)).filter(s -> !s.isEmpty());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MapConfigSource implements ConfigSource {

@Override
public Optional<String> getString(String key) {
return Optional.ofNullable((String) wrapped.get(key));
return Optional.ofNullable((String) wrapped.get(key)).filter(s -> !s.isEmpty());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ abstract class ConfigSourceTestBase {
protected static final Password PASSWORD_VALUE = new Password("secret");
protected static final String USERNAME_KEY = "username";
protected static final String USERNAME_VALUE = "user123";
protected static final String NULL_KEY = "valueNull";
protected static final String NULL_VALUE = null;
private ConfigSource configSource;

@BeforeEach
Expand Down Expand Up @@ -69,4 +71,11 @@ void testGetPassword_nonExistingKey_shouldReturnEmpty() {

assertFalse(password.isPresent());
}

@Test
void testGetString_nonExistingValue_shouldReturnEmpty() {
Optional<String> password = configSource.getString(NULL_KEY);

assertFalse(password.isPresent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ConfigSource createConfigSource() {
AbstractConfig config = mock(AbstractConfig.class);
when(config.getString(USERNAME_KEY)).thenReturn(USERNAME_VALUE);
when(config.getPassword(PASSWORD_KEY)).thenReturn(PASSWORD_VALUE);
when(config.getString(NULL_KEY)).thenReturn(NULL_VALUE);

return new ConfigWrapperSource(config);
}
Expand Down

0 comments on commit c66974b

Please sign in to comment.