about summary refs log tree commit diff
path: root/website/sandbox/learnpianochords/src/server/Spec.hs
blob: 69add52618361efd409b1a370a632a96fb18bf74 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{-# LANGUAGE OverloadedStrings #-}
--------------------------------------------------------------------------------
module Spec where
--------------------------------------------------------------------------------
import Test.Hspec
import Web.JWT
import Utils

import qualified GoogleSignIn
import qualified Fixtures as F
--------------------------------------------------------------------------------

main :: IO ()
main = hspec $ do
  describe "GoogleSignIn" $ do
    describe "jwtIsValid" $ do
      it "returns false when the signature is invalid" $ do
        let mJWT = F.defaultJWTFields { F.overwriteSigner = hmacSecret "wrong" }
                   |> F.googleJWT
        case mJWT of
          Nothing -> True == False
          Just jwt -> GoogleSignIn.jwtIsValid jwt == False

      it "returns false when the aud field doesn't match my client ID" $ do
        let mJWT = F.defaultJWTFields { F.overwriteAud = stringOrURI "wrong" }
                  |> F.googleJWT
        case mJWT of
          Nothing -> True == False
          Just jwt -> GoogleSignIn.jwtIsValid jwt == False