Refactored extraction of auth backends

Changed iteration over keys ot iteration over entries.
Implemented unit test as part of this process.
This commit is contained in:
2017-08-19 12:16:57 +02:00
parent b1c78b50d2
commit 5b34cfcc27
4 changed files with 119 additions and 4 deletions

View File

@ -27,6 +27,7 @@ public enum AuthBackend {
APPID("app-id"),
APPROLE("approle"),
USERPASS("userpass"),
GITHUB("github"), // Not supported yet.
UNKNOWN("");
private final String type;

View File

@ -45,11 +45,10 @@ public final class AuthMethodsResponse extends VaultDataResponse {
@Override
public void setData(final Map<String, Object> data) throws InvalidResponseException {
ObjectMapper mapper = new ObjectMapper();
for (String path : data.keySet()) {
for (Map.Entry<String, Object> entry : data.entrySet()) {
try {
this.supportedMethods.put(
path, mapper.readValue(mapper.writeValueAsString(data.get(path)),
AuthMethod.class));
this.supportedMethods.put(entry.getKey(),
mapper.readValue(mapper.writeValueAsString(entry.getValue()), AuthMethod.class));
} catch (IOException e) {
throw new InvalidResponseException();
}