diff options
| author | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-11-04 22:53:47 +0100 |
|---|---|---|
| committer | Arnaud Bailly <arnaud@pankzsoft.com> | 2025-11-05 06:03:37 +0100 |
| commit | 4240c90039e78bde98fcc3e0e27bad5d2c771bae (patch) | |
| tree | 551435bb76cf1463f85cac102a1290790de2633e /lambda-calcul/haskell/test/Minilang | |
| parent | 8a2727a05e0b61d300bb46e8e913c9e60ebd6328 (diff) | |
| download | lambda-nantes-4240c90039e78bde98fcc3e0e27bad5d2c771bae.tar.gz | |
post correct challenge response
Diffstat (limited to 'lambda-calcul/haskell/test/Minilang')
| -rw-r--r-- | lambda-calcul/haskell/test/Minilang/ServerSpec.hs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lambda-calcul/haskell/test/Minilang/ServerSpec.hs b/lambda-calcul/haskell/test/Minilang/ServerSpec.hs index a7926d3..544d0b7 100644 --- a/lambda-calcul/haskell/test/Minilang/ServerSpec.hs +++ b/lambda-calcul/haskell/test/Minilang/ServerSpec.hs @@ -57,7 +57,7 @@ spec = with (app testSeed) $ do `shouldRespondWith` 400 it "GET /api/challenge returns next challenge given user is registered" $ do - let expected = encode $ Challenge {level = 1, expr = "x"} + let expected = encode $ Challenge {level = 0, expr = "x"} postJSON "/api/register" alice `shouldRespondWith` 201 @@ -70,6 +70,17 @@ spec = with (app testSeed) $ do else Just ("Expected challenge " ++ show expected ++ ", but got " ++ show b) } + it "GET /api/challenge returns 400 given user is not registered" $ + get ("/api/challenge?token=" <> LBS.toStrict token) + `shouldRespondWith` 400 + + it "POST /api/challenge returns 200 given challenge response is correct" $ do + let response = "\"x\"" + void $ postJSON "/api/register" alice + + postJSON ("/api/challenge?token=" <> LBS.toStrict token) response + `shouldRespondWith` 200 + postJSON :: BS.ByteString -> ByteString -> WaiSession () SResponse postJSON url = request "POST" url [("Content-Type", "application/json")] |
