-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd7e03e
commit c83befe
Showing
5 changed files
with
112 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Feature.Auth.JwtCachingSpec where | ||
|
||
import Network.Wai (Application) | ||
|
||
import Network.HTTP.Types | ||
import Test.Hspec | ||
import Test.Hspec.Wai | ||
import Test.Hspec.Wai.JSON | ||
|
||
import Protolude hiding (get) | ||
import SpecHelper | ||
|
||
spec :: SpecWith ((), Application) | ||
spec = describe "JWT Caching" $ do | ||
let auth = authHeaderJWT "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoicG9zdGdyZXN0X3Rlc3RfYXV0aG9yIn0.Xod-F15qsGL0WhdOCr2j3DdKuTw9QJERVgoFD3vGaWA" | ||
|
||
it "jwt Cache warmup" $ | ||
request methodPost "/rpc/privileged_hello" [auth] [json|{"name": "jdoe"}|] | ||
`shouldRespondWith` [json|"Privileged hello to jdoe"|] | ||
{ matchStatus = 200 | ||
, matchHeaders = ["Server-Timing" <:> "jwt;dur=" | ||
, matchContentTypeJson] | ||
} | ||
|
||
it "JWT Cache, token should be cached at this request" $ | ||
request methodPost "/rpc/privileged_hello" [auth] [json|{"name": "jdoe"}|] | ||
`shouldRespondWith` [json|"Privileged hello to jdoe"|] | ||
{ matchStatus = 200 | ||
, matchHeaders = ["Server-Timing" <:> "jwt;dur=" | ||
, matchContentTypeJson] | ||
} | ||
|
||
it "JWT Claims should be retrieved from the cache" $ | ||
request methodPost "/rpc/privileged_hello" [auth] [json|{"name": "jdoe"}|] | ||
`shouldRespondWith` [json|"Privileged hello to jdoe"|] | ||
{ matchStatus = 200 | ||
, matchHeaders = ["Server-Timing" <:> "jwt;dur=" | ||
, matchContentTypeJson] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters