Search in sources :

Example 6 with StringCredentialValue

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

the class CredentialFactoryTest method makeCredentialFromRequest_givenAnExistingPassword_copiesCredentialNameReference.

@Test
public void makeCredentialFromRequest_givenAnExistingPassword_copiesCredentialNameReference() throws Exception {
    StringCredentialValue passwordValue = new StringCredentialValue(PLAINTEXT_VALUE);
    CredentialVersion existingCredentialVersion = new PasswordCredentialVersion(CREDENTIAL_NAME);
    CredentialVersion credentialVersion = subject.makeNewCredentialVersion(CredentialType.valueOf("password"), CREDENTIAL_NAME, passwordValue, existingCredentialVersion, generationParameters);
    assertThat(credentialVersion.getCredential(), equalTo(existingCredentialVersion.getCredential()));
}
Also used : StringCredentialValue(org.cloudfoundry.credhub.credential.StringCredentialValue) Test(org.junit.Test)

Example 7 with StringCredentialValue

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

the class PassayStringCredentialValueGeneratorTest method ignoresTooLargeLengthValues.

@Test
public void ignoresTooLargeLengthValues() {
    when(passwordGenerator.generatePassword(eq(subject.DEFAULT_LENGTH), anyList())).thenReturn("very-credential");
    StringGenerationParameters generationParameters = new StringGenerationParameters();
    generationParameters.setLength(201);
    StringCredentialValue stringCredentialValue = subject.generateCredential(generationParameters);
    assertThat(stringCredentialValue.getStringCredential(), equalTo("very-credential"));
}
Also used : StringCredentialValue(org.cloudfoundry.credhub.credential.StringCredentialValue) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Test(org.junit.Test)

Example 8 with StringCredentialValue

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

the class PassayStringCredentialValueGeneratorTest method canGenerateCredentialWithSpecificLength.

@Test
public void canGenerateCredentialWithSpecificLength() {
    when(passwordGenerator.generatePassword(eq(42), anyList())).thenReturn("very-credential");
    StringGenerationParameters generationParameters = new StringGenerationParameters();
    generationParameters.setLength(42);
    StringCredentialValue stringCredentialValue = subject.generateCredential(generationParameters);
    assertThat(stringCredentialValue.getStringCredential(), equalTo("very-credential"));
}
Also used : StringCredentialValue(org.cloudfoundry.credhub.credential.StringCredentialValue) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Test(org.junit.Test)

Example 9 with StringCredentialValue

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

the class PassayStringCredentialValueGeneratorTest method ignoresTooSmallLengthValues.

@Test
public void ignoresTooSmallLengthValues() {
    when(passwordGenerator.generatePassword(eq(subject.DEFAULT_LENGTH), anyList())).thenReturn("very-credential");
    StringGenerationParameters generationParameters = new StringGenerationParameters();
    generationParameters.setLength(3);
    StringCredentialValue stringCredentialValue = subject.generateCredential(generationParameters);
    assertThat(stringCredentialValue.getStringCredential(), equalTo("very-credential"));
}
Also used : StringCredentialValue(org.cloudfoundry.credhub.credential.StringCredentialValue) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Test(org.junit.Test)

Example 10 with StringCredentialValue

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

the class PassayStringCredentialValueGeneratorTest method canGenerateCredential.

@Test
public void canGenerateCredential() {
    StringGenerationParameters generationParameters = new StringGenerationParameters();
    when(passwordGenerator.generatePassword(eq(subject.DEFAULT_LENGTH), any(List.class))).thenReturn("very-credential");
    StringCredentialValue stringCredentialValue = subject.generateCredential(generationParameters);
    assertThat(stringCredentialValue.getStringCredential(), equalTo("very-credential"));
}
Also used : StringCredentialValue(org.cloudfoundry.credhub.credential.StringCredentialValue) List(java.util.List) Matchers.anyList(org.mockito.Matchers.anyList) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Test(org.junit.Test)

Aggregations

StringCredentialValue (org.cloudfoundry.credhub.credential.StringCredentialValue)15 Test (org.junit.Test)12 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)9 ArrayList (java.util.ArrayList)3 EventAuditRecordParameters (org.cloudfoundry.credhub.audit.EventAuditRecordParameters)3 Before (org.junit.Before)3 CertificateCredentialValue (org.cloudfoundry.credhub.credential.CertificateCredentialValue)2 RsaCredentialValue (org.cloudfoundry.credhub.credential.RsaCredentialValue)2 SshCredentialValue (org.cloudfoundry.credhub.credential.SshCredentialValue)2 PasswordSetRequest (org.cloudfoundry.credhub.request.PasswordSetRequest)2 List (java.util.List)1 UserContext (org.cloudfoundry.credhub.auth.UserContext)1 CryptSaltFactory (org.cloudfoundry.credhub.credential.CryptSaltFactory)1 UserCredentialValue (org.cloudfoundry.credhub.credential.UserCredentialValue)1 CertificateGenerationParameters (org.cloudfoundry.credhub.domain.CertificateGenerationParameters)1 CredentialVersion (org.cloudfoundry.credhub.domain.CredentialVersion)1 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)1 AuditingHelper (org.cloudfoundry.credhub.helper.AuditingHelper)1 GenerationParameters (org.cloudfoundry.credhub.request.GenerationParameters)1 PasswordGenerateRequest (org.cloudfoundry.credhub.request.PasswordGenerateRequest)1