use of org.cloudfoundry.credhub.entity.UserCredentialVersionData in project credhub by cloudfoundry-incubator.
the class UserCredentialVersionTest method getUsername_returnsUsernameFromDelegate.
@Test
public void getUsername_returnsUsernameFromDelegate() {
subject = new UserCredentialVersion(new UserCredentialVersionData(CREDENTIAL_NAME).setUsername("test-user"));
assertThat(subject.getUsername(), equalTo("test-user"));
}
use of org.cloudfoundry.credhub.entity.UserCredentialVersionData in project credhub by cloudfoundry-incubator.
the class UserCredentialVersionTest method setPassword_encryptedProvidedPasswordOnce_andSetsCorrectValuesOnDelegate.
@Test
public void setPassword_encryptedProvidedPasswordOnce_andSetsCorrectValuesOnDelegate() {
when(encryptor.encrypt(eq(USER_PASSWORD))).thenReturn(new EncryptedValue(ENCRYPTION_KEY_UUID, ENCRYPTED_PASSWORD, NONCE));
userCredentialData = new UserCredentialVersionData(CREDENTIAL_NAME);
subject = new UserCredentialVersion(userCredentialData).setEncryptor(encryptor);
subject.setPassword(USER_PASSWORD);
verify(encryptor, times(1)).encrypt(eq(USER_PASSWORD));
assertThat(userCredentialData.getEncryptionKeyUuid(), equalTo(ENCRYPTION_KEY_UUID));
assertThat(userCredentialData.getEncryptedValueData().getEncryptedValue(), equalTo(ENCRYPTED_PASSWORD));
assertThat(userCredentialData.getNonce(), equalTo(NONCE));
}
use of org.cloudfoundry.credhub.entity.UserCredentialVersionData in project credhub by cloudfoundry-incubator.
the class UserCredentialVersionTest method setGenerationParameters_setsEncryptedGenerationParametersAndNonce.
@Test
public void setGenerationParameters_setsEncryptedGenerationParametersAndNonce() {
when(encryptor.encrypt(eq(USER_GENERATION_PARAMS_STRING))).thenReturn(new EncryptedValue(ENCRYPTION_KEY_UUID, ENCRYPTED_GENERATION_PARAMS, PARAMETERS_NONCE));
userCredentialData = new UserCredentialVersionData(CREDENTIAL_NAME);
subject = new UserCredentialVersion(userCredentialData).setEncryptor(encryptor);
subject.setGenerationParameters(STRING_GENERATION_PARAMS);
verify(encryptor, times(1)).encrypt(eq(USER_GENERATION_PARAMS_STRING));
assertThat(userCredentialData.getEncryptedGenerationParameters().getEncryptionKeyUuid(), equalTo(ENCRYPTION_KEY_UUID));
assertThat(userCredentialData.getEncryptedGenerationParameters().getEncryptedValue(), equalTo(ENCRYPTED_GENERATION_PARAMS));
assertThat(userCredentialData.getEncryptedGenerationParameters().getNonce(), equalTo(PARAMETERS_NONCE));
}
Aggregations