datafaker-net / datafaker

Generating fake data for the JVM (Java, Kotlin, Groovy) has never been easier!
https://www.datafaker.net
Apache License 2.0
1.16k stars 160 forks source link

Password generation does not always contain a lowercase letter #1250

Closed andriy-lendyel closed 4 months ago

andriy-lendyel commented 4 months ago

Password generation does not always contain a lowercase letter. It would be nice to fix this. Here is the test to reproduce this issue.

import net.datafaker.Faker;
import org.junit.jupiter.api.RepeatedTest;

class PasswordTest {

    private static Faker FAKER = new Faker();

    @RepeatedTest(100)
    void passwordTest() {
        String password = FAKER.internet().password(8, 16, true, true, true);

        assertTrue(
            password.chars().anyMatch(i -> Character.isLetter(i) && Character.isLowerCase(i)),
            password + " password should contain lower case character."
        );
    }
}
kingthorin commented 4 months ago

I guess we could add another method with a fourth Boolean but really logically someone could very well choose a password that is full caps 🤷‍♂️

Also in the next release we'll be deprecating the password methods and suggesting Text#text(Text.TextRuleConfig) instead.

snuyanzin commented 4 months ago

nobody says that internet().passwordgives you such guarantee, if you need such guarantee then use Text#text(Text.TextRuleConfig) as mentioned above

crimsonvspurple commented 4 months ago

I guess we could add another method with a fourth Boolean but really logically someone could very well choose a password that is full caps 🤷‍♂️

Also in the next release we'll be deprecating the password methods and suggesting Text#text(Text.TextRuleConfig) instead.

Hi.

Is it possible to make the new pass recommendation (TextSymbolsBuilder...) to optionally utilize SecureRandom? If not, will you please add this feature?

My apologies. I didn't notice the base faker constructor can take a random as parameter! thank you!