signet 0.2025.5.12 → 0.2025.5.13
raw patch · 44 files changed
+113/−91 lines, 44 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Signet.Unstable.Type.UnknownSignature: MkUnknownSignature :: ByteString -> UnknownSignature
- Signet.Unstable.Type.UnknownSignature: instance GHC.Classes.Eq Signet.Unstable.Type.UnknownSignature.UnknownSignature
- Signet.Unstable.Type.UnknownSignature: instance GHC.Show.Show Signet.Unstable.Type.UnknownSignature.UnknownSignature
- Signet.Unstable.Type.UnknownSignature: newtype UnknownSignature
- Signet.Unstable.Type.UnknownSignature: unwrap :: UnknownSignature -> ByteString
- Signet.Unstable.Type.UnknownSignatureTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.UnknownSignature: MkUnknownSignature :: ByteString -> UnknownSignature
+ Signet.Unstable.Exception.UnknownSignature: instance GHC.Classes.Eq Signet.Unstable.Exception.UnknownSignature.UnknownSignature
+ Signet.Unstable.Exception.UnknownSignature: instance GHC.Exception.Type.Exception Signet.Unstable.Exception.UnknownSignature.UnknownSignature
+ Signet.Unstable.Exception.UnknownSignature: instance GHC.Show.Show Signet.Unstable.Exception.UnknownSignature.UnknownSignature
+ Signet.Unstable.Exception.UnknownSignature: newtype UnknownSignature
+ Signet.Unstable.Exception.UnknownSignature: unwrap :: UnknownSignature -> ByteString
+ Signet.Unstable.Exception.UnknownSignatureTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidAsymmetricSignatureTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidAsymmetricSignatureTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidIdTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidIdTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidMessageTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidMessageTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidPublicKeyTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidPublicKeyTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidSecretKeyTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidSecretKeyTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidSecretTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidSecretTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidSignatureTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidSignatureTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidSignerTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidSignerTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidSymmetricSignatureTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidSymmetricSignatureTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidTimestampTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidTimestampTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.InvalidVerifierTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.InvalidVerifierTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.SignetExceptionTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.SignetExceptionTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.ToleranceExceptionTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.ToleranceExceptionTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Exception.VerificationExceptionTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Exception.VerificationExceptionTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Extra.EitherTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Extra.EitherTest: spec :: forall (io :: Type -> Type) tree. (MonadCatch io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Extra.HttpTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Extra.HttpTest: spec :: forall (io :: Type -> Type) tree. (Applicative io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Extra.MaybeTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Extra.MaybeTest: spec :: forall (io :: Type -> Type) tree. (Applicative io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.AsymmetricSignatureTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.AsymmetricSignatureTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.IdTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.IdTest: spec :: forall (io :: Type -> Type) tree. (Applicative io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.MessageTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.MessageTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.PayloadTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.PayloadTest: spec :: forall tree (io :: Type -> Type). Monad tree => Test io tree -> tree ()
- Signet.Unstable.Type.PublicKeyTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.PublicKeyTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.SecretKeyTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.SecretKeyTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.SecretTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.SecretTest: spec :: forall (io :: Type -> Type) tree. (Applicative io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.SignatureTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.SignatureTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.SignaturesTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.SignaturesTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.SignerTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.SignerTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.SymmetricSignatureTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.SymmetricSignatureTest: spec :: forall (io :: Type -> Type) tree. (Applicative io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.Test: MkTest :: (HasCallStack => String -> IO Void) -> (String -> spec () -> spec ()) -> (String -> IO () -> spec ()) -> Test (spec :: Type -> Type)
+ Signet.Unstable.Type.Test: MkTest :: (forall void. HasCallStack => String -> io void) -> (String -> tree () -> tree ()) -> (String -> io () -> tree ()) -> Test (io :: Type -> Type) (tree :: Type -> Type)
- Signet.Unstable.Type.Test: [assertFailure] :: Test (spec :: Type -> Type) -> HasCallStack => String -> IO Void
+ Signet.Unstable.Type.Test: [assertFailure] :: Test (io :: Type -> Type) (tree :: Type -> Type) -> forall void. HasCallStack => String -> io void
- Signet.Unstable.Type.Test: [describe] :: Test (spec :: Type -> Type) -> String -> spec () -> spec ()
+ Signet.Unstable.Type.Test: [describe] :: Test (io :: Type -> Type) (tree :: Type -> Type) -> String -> tree () -> tree ()
- Signet.Unstable.Type.Test: [it] :: Test (spec :: Type -> Type) -> String -> IO () -> spec ()
+ Signet.Unstable.Type.Test: [it] :: Test (io :: Type -> Type) (tree :: Type -> Type) -> String -> io () -> tree ()
- Signet.Unstable.Type.Test: assertEq :: forall a (tree :: Type -> Type). (HasCallStack, Eq a, Show a) => Test tree -> a -> a -> IO ()
+ Signet.Unstable.Type.Test: assertEq :: forall io a (tree :: Type -> Type). (HasCallStack, Applicative io, Eq a, Show a) => Test io tree -> a -> a -> io ()
- Signet.Unstable.Type.Test: data Test (spec :: Type -> Type)
+ Signet.Unstable.Type.Test: data Test (io :: Type -> Type) (tree :: Type -> Type)
- Signet.Unstable.Type.TimestampTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.TimestampTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.ToleranceTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.ToleranceTest: spec :: forall (io :: Type -> Type) tree. (Applicative io, Monad tree) => Test io tree -> tree ()
- Signet.Unstable.Type.VerifierTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.Unstable.Type.VerifierTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- Signet.UnstableTest: spec :: Monad tree => Test tree -> tree ()
+ Signet.UnstableTest: spec :: forall (io :: Type -> Type) tree. (MonadThrow io, Monad tree) => Test io tree -> tree ()
- SignetTest: spec :: Monad tree => Test tree -> tree ()
+ SignetTest: spec :: forall (io :: Type -> Type) tree. (MonadCatch io, Monad tree) => Test io tree -> tree ()
Files
- signet.cabal +3/−3
- source/library/Signet.hs +2/−2
- source/library/Signet/Unstable.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidAsymmetricSignatureTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidIdTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidMessageTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidPublicKeyTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidSecretKeyTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidSecretTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidSignatureTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidSignerTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidSymmetricSignatureTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidTimestampTest.hs +1/−1
- source/library/Signet/Unstable/Exception/InvalidVerifierTest.hs +1/−1
- source/library/Signet/Unstable/Exception/SignetExceptionTest.hs +1/−1
- source/library/Signet/Unstable/Exception/ToleranceExceptionTest.hs +1/−1
- source/library/Signet/Unstable/Exception/UnknownSignature.hs +14/−0
- source/library/Signet/Unstable/Exception/UnknownSignatureTest.hs +7/−0
- source/library/Signet/Unstable/Exception/VerificationExceptionTest.hs +1/−1
- source/library/Signet/Unstable/Extra/EitherTest.hs +1/−1
- source/library/Signet/Unstable/Extra/HttpTest.hs +1/−1
- source/library/Signet/Unstable/Extra/MaybeTest.hs +1/−1
- source/library/Signet/Unstable/Type/AsymmetricSignatureTest.hs +5/−3
- source/library/Signet/Unstable/Type/IdTest.hs +1/−1
- source/library/Signet/Unstable/Type/MessageTest.hs +2/−1
- source/library/Signet/Unstable/Type/PayloadTest.hs +1/−1
- source/library/Signet/Unstable/Type/PublicKeyTest.hs +5/−3
- source/library/Signet/Unstable/Type/SecretKeyTest.hs +5/−3
- source/library/Signet/Unstable/Type/SecretTest.hs +1/−1
- source/library/Signet/Unstable/Type/Signature.hs +1/−1
- source/library/Signet/Unstable/Type/SignatureTest.hs +6/−4
- source/library/Signet/Unstable/Type/Signatures.hs +1/−1
- source/library/Signet/Unstable/Type/SignaturesTest.hs +6/−4
- source/library/Signet/Unstable/Type/SignerTest.hs +4/−3
- source/library/Signet/Unstable/Type/SymmetricSignatureTest.hs +1/−1
- source/library/Signet/Unstable/Type/Test.hs +10/−7
- source/library/Signet/Unstable/Type/TimestampTest.hs +7/−7
- source/library/Signet/Unstable/Type/ToleranceTest.hs +1/−1
- source/library/Signet/Unstable/Type/UnknownSignature.hs +0/−10
- source/library/Signet/Unstable/Type/UnknownSignatureTest.hs +0/−7
- source/library/Signet/Unstable/Type/VerifierTest.hs +4/−3
- source/library/Signet/UnstableTest.hs +3/−2
- source/library/SignetTest.hs +4/−3
- source/test-suite/Main.hs +1/−1
signet.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: signet-version: 0.2025.5.12+version: 0.2025.5.13 synopsis: Standard Webhooks description: Signet is a Haskell library for working with Standard Webhooks.@@ -83,6 +83,8 @@ Signet.Unstable.Exception.SignetExceptionTest Signet.Unstable.Exception.ToleranceException Signet.Unstable.Exception.ToleranceExceptionTest+ Signet.Unstable.Exception.UnknownSignature+ Signet.Unstable.Exception.UnknownSignatureTest Signet.Unstable.Exception.VerificationException Signet.Unstable.Exception.VerificationExceptionTest Signet.Unstable.Extra.Either@@ -118,8 +120,6 @@ Signet.Unstable.Type.TimestampTest Signet.Unstable.Type.Tolerance Signet.Unstable.Type.ToleranceTest- Signet.Unstable.Type.UnknownSignature- Signet.Unstable.Type.UnknownSignatureTest Signet.Unstable.Type.Verifier Signet.Unstable.Type.VerifierTest Signet.UnstableTest
source/library/Signet.hs view
@@ -33,7 +33,6 @@ Signet.Unstable.parseTimestamp, Signet.Unstable.Type.Tolerance.Tolerance (..), Signet.Unstable.typicalTolerance,- Signet.Unstable.Type.UnknownSignature.UnknownSignature (..), Signet.Unstable.Type.Verifier.Verifier (Signet.Unstable.AsymmetricVerifier, Signet.Unstable.SymmetricVerifier), Signet.Unstable.parseVerifier, @@ -51,6 +50,7 @@ Signet.Unstable.Exception.InvalidVerifier.InvalidVerifier (..), Signet.Unstable.Exception.SignetException.SignetException (..), Signet.Unstable.Exception.ToleranceException.ToleranceException (..),+ Signet.Unstable.Exception.UnknownSignature.UnknownSignature (..), Signet.Unstable.Exception.VerificationException.VerificationException (..), ) where@@ -69,6 +69,7 @@ import qualified Signet.Unstable.Exception.InvalidVerifier import qualified Signet.Unstable.Exception.SignetException import qualified Signet.Unstable.Exception.ToleranceException+import qualified Signet.Unstable.Exception.UnknownSignature import qualified Signet.Unstable.Exception.VerificationException import qualified Signet.Unstable.Extra.Http import qualified Signet.Unstable.Type.AsymmetricSignature@@ -84,5 +85,4 @@ import qualified Signet.Unstable.Type.SymmetricSignature import qualified Signet.Unstable.Type.Timestamp import qualified Signet.Unstable.Type.Tolerance-import qualified Signet.Unstable.Type.UnknownSignature import qualified Signet.Unstable.Type.Verifier
source/library/Signet/Unstable.hs view
@@ -16,6 +16,7 @@ import qualified Signet.Unstable.Exception.InvalidTimestamp as InvalidTimestamp import qualified Signet.Unstable.Exception.InvalidVerifier as InvalidVerifier import qualified Signet.Unstable.Exception.SignetException as SignetException+import qualified Signet.Unstable.Exception.UnknownSignature as UnknownSignature import qualified Signet.Unstable.Extra.Either as Either import qualified Signet.Unstable.Type.AsymmetricSignature as AsymmetricSignature import qualified Signet.Unstable.Type.Id as Id@@ -30,7 +31,6 @@ import qualified Signet.Unstable.Type.SymmetricSignature as SymmetricSignature import qualified Signet.Unstable.Type.Timestamp as Timestamp import qualified Signet.Unstable.Type.Tolerance as Tolerance-import qualified Signet.Unstable.Type.UnknownSignature as UnknownSignature import qualified Signet.Unstable.Type.Verifier as Verifier -- | Verifies a webhook with 'Text.Text' values. This is a wrapper around
source/library/Signet/Unstable/Exception/InvalidAsymmetricSignatureTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidAsymmetricSignature" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidIdTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidId" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidMessageTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidMessage" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidPublicKeyTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidPublicKey" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidSecretKeyTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidSecretKey" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidSecretTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidSecret" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidSignatureTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidSignature" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidSignerTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidSigner" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidSymmetricSignatureTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidSymmetricSignature" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidTimestampTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidTimestamp" $ do pure ()
source/library/Signet/Unstable/Exception/InvalidVerifierTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.InvalidVerifier" $ do pure ()
source/library/Signet/Unstable/Exception/SignetExceptionTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.SignetException" $ do pure ()
source/library/Signet/Unstable/Exception/ToleranceExceptionTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.ToleranceException" $ do pure ()
+ source/library/Signet/Unstable/Exception/UnknownSignature.hs view
@@ -0,0 +1,14 @@+module Signet.Unstable.Exception.UnknownSignature where++import qualified Control.Monad.Catch as Exception+import qualified Data.ByteString as ByteString++newtype UnknownSignature+ = MkUnknownSignature ByteString.ByteString+ deriving (Eq, Show)++instance Exception.Exception UnknownSignature where+ displayException = mappend "unknown signature: " . show . unwrap++unwrap :: UnknownSignature -> ByteString.ByteString+unwrap (MkUnknownSignature byteString) = byteString
+ source/library/Signet/Unstable/Exception/UnknownSignatureTest.hs view
@@ -0,0 +1,7 @@+module Signet.Unstable.Exception.UnknownSignatureTest where++import qualified Signet.Unstable.Type.Test as Test++spec :: (Monad tree) => Test.Test io tree -> tree ()+spec test = Test.describe test "Signet.Unstable.Exception.UnknownSignature" $ do+ pure ()
source/library/Signet/Unstable/Exception/VerificationExceptionTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Exception.VerificationException" $ do pure ()
source/library/Signet/Unstable/Extra/EitherTest.hs view
@@ -5,7 +5,7 @@ import qualified Signet.Unstable.Extra.Either as Either import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadCatch io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Extra.Either" $ do Test.describe test "hush" $ do Test.it test "works with Left" $ do
source/library/Signet/Unstable/Extra/HttpTest.hs view
@@ -5,7 +5,7 @@ import qualified Signet.Unstable.Extra.Http as Http import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Applicative io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Extra.Http" $ do Test.describe test "hWebhookId" $ do Test.it test "creates the correct header name" $ do
source/library/Signet/Unstable/Extra/MaybeTest.hs view
@@ -4,7 +4,7 @@ import qualified Signet.Unstable.Extra.Maybe as Maybe import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Applicative io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Extra.Maybe" $ do Test.describe test "note" $ do Test.it test "works with nothing" $ do
source/library/Signet/Unstable/Type/AsymmetricSignatureTest.hs view
@@ -1,13 +1,15 @@ module Signet.Unstable.Type.AsymmetricSignatureTest where +import qualified Control.Monad.Catch as Exception import qualified Crypto.Error as Error import qualified Crypto.PubKey.Ed25519 as Ed25519 import qualified Data.ByteString.Char8 as Ascii import qualified Signet.Unstable.Exception.InvalidAsymmetricSignature as InvalidAsymmetricSignature+import qualified Signet.Unstable.Extra.Either as Either import qualified Signet.Unstable.Type.AsymmetricSignature as AsymmetricSignature import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.AsymmetricSignature" $ do Test.describe test "parse" $ do Test.it test "fails with invalid input" $ do@@ -17,10 +19,10 @@ Test.it test "succeeds with valid input" $ do let result = AsymmetricSignature.parse $ Ascii.pack "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVotMDEyMzQ1Njc4OS1hYmNkZWZnaGlqa2xtbm9wcXJzdHV2cXh5eg=="- signature <- Error.throwCryptoErrorIO . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz"+ signature <- Either.throw . Error.eitherCryptoError . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz" Test.assertEq test result (Right $ AsymmetricSignature.MkAsymmetricSignature signature) Test.describe test "render" $ do Test.it test "works" $ do- asymmetricSignature <- fmap AsymmetricSignature.MkAsymmetricSignature . Error.throwCryptoErrorIO . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz"+ asymmetricSignature <- Either.throw . fmap AsymmetricSignature.MkAsymmetricSignature . Error.eitherCryptoError . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz" Test.assertEq test (AsymmetricSignature.render asymmetricSignature) (Ascii.pack "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVotMDEyMzQ1Njc4OS1hYmNkZWZnaGlqa2xtbm9wcXJzdHV2cXh5eg==")
source/library/Signet/Unstable/Type/IdTest.hs view
@@ -5,7 +5,7 @@ import qualified Signet.Unstable.Type.Id as Id import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Applicative io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Id" $ do Test.describe test "parse" $ do Test.it test "fails with input containing separator" $ do
source/library/Signet/Unstable/Type/MessageTest.hs view
@@ -1,5 +1,6 @@ module Signet.Unstable.Type.MessageTest where +import qualified Control.Monad.Catch as Exception import qualified Data.ByteString.Char8 as Ascii import qualified Signet.Unstable.Exception.InvalidMessage as InvalidMessage import qualified Signet.Unstable.Exception.InvalidTimestamp as InvalidTimestamp@@ -10,7 +11,7 @@ import qualified Signet.Unstable.Type.Test as Test import qualified Signet.Unstable.Type.Timestamp as Timestamp -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Message" $ do Test.describe test "parse" $ do Test.it test "fails with invalid timestamp" $ do
source/library/Signet/Unstable/Type/PayloadTest.hs view
@@ -2,6 +2,6 @@ import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Payload" $ do pure ()
source/library/Signet/Unstable/Type/PublicKeyTest.hs view
@@ -1,13 +1,15 @@ module Signet.Unstable.Type.PublicKeyTest where +import qualified Control.Monad.Catch as Exception import qualified Crypto.Error as Error import qualified Crypto.PubKey.Ed25519 as Ed25519 import qualified Data.ByteString.Char8 as Ascii import qualified Signet.Unstable.Exception.InvalidPublicKey as InvalidPublicKey+import qualified Signet.Unstable.Extra.Either as Either import qualified Signet.Unstable.Type.PublicKey as PublicKey import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.PublicKey" $ do Test.describe test "parse" $ do Test.it test "fails with invalid prefix" $ do@@ -22,10 +24,10 @@ Test.it test "succeeds with valid input" $ do let result = PublicKey.parse $ Ascii.pack "whpk_QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU="- publicKey <- fmap PublicKey.MkPublicKey . Error.throwCryptoErrorIO . Ed25519.publicKey $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"+ publicKey <- Either.throw . fmap PublicKey.MkPublicKey . Error.eitherCryptoError . Ed25519.publicKey $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345" Test.assertEq test result (Right publicKey) Test.describe test "render" $ do Test.it test "works" $ do- publicKey <- fmap PublicKey.MkPublicKey . Error.throwCryptoErrorIO . Ed25519.publicKey $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"+ publicKey <- Either.throw . fmap PublicKey.MkPublicKey . Error.eitherCryptoError . Ed25519.publicKey $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345" Test.assertEq test (PublicKey.render publicKey) (Ascii.pack "whpk_QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU=")
source/library/Signet/Unstable/Type/SecretKeyTest.hs view
@@ -1,13 +1,15 @@ module Signet.Unstable.Type.SecretKeyTest where +import qualified Control.Monad.Catch as Exception import qualified Crypto.Error as Error import qualified Crypto.PubKey.Ed25519 as Ed25519 import qualified Data.ByteString.Char8 as Ascii import qualified Signet.Unstable.Exception.InvalidSecretKey as InvalidSecretKey+import qualified Signet.Unstable.Extra.Either as Either import qualified Signet.Unstable.Type.SecretKey as SecretKey import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.SecretKey" $ do Test.describe test "parse" $ do Test.it test "fails with invalid prefix" $ do@@ -22,10 +24,10 @@ Test.it test "succeeds with valid input" $ do let result = SecretKey.parse $ Ascii.pack "whsk_QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU="- secretKey <- fmap SecretKey.MkSecretKey . Error.throwCryptoErrorIO . Ed25519.secretKey $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"+ secretKey <- Either.throw . fmap SecretKey.MkSecretKey . Error.eitherCryptoError . Ed25519.secretKey $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345" Test.assertEq test result (Right secretKey) Test.describe test "render" $ do Test.it test "works" $ do- secretKey <- fmap SecretKey.MkSecretKey . Error.throwCryptoErrorIO . Ed25519.secretKey $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"+ secretKey <- Either.throw . fmap SecretKey.MkSecretKey . Error.eitherCryptoError . Ed25519.secretKey $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345" Test.assertEq test (SecretKey.render secretKey) (Ascii.pack "whsk_QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU=")
source/library/Signet/Unstable/Type/SecretTest.hs view
@@ -6,7 +6,7 @@ import qualified Signet.Unstable.Type.Secret as Secret import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Applicative io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Secret" $ do Test.describe test "parse" $ do Test.it test "fails with invalid prefix" $ do
source/library/Signet/Unstable/Type/Signature.hs view
@@ -5,9 +5,9 @@ import qualified Data.ByteString.Char8 as Ascii import qualified Data.Word as Word import qualified Signet.Unstable.Exception.InvalidSignature as InvalidSignature+import qualified Signet.Unstable.Exception.UnknownSignature as UnknownSignature import qualified Signet.Unstable.Type.AsymmetricSignature as AsymmetricSignature import qualified Signet.Unstable.Type.SymmetricSignature as SymmetricSignature-import qualified Signet.Unstable.Type.UnknownSignature as UnknownSignature data Signature = Asymmetric AsymmetricSignature.AsymmetricSignature
source/library/Signet/Unstable/Type/SignatureTest.hs view
@@ -1,5 +1,6 @@ module Signet.Unstable.Type.SignatureTest where +import qualified Control.Monad.Catch as Exception import qualified Crypto.Error as Error import qualified Crypto.Hash as Hash import qualified Crypto.PubKey.Ed25519 as Ed25519@@ -8,13 +9,14 @@ import qualified Signet.Unstable.Exception.InvalidAsymmetricSignature as InvalidAsymmetricSignature import qualified Signet.Unstable.Exception.InvalidSignature as InvalidSignature import qualified Signet.Unstable.Exception.InvalidSymmetricSignature as InvalidSymmetricSignature+import qualified Signet.Unstable.Exception.UnknownSignature as UnknownSignature+import qualified Signet.Unstable.Extra.Either as Either import qualified Signet.Unstable.Type.AsymmetricSignature as AsymmetricSignature import qualified Signet.Unstable.Type.Signature as Signature import qualified Signet.Unstable.Type.SymmetricSignature as SymmetricSignature import qualified Signet.Unstable.Type.Test as Test-import qualified Signet.Unstable.Type.UnknownSignature as UnknownSignature -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Signature" $ do Test.describe test "parse" $ do Test.it test "fails with invalid asymmetric signature" $ do@@ -34,7 +36,7 @@ Test.it test "succeeds with valid asymmetric signature" $ do let byteString = Ascii.pack "v1a,QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVotMDEyMzQ1Njc4OS1hYmNkZWZnaGlqa2xtbm9wcXJzdHV2cXh5eg=="- signature <- fmap (Signature.Asymmetric . AsymmetricSignature.MkAsymmetricSignature) . Error.throwCryptoErrorIO . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz"+ signature <- Either.throw . fmap (Signature.Asymmetric . AsymmetricSignature.MkAsymmetricSignature) . Error.eitherCryptoError . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz" Test.assertEq test (Signature.parse byteString) (Right (Right signature)) Test.it test "succeeds with valid symmetric signature" $ do@@ -44,7 +46,7 @@ Test.describe test "render" $ do Test.it test "renders asymmetric signature correctly" $ do- signature <- fmap (Signature.Asymmetric . AsymmetricSignature.MkAsymmetricSignature) . Error.throwCryptoErrorIO . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz"+ signature <- Either.throw . fmap (Signature.Asymmetric . AsymmetricSignature.MkAsymmetricSignature) . Error.eitherCryptoError . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz" Test.assertEq test (Signature.render signature) (Ascii.pack "v1a,QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVotMDEyMzQ1Njc4OS1hYmNkZWZnaGlqa2xtbm9wcXJzdHV2cXh5eg==") Test.it test "renders symmetric signature correctly" $ do
source/library/Signet/Unstable/Type/Signatures.hs view
@@ -4,8 +4,8 @@ import qualified Data.Either as Either import qualified Data.Word as Word import qualified Signet.Unstable.Exception.InvalidSignature as InvalidSignature+import qualified Signet.Unstable.Exception.UnknownSignature as UnknownSignature import qualified Signet.Unstable.Type.Signature as Signature-import qualified Signet.Unstable.Type.UnknownSignature as UnknownSignature newtype Signatures = MkSignatures [Signature.Signature]
source/library/Signet/Unstable/Type/SignaturesTest.hs view
@@ -1,5 +1,6 @@ module Signet.Unstable.Type.SignaturesTest where +import qualified Control.Monad.Catch as Exception import qualified Crypto.Error as Error import qualified Crypto.Hash as Hash import qualified Crypto.PubKey.Ed25519 as Ed25519@@ -8,14 +9,15 @@ import qualified Signet.Unstable.Exception.InvalidAsymmetricSignature as InvalidAsymmetricSignature import qualified Signet.Unstable.Exception.InvalidSignature as InvalidSignature import qualified Signet.Unstable.Exception.InvalidSymmetricSignature as InvalidSymmetricSignature+import qualified Signet.Unstable.Exception.UnknownSignature as UnknownSignature+import qualified Signet.Unstable.Extra.Either as Either import qualified Signet.Unstable.Type.AsymmetricSignature as AsymmetricSignature import qualified Signet.Unstable.Type.Signature as Signature import qualified Signet.Unstable.Type.Signatures as Signatures import qualified Signet.Unstable.Type.SymmetricSignature as SymmetricSignature import qualified Signet.Unstable.Type.Test as Test-import qualified Signet.Unstable.Type.UnknownSignature as UnknownSignature -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Signatures" $ do Test.describe test "parse" $ do Test.it test "succeeds with no signatures" $ do@@ -28,7 +30,7 @@ Test.it test "succeeds with many signatures" $ do let symmetricSignature = SymmetricSignature.MkSymmetricSignature $ Hash.hash ByteString.empty- asymmetricSignature <- fmap AsymmetricSignature.MkAsymmetricSignature . Error.throwCryptoErrorIO . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz"+ asymmetricSignature <- Either.throw . fmap AsymmetricSignature.MkAsymmetricSignature . Error.eitherCryptoError . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz" let byteString = Ascii.pack "v1,47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= v1a,QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVotMDEyMzQ1Njc4OS1hYmNkZWZnaGlqa2xtbm9wcXJzdHV2cXh5eg==" let signatures = Signatures.MkSignatures@@ -62,7 +64,7 @@ Test.it test "renders many signatures" $ do let symmetricSignature = SymmetricSignature.MkSymmetricSignature $ Hash.hash ByteString.empty- asymmetricSignature <- fmap AsymmetricSignature.MkAsymmetricSignature . Error.throwCryptoErrorIO . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz"+ asymmetricSignature <- Either.throw . fmap AsymmetricSignature.MkAsymmetricSignature . Error.eitherCryptoError . Ed25519.signature $ Ascii.pack "ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789-abcdefghijklmnopqrstuvqxyz" let signatures = Signatures.MkSignatures [ Signature.Symmetric symmetricSignature,
source/library/Signet/Unstable/Type/SignerTest.hs view
@@ -1,5 +1,6 @@ module Signet.Unstable.Type.SignerTest where +import qualified Control.Monad.Catch as Exception import qualified Data.ByteString.Char8 as Ascii import qualified Signet.Unstable.Exception.InvalidSigner as InvalidSigner import qualified Signet.Unstable.Extra.Either as Either@@ -12,7 +13,7 @@ import qualified Signet.Unstable.Type.SymmetricSignature as SymmetricSignature import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Signer" $ do Test.describe test "parse" $ do Test.it test "succeeds with a valid secret key" $ do@@ -48,14 +49,14 @@ signer <- Either.throw . Signer.parse $ Ascii.pack "whsk_QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVowMTIzNDU=" message <- Either.throw . Message.parse $ Ascii.pack "i.0.Hello, world!" let actual = Signer.sign signer message- Right expected <- Either.throw . Signature.parse $ Ascii.pack "v1a,CV1O+PvrwXM42OMUX+tmm6bA3cS0tgLp0qo3YKuu0MGmBrsUhA0MHXF11HsEUJtPfTKs80WE7WUKVt9TueLDCQ=="+ expected <- Either.throw =<< Either.throw (Signature.parse $ Ascii.pack "v1a,CV1O+PvrwXM42OMUX+tmm6bA3cS0tgLp0qo3YKuu0MGmBrsUhA0MHXF11HsEUJtPfTKs80WE7WUKVt9TueLDCQ==") Test.assertEq test actual expected Test.it test "works with symmetric" $ do signer <- Either.throw . Signer.parse $ Ascii.pack "whsec_bXlzZWNyZXRrZXkxMjM0NQ==" message <- Either.throw . Message.parse $ Ascii.pack "i.0.Hello, world!" let actual = Signer.sign signer message- Right expected <- Either.throw . Signature.parse $ Ascii.pack "v1,IywpE5NXy+JdAScgR7j5Pt59GjmazD7iJuVsQoRZFyw="+ expected <- Either.throw =<< Either.throw (Signature.parse $ Ascii.pack "v1,IywpE5NXy+JdAScgR7j5Pt59GjmazD7iJuVsQoRZFyw=") Test.assertEq test actual expected Test.describe test "asymmetric" $ do
source/library/Signet/Unstable/Type/SymmetricSignatureTest.hs view
@@ -7,7 +7,7 @@ import qualified Signet.Unstable.Type.SymmetricSignature as SymmetricSignature import qualified Signet.Unstable.Type.Test as Test -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Applicative io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.SymmetricSignature" $ do Test.describe test "parse" $ do Test.it test "fails with invalid symmetric signature" $ do
source/library/Signet/Unstable/Type/Test.hs view
@@ -3,18 +3,21 @@ module Signet.Unstable.Type.Test where import qualified Control.Monad as Monad-import qualified Data.Void as Void import qualified GHC.Stack as Stack -data Test spec = MkTest- { assertFailure :: (Stack.HasCallStack) => String -> IO Void.Void,- describe :: String -> spec () -> spec (),- it :: String -> IO () -> spec ()+data Test io tree = MkTest+ { assertFailure :: forall void. (Stack.HasCallStack) => String -> io void,+ describe :: String -> tree () -> tree (),+ it :: String -> io () -> tree () } -assertEq :: (Stack.HasCallStack, Eq a, Show a) => Test tree -> a -> a -> IO ()+assertEq ::+ (Stack.HasCallStack, Applicative io, Eq a, Show a) =>+ Test io tree ->+ a ->+ a ->+ io () assertEq test expected actual = Monad.when (expected /= actual)- . Monad.void . assertFailure test $ "expected " <> show expected <> " but got " <> show actual
source/library/Signet/Unstable/Type/TimestampTest.hs view
@@ -1,12 +1,14 @@ module Signet.Unstable.Type.TimestampTest where +import qualified Control.Monad.Catch as Exception import qualified Data.ByteString.Char8 as Ascii import qualified Data.Time as Time import qualified Signet.Unstable.Exception.InvalidTimestamp as InvalidTimestamp+import qualified Signet.Unstable.Extra.Either as Either import qualified Signet.Unstable.Type.Test as Test import qualified Signet.Unstable.Type.Timestamp as Timestamp -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Timestamp" $ do Test.describe test "parse" $ do Test.it test "fails with invalid timestamp format" $ do@@ -17,12 +19,10 @@ Test.it test "succeeds with valid timestamp format" $ do let byteString = Ascii.pack "1617235200" let result = Timestamp.parse byteString- case result of- Right timestamp -> do- let utcTime = Timestamp.unwrap timestamp- let expectedTime = Time.UTCTime (Time.fromGregorian 2021 4 1) 0- Test.assertEq test utcTime expectedTime- Left _ -> fail "Expected Right but got Left"+ timestamp <- Either.throw result+ let utcTime = Timestamp.unwrap timestamp+ let expectedTime = Time.UTCTime (Time.fromGregorian 2021 4 1) 0+ Test.assertEq test utcTime expectedTime Test.describe test "render" $ do Test.it test "returns the correct ByteString representation" $ do
source/library/Signet/Unstable/Type/ToleranceTest.hs view
@@ -6,7 +6,7 @@ import qualified Signet.Unstable.Type.Timestamp as Timestamp import qualified Signet.Unstable.Type.Tolerance as Tolerance -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Applicative io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Tolerance" $ do Test.describe test "check" $ do Test.it test "succeeds when timestamp is within tolerance" $ do
− source/library/Signet/Unstable/Type/UnknownSignature.hs
@@ -1,10 +0,0 @@-module Signet.Unstable.Type.UnknownSignature where--import qualified Data.ByteString as ByteString--newtype UnknownSignature- = MkUnknownSignature ByteString.ByteString- deriving (Eq, Show)--unwrap :: UnknownSignature -> ByteString.ByteString-unwrap (MkUnknownSignature byteString) = byteString
− source/library/Signet/Unstable/Type/UnknownSignatureTest.hs
@@ -1,7 +0,0 @@-module Signet.Unstable.Type.UnknownSignatureTest where--import qualified Signet.Unstable.Type.Test as Test--spec :: (Monad tree) => Test.Test tree -> tree ()-spec test = Test.describe test "Signet.Unstable.Type.UnknownSignature" $ do- pure ()
source/library/Signet/Unstable/Type/VerifierTest.hs view
@@ -1,5 +1,6 @@ module Signet.Unstable.Type.VerifierTest where +import qualified Control.Monad.Catch as Exception import qualified Data.ByteString.Char8 as Ascii import qualified Signet.Unstable.Exception.InvalidVerifier as InvalidVerifier import qualified Signet.Unstable.Exception.VerificationException as VerificationException@@ -14,7 +15,7 @@ import qualified Signet.Unstable.Type.Test as Test import qualified Signet.Unstable.Type.Verifier as Verifier -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable.Type.Verifier" $ do Test.describe test "parse" $ do Test.it test "succeeds with a valid public key" $ do@@ -51,7 +52,7 @@ message <- Either.throw . Message.parse $ Ascii.pack "i.0.Hello, world!" (_, signatures) <- Either.throw . Signatures.parse $ Ascii.pack "v1a,CV1O+PvrwXM42OMUX+tmm6bA3cS0tgLp0qo3YKuu0MGmBrsUhA0MHXF11HsEUJtPfTKs80WE7WUKVt9TueLDCQ==" let actual = Verifier.verify verifier message signatures- Right signature <- Either.throw . Signature.parse $ Ascii.pack "v1a,CV1O+PvrwXM42OMUX+tmm6bA3cS0tgLp0qo3YKuu0MGmBrsUhA0MHXF11HsEUJtPfTKs80WE7WUKVt9TueLDCQ=="+ signature <- Either.throw =<< Either.throw (Signature.parse $ Ascii.pack "v1a,CV1O+PvrwXM42OMUX+tmm6bA3cS0tgLp0qo3YKuu0MGmBrsUhA0MHXF11HsEUJtPfTKs80WE7WUKVt9TueLDCQ==") Test.assertEq test actual (Right signature) Test.it test "fails with an invalid asymmetric signature" $ do@@ -66,7 +67,7 @@ message <- Either.throw . Message.parse $ Ascii.pack "i.0.Hello, world!" (_, signatures) <- Either.throw . Signatures.parse $ Ascii.pack "v1,IywpE5NXy+JdAScgR7j5Pt59GjmazD7iJuVsQoRZFyw=" let actual = Verifier.verify verifier message signatures- Right signature <- Either.throw . Signature.parse $ Ascii.pack "v1,IywpE5NXy+JdAScgR7j5Pt59GjmazD7iJuVsQoRZFyw="+ signature <- Either.throw =<< Either.throw (Signature.parse $ Ascii.pack "v1,IywpE5NXy+JdAScgR7j5Pt59GjmazD7iJuVsQoRZFyw=") Test.assertEq test actual (Right signature) Test.it test "fails with an invalid symmetric signature" $ do
source/library/Signet/UnstableTest.hs view
@@ -1,5 +1,6 @@ module Signet.UnstableTest where +import qualified Control.Monad.Catch as Exception import qualified Data.ByteString.Char8 as Ascii import qualified Data.Time as Time import qualified Signet.Unstable as Signet@@ -14,7 +15,7 @@ import qualified Signet.Unstable.Type.Tolerance as Tolerance import qualified Signet.Unstable.Type.Verifier as Verifier -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadThrow io, Monad tree) => Test.Test io tree -> tree () spec test = Test.describe test "Signet.Unstable" $ do Test.describe test "verifyWebhookText" $ do pure ()@@ -34,7 +35,7 @@ let byteString = Ascii.pack "v1,IywpE5NXy+JdAScgR7j5Pt59GjmazD7iJuVsQoRZFyw=" (_, signatures) <- Either.throw $ Signatures.parse byteString let result = Signet.verifyWebhookWith tolerance now verifier message signatures- Right signature <- Either.throw $ Signature.parse byteString+ signature <- Either.throw =<< Either.throw (Signature.parse byteString) Test.assertEq test result (Right signature) Test.it test "fails with an invalid timestamp" $ do
source/library/SignetTest.hs view
@@ -1,5 +1,6 @@ module SignetTest where +import qualified Control.Monad.Catch as Exception import qualified Signet.Unstable.Exception.InvalidAsymmetricSignatureTest import qualified Signet.Unstable.Exception.InvalidIdTest import qualified Signet.Unstable.Exception.InvalidMessageTest@@ -13,6 +14,7 @@ import qualified Signet.Unstable.Exception.InvalidVerifierTest import qualified Signet.Unstable.Exception.SignetExceptionTest import qualified Signet.Unstable.Exception.ToleranceExceptionTest+import qualified Signet.Unstable.Exception.UnknownSignatureTest import qualified Signet.Unstable.Exception.VerificationExceptionTest import qualified Signet.Unstable.Extra.EitherTest import qualified Signet.Unstable.Extra.HttpTest@@ -31,11 +33,10 @@ import qualified Signet.Unstable.Type.Test as Test import qualified Signet.Unstable.Type.TimestampTest import qualified Signet.Unstable.Type.ToleranceTest-import qualified Signet.Unstable.Type.UnknownSignatureTest import qualified Signet.Unstable.Type.VerifierTest import qualified Signet.UnstableTest -spec :: (Monad tree) => Test.Test tree -> tree ()+spec :: (Exception.MonadCatch io, Monad tree) => Test.Test io tree -> tree () spec test = do Signet.Unstable.Exception.InvalidAsymmetricSignatureTest.spec test Signet.Unstable.Exception.InvalidIdTest.spec test@@ -67,6 +68,6 @@ Signet.Unstable.Type.SymmetricSignatureTest.spec test Signet.Unstable.Type.TimestampTest.spec test Signet.Unstable.Type.ToleranceTest.spec test- Signet.Unstable.Type.UnknownSignatureTest.spec test+ Signet.Unstable.Exception.UnknownSignatureTest.spec test Signet.Unstable.Type.VerifierTest.spec test Signet.UnstableTest.spec test
source/test-suite/Main.hs view
@@ -10,7 +10,7 @@ testTree :: Tasty.TestTree testTree = Tasty.testGroup "signet" . Writer.execWriter $ SignetTest.spec tasty -tasty :: Test.Test (Writer.Writer [Tasty.TestTree])+tasty :: Test.Test IO (Writer.Writer [Tasty.TestTree]) tasty = Test.MkTest { Test.assertFailure = Unit.assertFailure,