From f1883b279037375c66cf683b7392652624381c59 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sat, 8 Aug 2020 14:08:11 +0100 Subject: Test that the JWT's iss field meets our expectations The JWT should match "accounts.google.com" or "https://accounts.google.com". If it doesn't, we produce a validation error. TL;DR: - Group all failed stringOrURI function calls as StringOrURIParseFailure errors --- website/sandbox/learnpianochords/src/server/Spec.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'website/sandbox/learnpianochords/src/server/Spec.hs') diff --git a/website/sandbox/learnpianochords/src/server/Spec.hs b/website/sandbox/learnpianochords/src/server/Spec.hs index 20c7b96b952f..96f10a9c4332 100644 --- a/website/sandbox/learnpianochords/src/server/Spec.hs +++ b/website/sandbox/learnpianochords/src/server/Spec.hs @@ -32,3 +32,15 @@ main = hspec $ do encodedJWT = F.defaultJWTFields { F.overwriteAuds = auds } |> F.googleJWT jwtIsValid' encodedJWT `shouldReturn` Valid + + it "returns validation error when one of the iss field doesn't match accounts.google.com or https://accounts.google.com" $ do + let erroneousIssuer = TestUtils.unsafeStringOrURI "not-accounts.google.com" + encodedJWT = F.defaultJWTFields { F.overwriteIss = erroneousIssuer } + |> F.googleJWT + jwtIsValid' encodedJWT `shouldReturn` WrongIssuer erroneousIssuer + + it "returns validation success when the iss field matches accounts.google.com or https://accounts.google.com" $ do + let erroneousIssuer = TestUtils.unsafeStringOrURI "https://accounts.google.com" + encodedJWT = F.defaultJWTFields { F.overwriteIss = erroneousIssuer } + |> F.googleJWT + jwtIsValid' encodedJWT `shouldReturn` Valid -- cgit 1.4.1