use of org.cloudfoundry.credhub.util.PasswordKeyProxyFactoryTestImpl in project credhub by cloudfoundry-incubator.
the class LunaKeyProxyTest method isMatchingCanary_usingOldCanaryValue_returnsTrue.
@Test
public void isMatchingCanary_usingOldCanaryValue_returnsTrue() throws Exception {
subject = new LunaKeyProxy(encryptionKey, new InternalEncryptionService(new PasswordKeyProxyFactoryTestImpl()));
assertThat(subject.matchesCanary(deprecatedCanary), equalTo(true));
}
use of org.cloudfoundry.credhub.util.PasswordKeyProxyFactoryTestImpl in project credhub by cloudfoundry-incubator.
the class LunaKeyProxyTest method isMatchingCanary_whenDecryptThrowsAEADBadTagException_returnsFalse.
@Test
public void isMatchingCanary_whenDecryptThrowsAEADBadTagException_returnsFalse() throws Exception {
subject = new LunaKeyProxy(encryptionKey, new InternalEncryptionService(new PasswordKeyProxyFactoryTestImpl()) {
@Override
public String decrypt(Key key, byte[] encryptedValue, byte[] nonce) throws Exception {
throw new AEADBadTagException();
}
});
assertThat(subject.matchesCanary(mock(EncryptionKeyCanary.class)), equalTo(false));
}
use of org.cloudfoundry.credhub.util.PasswordKeyProxyFactoryTestImpl in project credhub by cloudfoundry-incubator.
the class LunaKeyProxyTest method isMatchingCanary_whenDecryptThrowsBadPaddingException_throwsIncorrectKeyException.
@Test(expected = IncorrectKeyException.class)
public void isMatchingCanary_whenDecryptThrowsBadPaddingException_throwsIncorrectKeyException() throws Exception {
subject = new LunaKeyProxy(encryptionKey, new InternalEncryptionService(new PasswordKeyProxyFactoryTestImpl()) {
@Override
public String decrypt(Key key, byte[] encryptedValue, byte[] nonce) throws Exception {
throw new BadPaddingException("");
}
});
subject.matchesCanary(mock(EncryptionKeyCanary.class));
}
use of org.cloudfoundry.credhub.util.PasswordKeyProxyFactoryTestImpl in project credhub by cloudfoundry-incubator.
the class InternalEncryptionServiceTest method createsPasswordBasedKeyProxy.
@Test
public void createsPasswordBasedKeyProxy() throws Exception {
InternalEncryptionService subject = new InternalEncryptionService(new PasswordKeyProxyFactoryTestImpl());
EncryptionKeyMetadata keyMetadata = new EncryptionKeyMetadata();
keyMetadata.setEncryptionPassword("foobar");
final KeyProxy keyProxy = subject.createKeyProxy(keyMetadata);
assertThat(keyProxy, instanceOf(PasswordBasedKeyProxy.class));
}
Aggregations