Search in sources :

Example 6 with CreateSecretRequestV2

use of keywhiz.api.automation.v2.CreateSecretRequestV2 in project keywhiz by square.

the class SecretResourceTest method modifySecretGroups_success.

@Test
public void modifySecretGroups_success() throws Exception {
    // Create sample secret and groups
    createGroup("group8a");
    createGroup("group8b");
    createGroup("group8c");
    create(CreateSecretRequestV2.builder().name("secret8").content(encoder.encodeToString("supa secret8".getBytes(UTF_8))).groups("group8a", "group8b").build());
    // Modify secret
    ModifyGroupsRequestV2 request = ModifyGroupsRequestV2.builder().addGroups("group8c", "non-existent1").removeGroups("group8a", "non-existent2").build();
    List<String> groups = modifyGroups("secret8", request);
    assertThat(groups).containsOnly("group8b", "group8c");
}
Also used : ModifyGroupsRequestV2(keywhiz.api.automation.v2.ModifyGroupsRequestV2) Test(org.junit.Test)

Example 7 with CreateSecretRequestV2

use of keywhiz.api.automation.v2.CreateSecretRequestV2 in project keywhiz by square.

the class SecretResourceTest method createSecret_duplicateUnVersioned.

@Test
public void createSecret_duplicateUnVersioned() throws Exception {
    CreateSecretRequestV2 request = CreateSecretRequestV2.builder().name("secret2").content(encoder.encodeToString("supa secret2".getBytes(UTF_8))).description("desc").build();
    Response httpResponse = create(request);
    assertThat(httpResponse.code()).isEqualTo(201);
    httpResponse = create(request);
    assertThat(httpResponse.code()).isEqualTo(409);
}
Also used : Response(okhttp3.Response) CreateSecretRequestV2(keywhiz.api.automation.v2.CreateSecretRequestV2) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 CreateSecretRequestV2 (keywhiz.api.automation.v2.CreateSecretRequestV2)3 ModifyGroupsRequestV2 (keywhiz.api.automation.v2.ModifyGroupsRequestV2)3 SecretDetailResponseV2 (keywhiz.api.automation.v2.SecretDetailResponseV2)3 Response (okhttp3.Response)3 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)1 Timed (com.codahale.metrics.annotation.Timed)1 ImmutableList (com.google.common.collect.ImmutableList)1 Sets (com.google.common.collect.Sets)1 Auth (io.dropwizard.auth.Auth)1 String.format (java.lang.String.format)1 URI (java.net.URI)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Instant (java.time.Instant)1 HOURS (java.time.temporal.ChronoUnit.HOURS)1 Base64 (java.util.Base64)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1