-- | Tests HTTP signatures.
-- TODO: Make tests with official test suite https://github.com/w3c-ccg/http-signatures-test-suite
do
let unwrap :: Either String a -> IO a
unwrap = either fail pure
it "generates a valid HTTP signature" $ do
-- Test case validated through https://dinochiesa.github.io/httpsig/
testKey <- runEff $ runFailIO $ readKeyFile "test/testKey"
let date = UTCTime (read "2137-12-13") 0
params = GET { host = "example.com", path = "/.well-known/fwibble", date }
signer = Signer (Id "https://example.com/key") testKey
sig <- unwrap (makeSignature signer params)
fmtSignature sig `shouldBe` "keyId=\"https://example.com/key\", algorithm=\"rsa-sha256\", headers=\"(request-target) date host\", signature=\"fafUl+kuJItuFlrqRpzfqAB9Dxf/eLZY6i/jUBlME7nSb4ZRZ6EM0/3/wY1F+JThCUxJTNlW1/tnLzvB4lY33sEFjFQhCe6dKhLL8a3crMec0PDhRADW3kmivzGV+e4snMUG8R9+gQECzaBFSYpB1BE+yVYHHaBiHpqok7P35yEJ9ZJicaOT4bhv8nCMzVau8lj6e2nJra9ucGqIph5sX0wMVxwzlt4rlKUctFsvyjqNKI2Os/OwTrV1VhcvylXiUxWWztJiguQf9wOLgCG1G3O4PKpbinJ7bLkKqSSPJZUeWhCmHNhMYLXBEg0NR7OnDSOAHaNJ3/83EYhY1G3YlmJZ2SZnaGFqUVVySKec2IkbWCzoMeuxLYP16jcQvBU/sCiuSnBQTpdUh0uZsk75+HDz9uFosi8j/e+FZxKEk1ljWt6osUqq/jLjVKPecYBnUSNkhjEUPv4K/UnaV2uLtRvBfqiF/5nKLDtTp/rRdaDxQCdVTGnryVJ0lqsjgZ06SmRuqNJQf274OoEZJSQixulji+0ikpXBp/PeoFnfipEcSC68sKokAFAs9WjF8kq3CsoxkyQsMLziQTSalSseGJP107H7Pqw1fNlaR4zGL8lJo+TNHS4gkKglaMjfoAEMGZKziOQ/vCbvFFIsSqvbuvlF5hRmP1EvNb/mHvr3YJxIuznRkTshMSQ86L+307bxgN7+/05RPWVbWi3FZ5fEKmf8zR7pI2KqY6xdYIV93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