use of keywhiz.api.GroupDetailResponse in project keywhiz by square.
the class GroupsResourceIntegrationTest method createsGroup.
@Test
public void createsGroup() throws IOException {
keywhizClient.login(DbSeedCommand.defaultUser, DbSeedCommand.defaultPassword.toCharArray());
GroupDetailResponse groupDetails = keywhizClient.createGroup("NewGroup", "", ImmutableMap.of("app", "NewApp"));
assertThat(groupDetails.getName()).isEqualTo("NewGroup");
List<Group> groups = keywhizClient.allGroups();
List<String> names = Lists.transform(groups, new Function<Group, String>() {
@Override
public String apply(@Nullable Group group) {
return (group == null) ? null : group.getName();
}
});
assertThat(names).contains("NewGroup");
}
use of keywhiz.api.GroupDetailResponse in project keywhiz by square.
the class AutomationGroupResourceIntegrationTest method findGroup.
@Test
public void findGroup() throws Exception {
Request get = new Request.Builder().get().url(testUrl("/automation/groups?name=Web")).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build();
Response response = mutualSslClient.newCall(get).execute();
assertThat(response.code()).isEqualTo(200);
GroupDetailResponse groupResponse = mapper.readValue(response.body().string(), GroupDetailResponse.class);
assertThat(groupResponse.getId()).isEqualTo(918);
}
use of keywhiz.api.GroupDetailResponse in project keywhiz by square.
the class AutomationGroupResourceIntegrationTest method findAllGroups.
@Test
public void findAllGroups() throws Exception {
Request get = new Request.Builder().get().url(testUrl("/automation/groups")).addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON).build();
Response response = mutualSslClient.newCall(get).execute();
assertThat(response.code()).isEqualTo(200);
List<GroupDetailResponse> groups = mapper.readValue(response.body().string(), new TypeReference<List<GroupDetailResponse>>() {
});
assertThat(groups).extracting("name").contains("Blackops", "Security", "Web", "iOS");
}
use of keywhiz.api.GroupDetailResponse in project keywhiz by square.
the class GroupsResourceIntegrationTest method getGroupInfo.
@Test
public void getGroupInfo() throws IOException {
keywhizClient.login(DbSeedCommand.defaultUser, DbSeedCommand.defaultPassword.toCharArray());
GroupDetailResponse groupDetail = keywhizClient.groupDetailsForId(916);
assertThat(groupDetail.getName()).isEqualTo("Blackops");
}
use of keywhiz.api.GroupDetailResponse in project keywhiz by square.
the class GroupsResourceTest method getSpecificIncludesAllTheThings.
@Test
public void getSpecificIncludesAllTheThings() {
when(groupDAO.getGroupById(4444)).thenReturn(Optional.of(group));
SanitizedSecret secret = SanitizedSecret.of(1, "name", "checksum", null, now, "creator", now, "creator", null, null, null, 1136214245, 125L);
when(aclDAO.getSanitizedSecretsFor(group)).thenReturn(ImmutableSet.of(secret));
Client client = new Client(1, "client", "desc", now, "creator", now, "creator", null, true, false);
when(aclDAO.getClientsFor(group)).thenReturn(ImmutableSet.of(client));
GroupDetailResponse response = resource.getGroup(user, new LongParam("4444"));
assertThat(response.getId()).isEqualTo(group.getId());
assertThat(response.getName()).isEqualTo(group.getName());
assertThat(response.getDescription()).isEqualTo(group.getDescription());
assertThat(response.getCreationDate()).isEqualTo(group.getCreatedAt());
assertThat(response.getCreatedBy()).isEqualTo(group.getCreatedBy());
assertThat(response.getUpdateDate()).isEqualTo(group.getUpdatedAt());
assertThat(response.getUpdatedBy()).isEqualTo(group.getUpdatedBy());
assertThat(response.getSecrets()).containsExactly(secret);
assertThat(response.getClients()).containsExactly(client);
}
Aggregations