Search in sources :

Example 16 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class SecretsResourceTest method handlesNoAssociations.

@Test
public void handlesNoAssociations() {
    when(secretController.getSecretById(22)).thenReturn(Optional.of(secret));
    when(aclDAO.getGroupsFor(secret)).thenReturn(Collections.emptySet());
    when(aclDAO.getClientsFor(secret)).thenReturn(Collections.emptySet());
    SecretDetailResponse response = resource.retrieveSecret(user, new LongParam("22"));
    assertThat(response.groups).isEmpty();
    assertThat(response.clients).isEmpty();
}
Also used : SecretDetailResponse(keywhiz.api.SecretDetailResponse) LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 17 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class SecretsResourceTest method includesAssociations.

@Test
public void includesAssociations() {
    Client client = new Client(0, "client", null, null, null, null, null, null, false, false);
    Group group1 = new Group(0, "group1", null, null, null, null, null, null);
    Group group2 = new Group(0, "group2", null, null, null, null, null, null);
    when(secretController.getSecretById(22)).thenReturn(Optional.of(secret));
    when(aclDAO.getGroupsFor(secret)).thenReturn(Sets.newHashSet(group1, group2));
    when(aclDAO.getClientsFor(secret)).thenReturn(Sets.newHashSet(client));
    SecretDetailResponse response = resource.retrieveSecret(user, new LongParam("22"));
    assertThat(response.groups).containsOnly(group1, group2);
    assertThat(response.clients).containsOnly(client);
}
Also used : Group(keywhiz.api.model.Group) SecretDetailResponse(keywhiz.api.SecretDetailResponse) LongParam(io.dropwizard.jersey.params.LongParam) Client(keywhiz.api.model.Client) KeywhizClient(keywhiz.client.KeywhizClient) Test(org.junit.Test)

Example 18 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class SecretsResourceTest method deleteErrorsOnNotFound.

@Test(expected = NotFoundException.class)
public void deleteErrorsOnNotFound() {
    when(secretController.getSecretById(0xdeadbeef)).thenReturn(Optional.empty());
    resource.deleteSecret(user, new LongParam(Long.toString(0xdeadbeef)));
}
Also used : LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 19 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class SecretsResourceTest method badIdNotFound.

@Test(expected = NotFoundException.class)
public void badIdNotFound() {
    when(secretController.getSecretById(0xbad1d)).thenReturn(Optional.empty());
    resource.retrieveSecret(user, new LongParam(Long.toString(0xbad1d)));
}
Also used : LongParam(io.dropwizard.jersey.params.LongParam) Test(org.junit.Test)

Example 20 with LongParam

use of io.dropwizard.jersey.params.LongParam in project keywhiz by square.

the class SecretsResourceTest method rollbackThrowsException.

@Test(expected = NotFoundException.class)
public void rollbackThrowsException() {
    doThrow(new NotFoundException()).when(secretDAO).setCurrentSecretVersionByName(eq("name2"), anyLong());
    resource.resetSecretVersion(user, "name2", new LongParam("125"));
}
Also used : LongParam(io.dropwizard.jersey.params.LongParam) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.Test)

Aggregations

LongParam (io.dropwizard.jersey.params.LongParam)30 Test (org.junit.Test)30 Response (javax.ws.rs.core.Response)6 SecretDetailResponse (keywhiz.api.SecretDetailResponse)5 ClientDetailResponse (keywhiz.api.ClientDetailResponse)4 Group (keywhiz.api.model.Group)4 GroupDetailResponse (keywhiz.api.GroupDetailResponse)3 SanitizedSecret (keywhiz.api.model.SanitizedSecret)3 Client (keywhiz.api.model.Client)2 Secret (keywhiz.api.model.Secret)2 HashSet (java.util.HashSet)1 NotFoundException (javax.ws.rs.NotFoundException)1 KeywhizClient (keywhiz.client.KeywhizClient)1