use of keywhiz.api.model.SanitizedSecret in project keywhiz by square.
the class AclDAOTest method getSecretFor.
@Test
public void getSecretFor() throws Exception {
SanitizedSecret sanitizedSecret1 = SanitizedSecret.fromSecret(secret1);
aclDAO.enrollClient(jooqContext.configuration(), client2.getId(), group1.getId());
aclDAO.enrollClient(jooqContext.configuration(), client2.getId(), group3.getId());
aclDAO.allowAccess(jooqContext.configuration(), secret1.getId(), group1.getId());
SanitizedSecret secret = aclDAO.getSanitizedSecretFor(client2, sanitizedSecret1.name()).orElseThrow(RuntimeException::new);
assertThat(secret).isEqualToIgnoringGivenFields(sanitizedSecret1, "id", "version");
aclDAO.evictClient(jooqContext.configuration(), client2.getId(), group1.getId());
Optional<SanitizedSecret> missingSecret = aclDAO.getSanitizedSecretFor(client2, sanitizedSecret1.name());
assertThat(missingSecret).isEmpty();
aclDAO.allowAccess(jooqContext.configuration(), sanitizedSecret1.id(), group3.getId());
secret = aclDAO.getSanitizedSecretFor(client2, sanitizedSecret1.name()).orElseThrow(RuntimeException::new);
assertThat(secret).isEqualToIgnoringGivenFields(sanitizedSecret1, "id", "version");
}
Aggregations