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()));
}
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"));
}
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"));
}
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"));
}
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"));
}
Aggregations