From 526728eb89963f558566b4ceb3cb95e4921c0866 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sat, 8 Aug 2020 13:46:57 +0100 Subject: [PATCH] Test that an improperly encoded JWT returns a DecodeError The subject of this commit message says it all. --- website/sandbox/learnpianochords/src/server/Spec.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/sandbox/learnpianochords/src/server/Spec.hs b/website/sandbox/learnpianochords/src/server/Spec.hs index 6c683cbbf..20c7b96b9 100644 --- a/website/sandbox/learnpianochords/src/server/Spec.hs +++ b/website/sandbox/learnpianochords/src/server/Spec.hs @@ -16,6 +16,9 @@ main = hspec $ do describe "GoogleSignIn" $ describe "jwtIsValid" $ do let jwtIsValid' = GoogleSignIn.jwtIsValid True + it "returns a decode error when an incorrectly encoded JWT is used" $ do + jwtIsValid' (GoogleSignIn.EncodedJWT "rubbish") `shouldReturn` DecodeError + it "returns validation error when the aud field doesn't match my client ID" $ do let auds = ["wrong-client-id"] |> fmap TestUtils.unsafeStringOrURI