Search in sources :

Example 6 with UserCredentialValue

use of org.cloudfoundry.credhub.credential.UserCredentialValue in project credhub by cloudfoundry-incubator.

the class UserGeneratorTest method generateCredential_givenAUsernameAndPasswordParameters_generatesUserWithUsernameAndGeneratedPassword.

@Test
public void generateCredential_givenAUsernameAndPasswordParameters_generatesUserWithUsernameAndGeneratedPassword() {
    passwordParameters.setUsername("test-user");
    final UserCredentialValue user = subject.generateCredential(passwordParameters);
    assertThat(user.getUsername(), equalTo("test-user"));
    assertThat(user.getPassword(), equalTo("fake-generated-password"));
    assertThat(user.getSalt(), equalTo("fake-generated-salt"));
}
Also used : UserCredentialValue(org.cloudfoundry.credhub.credential.UserCredentialValue) Test(org.junit.Test)

Example 7 with UserCredentialValue

use of org.cloudfoundry.credhub.credential.UserCredentialValue in project credhub by cloudfoundry-incubator.

the class CredentialFactoryTest method makeCredentialFromRequest_givenUserType_andNoExisting_returnsUserCredential.

@Test
public void makeCredentialFromRequest_givenUserType_andNoExisting_returnsUserCredential() throws Exception {
    UserCredentialValue userValue = new UserCredentialValue("username", PLAINTEXT_VALUE, "salt");
    UserCredentialVersion credential = (UserCredentialVersion) subject.makeNewCredentialVersion(CredentialType.valueOf("user"), CREDENTIAL_NAME, userValue, null, generationParameters);
    MatcherAssert.assertThat(credential.getCredential().getName(), equalTo(CREDENTIAL_NAME));
    assertThat(credential.getUsername(), equalTo("username"));
    assertThat(credential.getPassword(), equalTo(PLAINTEXT_VALUE));
    assertThat(credential.getSalt(), equalTo("salt"));
}
Also used : UserCredentialValue(org.cloudfoundry.credhub.credential.UserCredentialValue) Test(org.junit.Test)

Aggregations

UserCredentialValue (org.cloudfoundry.credhub.credential.UserCredentialValue)7 Test (org.junit.Test)5 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)2 ArrayList (java.util.ArrayList)1 EventAuditRecordParameters (org.cloudfoundry.credhub.audit.EventAuditRecordParameters)1 CertificateCredentialValue (org.cloudfoundry.credhub.credential.CertificateCredentialValue)1 RsaCredentialValue (org.cloudfoundry.credhub.credential.RsaCredentialValue)1 SshCredentialValue (org.cloudfoundry.credhub.credential.SshCredentialValue)1 StringCredentialValue (org.cloudfoundry.credhub.credential.StringCredentialValue)1 AuditingHelper (org.cloudfoundry.credhub.helper.AuditingHelper)1 GenerationParameters (org.cloudfoundry.credhub.request.GenerationParameters)1 UserSetRequest (org.cloudfoundry.credhub.request.UserSetRequest)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1