use of com.github.nagyesta.lowkeyvault.http.management.VaultModel in project lowkey-vault by nagyesta.
the class ManagementStepDefs method deletedVaultListContainsVaultNameWithDeletedOnPopulated.
@And("deleted vault list contains {name} with deletedOn populated")
public void deletedVaultListContainsVaultNameWithDeletedOnPopulated(final String vaultName) {
final List<VaultModel> models = context.getClient().listDeletedVaults();
final Optional<VaultModel> found = models.stream().filter(v -> v.getBaseUri().getHost().startsWith(vaultName)).findAny();
assertTrue(found.isPresent());
// noinspection OptionalGetWithoutIsPresent
final OffsetDateTime deletedOn = found.get().getDeletedOn();
assertNotNull(deletedOn);
assertTrue(deletedOn.isBefore(OffsetDateTime.now()));
}
use of com.github.nagyesta.lowkeyvault.http.management.VaultModel in project lowkey-vault by nagyesta.
the class ManagementStepDefs method theVaultNamedVaultNameIsRecovered.
@And("the vault named {name} is recovered")
public void theVaultNamedVaultNameIsRecovered(final String vaultName) {
final String vaultUrl = vaultNameToUrl(vaultName);
final VaultModel model = context.getClient().recover(URI.create(vaultUrl));
assertNotNull(model);
}
use of com.github.nagyesta.lowkeyvault.http.management.VaultModel in project lowkey-vault by nagyesta.
the class ResponseEntityTest method testGetResponseObjectShouldMapResponseBodyUsingObjectReaderWhenCalledWithSingleObject.
@Test
void testGetResponseObjectShouldMapResponseBodyUsingObjectReaderWhenCalledWithSingleObject() {
// given
final VaultModel expected = new VaultModel(URI.create(HTTPS_DEFAULT_LOCALHOST_8443), null, null, null, null);
final HttpResponse response = mock(HttpResponse.class);
when(response.getStatusCode()).thenReturn(HttpStatus.SC_OK);
when(response.getBodyAsString(eq(StandardCharsets.UTF_8))).thenReturn(Mono.just(VAULT_MODEL));
final ObjectReader reader = new ObjectMapper().reader();
final ResponseEntity underTest = new ResponseEntity(response, reader);
// when
final VaultModel actual = underTest.getResponseObject(VaultModel.class);
// then
Assertions.assertEquals(expected, actual);
verify(response).getStatusCode();
verify(response).getBodyAsString(eq(StandardCharsets.UTF_8));
}
use of com.github.nagyesta.lowkeyvault.http.management.VaultModel in project lowkey-vault by nagyesta.
the class ResponseEntityTest method testGetResponseObjectShouldMapResponseBodyUsingObjectReaderWhenCalledWithList.
@Test
void testGetResponseObjectShouldMapResponseBodyUsingObjectReaderWhenCalledWithList() {
// given
final VaultModel vaultModel = new VaultModel(URI.create(HTTPS_DEFAULT_LOCALHOST_8443), null, null, null, null);
final List<VaultModel> expected = Collections.singletonList(vaultModel);
final HttpResponse response = mock(HttpResponse.class);
when(response.getStatusCode()).thenReturn(HttpStatus.SC_OK);
when(response.getBodyAsString(eq(StandardCharsets.UTF_8))).thenReturn(Mono.just(VAULT_MODEL_LIST));
final ObjectReader reader = new ObjectMapper().reader();
final ResponseEntity underTest = new ResponseEntity(response, reader);
// when
final List<VaultModel> actual = underTest.getResponseObject(VAULT_MODEL_LIST_TYPE_REF);
// then
Assertions.assertEquals(expected, actual);
verify(response).getStatusCode();
verify(response).getBodyAsString(eq(StandardCharsets.UTF_8));
}
use of com.github.nagyesta.lowkeyvault.http.management.VaultModel in project lowkey-vault by nagyesta.
the class ManagementStepDefs method vaultListContainsVaultNameWithDeletedOnAsNull.
@And("vault list contains {name} with deletedOn as null")
public void vaultListContainsVaultNameWithDeletedOnAsNull(final String vaultName) {
final List<VaultModel> models = context.getClient().listVaults();
final Optional<VaultModel> found = models.stream().filter(v -> v.getBaseUri().getHost().startsWith(vaultName)).findAny();
assertTrue(found.isPresent());
// noinspection OptionalGetWithoutIsPresent
final VaultModel vaultModel = found.get();
assertNull(vaultModel.getDeletedOn());
assertTrue(vaultModel.getCreatedOn().isBefore(OffsetDateTime.now()));
}
Aggregations