use of org.passay.CharacterRule in project credhub by cloudfoundry-incubator.
the class CharacterRuleProviderTest method getCharacterRules_canCreateCharacterRulesWithoutNumbers.
@Test
public void getCharacterRules_canCreateCharacterRulesWithoutNumbers() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setExcludeNumber(true);
List<CharacterRule> characterRules = CharacterRuleProvider.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(2));
assertThat(characterRules, containsInAnyOrder(usesCharacters(EnglishCharacterData.UpperCase), usesCharacters(EnglishCharacterData.LowerCase)));
assertThat(characterRules, not(containsInAnyOrder(usesCharacters(EnglishCharacterData.Digit), usesCharacters(CredHubCharacterData.Special))));
}
use of org.passay.CharacterRule in project credhub by cloudfoundry-incubator.
the class CharacterRuleProviderTest method getCharacterRules_canCreateCharacterRulesWithAllIncluded.
@Test
public void getCharacterRules_canCreateCharacterRulesWithAllIncluded() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setIncludeSpecial(true);
List<CharacterRule> characterRules = CharacterRuleProvider.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(4));
assertThat(characterRules, containsInAnyOrder(usesCharacters(EnglishCharacterData.UpperCase), usesCharacters(EnglishCharacterData.LowerCase), usesCharacters(EnglishCharacterData.Digit), usesCharacters(CredHubCharacterData.Special)));
}
use of org.passay.CharacterRule in project credhub by cloudfoundry-incubator.
the class CharacterRuleProviderTest method getCharacterRules_canCreateCharacterRulesWithoutLowercase.
@Test
public void getCharacterRules_canCreateCharacterRulesWithoutLowercase() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setExcludeLower(true);
List<CharacterRule> characterRules = CharacterRuleProvider.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(2));
assertThat(characterRules, containsInAnyOrder(usesCharacters(EnglishCharacterData.UpperCase), usesCharacters(EnglishCharacterData.Digit)));
assertThat(characterRules, not(containsInAnyOrder(usesCharacters(EnglishCharacterData.LowerCase), usesCharacters(CredHubCharacterData.Special), usesCharacters(CredHubCharacterData.Hex))));
}
use of org.passay.CharacterRule in project credhub by cloudfoundry-incubator.
the class CharacterRuleProviderTest method getCharacterRules_returnsAnEmptyListWhenAllAreExcluded.
@Test
public void getCharacterRules_returnsAnEmptyListWhenAllAreExcluded() {
StringGenerationParameters generationParameters = new StringGenerationParameters();
generationParameters.setIncludeSpecial(false);
generationParameters.setExcludeNumber(true);
generationParameters.setExcludeUpper(true);
generationParameters.setExcludeLower(true);
List<CharacterRule> characterRules = CharacterRuleProvider.getCharacterRules(generationParameters);
assertThat(characterRules, iterableWithSize(0));
}
Aggregations