@Test public void should_assert_same_secrets_with_tokens() throws FileNotFoundException, VaultException { when(vaultConnection.createToken()).thenReturn(new VaultConnection.TokenCreator(vault)); when(vault.auth()).thenReturn(auth); when(auth.createToken(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())) .thenReturn(response); final Map<String, String> fooSecret = new HashMap<>(); fooSecret.put("zip", "zap"); fooSecret.put("a", "b"); when(vaultConnection.readLogical("secret/foo")).thenReturn(fooSecret); VaultAssertion.strictAssertEquals(new FileInputStream("src/test/resources/tokens_and_secrets.yml"), vaultConnection); verify(vaultConnection, times(1)).updateToken("C56A4180-65AA-42EC-A945-5FD21DEC0538"); verify(vaultConnection, times(1)).reconnectToOriginal(); verify(vaultConnection).readLogical("secret/foo"); verify(vaultConnection, times(0)).readLogical("secret/bar"); }
public static void strictAssertEquals(final InputStream dataset, final VaultConnection vault) { final Yaml yaml = new Yaml(); final Object load = yaml.load(dataset); if (areOnlySecrets(load)) { final List<Map<String, Map<String, Object>>> secrets = (List) load; checkSecretsRegisteredByTokens(secrets, vault); assertSecrets(secrets, vault); } }
VaultAssertion { public static void strictAssertEquals(final InputStream dataset, final VaultConnection vault) { final Yaml yaml = new Yaml(); final Object load = yaml.load(dataset); if (areOnlySecrets(load)) { final List<Map<String, Map<String, Object>>> secrets = (List) load; checkSecretsRegisteredByTokens(secrets, vault); assertSecrets(secrets, vault); } } }
VaultAssertion { public static void strictAssertEquals(final InputStream dataset, final VaultConnection vault) { final Yaml yaml = new Yaml(); final Object load = yaml.load(dataset); if (areOnlySecrets(load)) { final List<Map<String, Map<String, Object>>> secrets = (List) load; checkSecretsRegisteredByTokens(secrets, vault); assertSecrets(secrets, vault); } }  }
VaultAssertion { public static void strictAssertEquals(final InputStream dataset, final VaultConnection vault) { final Yaml yaml = new Yaml(); final Object load = yaml.load(dataset); if (areOnlySecrets(load)) { final List<Map<String, Map<String, Object>>> secrets = (List) load; checkSecretsRegisteredByTokens(secrets, vault); assertSecrets(secrets, vault); } }  static void strictAssertEquals(final InputStream dataset, final VaultConnection vault); }
VaultAssertion { public static void strictAssertEquals(final InputStream dataset, final VaultConnection vault) { final Yaml yaml = new Yaml(); final Object load = yaml.load(dataset); if (areOnlySecrets(load)) { final List<Map<String, Map<String, Object>>> secrets = (List) load; checkSecretsRegisteredByTokens(secrets, vault); assertSecrets(secrets, vault); } }  static void strictAssertEquals(final InputStream dataset, final VaultConnection vault);  }