Search in sources :

Example 11 with CharacterRule

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))));
}
Also used : CharacterRule(org.passay.CharacterRule) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Test(org.junit.Test)

Example 12 with CharacterRule

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)));
}
Also used : CharacterRule(org.passay.CharacterRule) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Test(org.junit.Test)

Example 13 with CharacterRule

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))));
}
Also used : CharacterRule(org.passay.CharacterRule) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Test(org.junit.Test)

Example 14 with CharacterRule

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));
}
Also used : CharacterRule(org.passay.CharacterRule) StringGenerationParameters(org.cloudfoundry.credhub.request.StringGenerationParameters) Test(org.junit.Test)

Aggregations

CharacterRule (org.passay.CharacterRule)14 Test (org.junit.Test)8 StringGenerationParameters (org.cloudfoundry.credhub.request.StringGenerationParameters)7 ArrayList (java.util.ArrayList)4 Date (java.util.Date)1 CharacterCharacteristicsRule (org.passay.CharacterCharacteristicsRule)1 DictionaryRule (org.passay.DictionaryRule)1 DictionarySubstringRule (org.passay.DictionarySubstringRule)1 EnglishCharacterData (org.passay.EnglishCharacterData)1 IllegalRegexRule (org.passay.IllegalRegexRule)1 LengthRule (org.passay.LengthRule)1 PasswordGenerator (org.passay.PasswordGenerator)1 PasswordValidator (org.passay.PasswordValidator)1 Rule (org.passay.Rule)1