use of keywhiz.api.automation.v2.PartialUpdateSecretRequestV2 in project keywhiz by square.
the class SecretResourceTest method partialUpdateSecret_notFound.
@Test
public void partialUpdateSecret_notFound() throws Exception {
PartialUpdateSecretRequestV2 request = PartialUpdateSecretRequestV2.builder().description("a more detailed description").descriptionPresent(true).expiry(1487268151L).expiryPresent(true).build();
RequestBody body = RequestBody.create(JSON, mapper.writeValueAsString(request));
Request post = clientRequest("/automation/v2/secrets/non-existent/partialupdate").post(body).build();
Response httpResponse = mutualSslClient.newCall(post).execute();
assertThat(httpResponse.code()).isEqualTo(404);
}
use of keywhiz.api.automation.v2.PartialUpdateSecretRequestV2 in project keywhiz by square.
the class SecretResourceTest method partialUpdateSecret_success.
//---------------------------------------------------------------------------------------
// partialUpdateSecret
//---------------------------------------------------------------------------------------
@Test
public void partialUpdateSecret_success() throws Exception {
// Create a secret to update
CreateOrUpdateSecretRequestV2 createRequest = CreateOrUpdateSecretRequestV2.builder().content(encoder.encodeToString("supa secret".getBytes(UTF_8))).description("desc").metadata(ImmutableMap.of("owner", "root", "mode", "0440")).type("password").build();
Response httpResponse = createOrUpdate(createRequest, "secret3");
assertThat(httpResponse.code()).isEqualTo(201);
URI location = URI.create(httpResponse.header(LOCATION));
assertThat(location.getPath()).isEqualTo("/automation/v2/secrets/secret3");
// Update the secret's description and set its expiry
PartialUpdateSecretRequestV2 request = PartialUpdateSecretRequestV2.builder().description("a more detailed description").descriptionPresent(true).expiry(1487268151L).expiryPresent(true).build();
httpResponse = partialUpdate(request, "secret3");
assertThat(httpResponse.code()).isEqualTo(201);
location = URI.create(httpResponse.header(LOCATION));
assertThat(location.getPath()).isEqualTo("/automation/v2/secrets/secret3");
}
Aggregations