use of org.cloudfoundry.credhub.request.StringGenerationParameters 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.request.StringGenerationParameters 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"));
}
use of org.cloudfoundry.credhub.request.StringGenerationParameters in project credhub by cloudfoundry-incubator.
the class UserGeneratorTest method beforeEach.
@Before
public void beforeEach() {
UsernameGenerator usernameGenerator = mock(UsernameGenerator.class);
PasswordCredentialGenerator passwordGenerator = mock(PasswordCredentialGenerator.class);
CryptSaltFactory cryptSaltFactory = mock(CryptSaltFactory.class);
passwordParameters = new StringGenerationParameters();
userContext = null;
subject = new UserGenerator(usernameGenerator, passwordGenerator, cryptSaltFactory);
StringCredentialValue generatedUsername = new StringCredentialValue("fake-generated-username");
StringCredentialValue generatedPassword = new StringCredentialValue("fake-generated-password");
when(usernameGenerator.generateCredential()).thenReturn(generatedUsername);
when(passwordGenerator.generateCredential(eq(passwordParameters))).thenReturn(generatedPassword);
when(cryptSaltFactory.generateSalt(generatedPassword.getStringCredential())).thenReturn("fake-generated-salt");
}
use of org.cloudfoundry.credhub.request.StringGenerationParameters in project credhub by cloudfoundry-incubator.
the class CharacterRuleProviderTest method getCharacterRules_canCreateCharacterRulesWithoutUppercase.
@Test
public void getCharacterRules_canCreateCharacterRulesWithoutUppercase() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setExcludeUpper(true);
List<CharacterRule> characterRules = CharacterRuleProvider.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(2));
assertThat(characterRules, containsInAnyOrder(usesCharacters(EnglishCharacterData.LowerCase), usesCharacters(EnglishCharacterData.Digit)));
assertThat(characterRules, not(containsInAnyOrder(usesCharacters(EnglishCharacterData.UpperCase), usesCharacters(CredHubCharacterData.Special), usesCharacters(CredHubCharacterData.Hex))));
}
use of org.cloudfoundry.credhub.request.StringGenerationParameters in project credhub by cloudfoundry-incubator.
the class CharacterRuleProviderTest method getCharacterRules_canCreateCharacterRulesWithoutSpecialCharacters.
@Test
public void getCharacterRules_canCreateCharacterRulesWithoutSpecialCharacters() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setIncludeSpecial(false);
List<CharacterRule> characterRules = CharacterRuleProvider.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(3));
assertThat(characterRules, containsInAnyOrder(usesCharacters(EnglishCharacterData.UpperCase), usesCharacters(EnglishCharacterData.LowerCase), usesCharacters(EnglishCharacterData.Digit)));
assertThat(characterRules, not(hasItem(usesCharacters(CredHubCharacterData.Special))));
assertThat(characterRules, not(hasItem(usesCharacters(CredHubCharacterData.Hex))));
}
Aggregations