fix API endpoint for token lookup

This commit is contained in:
Stefan Kalscheuer 2019-10-16 17:49:49 +02:00
parent d51421cb14
commit 596a097707
3 changed files with 38 additions and 2 deletions

View File

@ -1,5 +1,8 @@
## unreleased ## unreleased
### Fixes
* Fixed token lookup (#31)
### Improvements ### Improvements
* Updated dependencies * Updated dependencies

View File

@ -696,7 +696,9 @@ public class HTTPVaultConnector implements VaultConnector {
requireAuth(); requireAuth();
/* Request HTTP response and parse Secret */ /* Request HTTP response and parse Secret */
return request.get(PATH_TOKEN + "/lookup/" + token, new HashMap<>(), token, TokenResponse.class); Map<String, String> param = new HashMap<>();
param.put("token", token);
return request.get(PATH_TOKEN + PATH_LOOKUP, param, token, TokenResponse.class);
} }
/** /**

View File

@ -1026,7 +1026,7 @@ public class HTTPVaultConnectorTest {
} }
/** /**
* Test revocation of secrets. * Test token creation.
*/ */
@Test @Test
@Order(20) @Order(20)
@ -1101,6 +1101,37 @@ public class HTTPVaultConnectorTest {
assertThat(stackTrace(e), not(stringContainsInOrder(token.getId()))); assertThat(stackTrace(e), not(stringContainsInOrder(token.getId())));
} }
} }
/**
* Test token lookuo.
*/
@Test
@Order(30)
@DisplayName("Lookup token")
public void lookupTokenTest() {
authRoot();
assumeTrue(connector.isAuthorized());
/* Create token with attributes */
Token token = Token.builder()
.withId("my-token")
.build();
try {
connector.createToken(token);
} catch (VaultConnectorException e) {
fail("Token creation failed.");
}
authRoot();
assumeTrue(connector.isAuthorized());
try {
TokenResponse res = connector.lookupToken("my-token");
assertThat("Unexpected token ID", res.getData().getId(), is(token.getId()));
} catch (VaultConnectorException e) {
fail("Token creation failed.");
}
}
} }
@Nested @Nested