Search in sources :

Example 6 with SanitizedSecretWithGroups

use of keywhiz.api.model.SanitizedSecretWithGroups in project keywhiz by square.

the class SecretControllerTest method assertListContainsSecretsWithIds.

private void assertListContainsSecretsWithIds(List<SanitizedSecretWithGroups> secrets, List<Long> ids) {
    List<Long> foundIds = new ArrayList<>();
    for (SanitizedSecretWithGroups secretWithGroups : secrets) {
        if (ids.contains(secretWithGroups.secret().id())) {
            foundIds.add(secretWithGroups.secret().id());
        }
    }
    assertThat(foundIds).as("List should contain secrets with IDs %s; found IDs %s in secret list %s", ids, foundIds, secrets).containsExactlyElementsOf(ids);
}
Also used : SanitizedSecretWithGroups(keywhiz.api.model.SanitizedSecretWithGroups) ArrayList(java.util.ArrayList)

Example 7 with SanitizedSecretWithGroups

use of keywhiz.api.model.SanitizedSecretWithGroups in project keywhiz by square.

the class SecretControllerTest method assertListDoesNotContainSecretsWithIds.

private void assertListDoesNotContainSecretsWithIds(List<SanitizedSecretWithGroups> secrets, List<Long> ids) {
    Set<Long> foundIds = new HashSet<>();
    for (SanitizedSecretWithGroups secretWithGroups : secrets) {
        if (ids.contains(secretWithGroups.secret().id())) {
            foundIds.add(secretWithGroups.secret().id());
        }
    }
    assertThat(foundIds).as("List should NOT contain secrets with IDs %s; found IDs %s in secret list %s", ids, foundIds, secrets).isEmpty();
}
Also used : SanitizedSecretWithGroups(keywhiz.api.model.SanitizedSecretWithGroups) HashSet(java.util.HashSet)

Aggregations

SanitizedSecretWithGroups (keywhiz.api.model.SanitizedSecretWithGroups)7 ArrayList (java.util.ArrayList)3 SanitizedSecretWithGroupsListAndCursor (keywhiz.api.model.SanitizedSecretWithGroupsListAndCursor)3 SecretRetrievalCursor (keywhiz.api.model.SecretRetrievalCursor)3 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Group (keywhiz.api.model.Group)2 SanitizedSecret (keywhiz.api.model.SanitizedSecret)2 SanitizedSecretWithGroups.fromSecretSeriesAndContentAndGroups (keywhiz.api.model.SanitizedSecretWithGroups.fromSecretSeriesAndContentAndGroups)2 ExceptionMetered (com.codahale.metrics.annotation.ExceptionMetered)1 Timed (com.codahale.metrics.annotation.Timed)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Auth (io.dropwizard.auth.Auth)1 String.format (java.lang.String.format)1