redacted / XKCD-password-generator

Generate secure multiword passwords/passphrases, inspired by XKCD
BSD 3-Clause "New" or "Revised" License
1.32k stars 185 forks source link

Fix non-deterministic test #158

Closed tribals closed 11 months ago

tribals commented 11 months ago

Hello!

During another ZHF, I've discovered a regression in build of this software project at Nix's bulding farm (called Hydra): https://hydra.nixos.org/build/240490554

The build fails due to a little non-determinism in test_random_delimiter test function. If generate_xkcdpassword() function does not take delimiter characters, it chooses them from default list, which contains empty string.

So, the value of len(result) could be not only 11, but also 10 or 9. This quick fix tries to solve the problem.

It would be nice to upstream those changes, so package definition would no more use a patch, as it does right now:

https://github.com/NixOS/nixpkgs/pull/268540/files#diff-96aa19f6bba1d17c2894d4fad12b1bbd5657796fcfed8812464380883c2fd0b5R23

redacted commented 11 months ago

Thanks for the fix! I implemented @peterhoeg's suggested alternative syntax in the end and haven't been able to trigger the random test failure in v1.19.6. I'll leave the PR open for now - once you're happy its working on Hydra let me know and I can close it off

peterhoeg commented 11 months ago

You haven't pushed it though.

redacted commented 11 months ago

It's in the 1.19.6 version - https://github.com/redacted/XKCD-password-generator/blob/8396611102b328a8f851ef72a74213b3c5794c8f/tests/test_xkcdpass.py The current master has been further improved but I have a couple more changes to include for the next pypi release