Search in sources :

Example 6 with PartialUpdateSecretRequestV2

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);
}
Also used : Response(okhttp3.Response) PartialUpdateSecretRequestV2(keywhiz.api.automation.v2.PartialUpdateSecretRequestV2) Request(okhttp3.Request) TestClients.clientRequest(keywhiz.TestClients.clientRequest) RequestBody(okhttp3.RequestBody) Test(org.junit.Test)

Example 7 with PartialUpdateSecretRequestV2

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");
}
Also used : Response(okhttp3.Response) PartialUpdateSecretRequestV2(keywhiz.api.automation.v2.PartialUpdateSecretRequestV2) CreateOrUpdateSecretRequestV2(keywhiz.api.automation.v2.CreateOrUpdateSecretRequestV2) URI(java.net.URI) Test(org.junit.Test)

Aggregations

PartialUpdateSecretRequestV2 (keywhiz.api.automation.v2.PartialUpdateSecretRequestV2)7 Test (org.junit.Test)6 URI (java.net.URI)2 Response (okhttp3.Response)2 Response (javax.ws.rs.core.Response)1 TestClients.clientRequest (keywhiz.TestClients.clientRequest)1 SecretDetailResponse (keywhiz.api.SecretDetailResponse)1 CreateOrUpdateSecretRequestV2 (keywhiz.api.automation.v2.CreateOrUpdateSecretRequestV2)1 Request (okhttp3.Request)1 RequestBody (okhttp3.RequestBody)1