Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.hs Secret

Created October 27, 2022 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dminuoso/dd9faad54d7719392319032ed8430916 to your computer and use it in GitHub Desktop.
Save dminuoso/dd9faad54d7719392319032ed8430916 to your computer and use it in GitHub Desktop.
arbitraryPass :: Int -> Gen BS.ByteString
arbitraryPass l = do
i <- chooseInt (0, l)
BS8.pack <$> vectorOf i arbitraryPrintableChar
qc_crypto :: TestTree
qc_crypto = testGroup "Crytographic functions" $
[ testProperty "encodePassword/decodePassword roundtrip" $
forAll (liftA3 (,,) arbitraryBS16 arbitraryBS16 (arbitraryPass 33)) $ \(auth,sec,pass) ->
Just pass === decodePassword auth (Secret sec) (encodePassword auth (Secret sec) pass)
]
Crytographic functions
encodePassword/decodePassword rountrip: FAIL
*** Failed! Falsified (after 59 tests):
("\214\188x\SYN\158\&3d\208{w\224v\212\208\&9$","\141&[\176\159C\134\195\186\195\DC3\192K2\EOT\191","`p\NUL")
Just "`p\NUL" /= Just "`p"
Use --quickcheck-replay=864535 to reproduce.
Use -p '/encodePassword\/decodePassword rountrip/' to rerun this test only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment