about summary refs log tree commit diff
path: root/website/sandbox/learnpianochords/src/server/TestUtils.hs
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-08-08T12·44+0100
committerWilliam Carroll <wpcarro@gmail.com>2020-08-08T12·44+0100
commitd34b146702476f46bcca7d362e56f46227863f1b (patch)
tree6ad489c4509172780f578df9d66602a1c6a6272f /website/sandbox/learnpianochords/src/server/TestUtils.hs
parent926d8e643e9ffb7d5f5608793d35381742675073 (diff)
Tests valid and invalid JWTs for the "aud" field
Test that when the JWT contains the client ID for my Google app, the JWT is
valid, and when it doesn't, it's invalid.
Diffstat (limited to 'website/sandbox/learnpianochords/src/server/TestUtils.hs')
-rw-r--r--website/sandbox/learnpianochords/src/server/TestUtils.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/website/sandbox/learnpianochords/src/server/TestUtils.hs b/website/sandbox/learnpianochords/src/server/TestUtils.hs
new file mode 100644
index 0000000000..c586f7f219
--- /dev/null
+++ b/website/sandbox/learnpianochords/src/server/TestUtils.hs
@@ -0,0 +1,12 @@
+--------------------------------------------------------------------------------
+module TestUtils where
+--------------------------------------------------------------------------------
+import Web.JWT
+import Data.String.Conversions (cs)
+--------------------------------------------------------------------------------
+
+unsafeStringOrURI :: String -> StringOrURI
+unsafeStringOrURI x =
+  case stringOrURI (cs x) of
+    Nothing -> error $ "Failed to convert to StringOrURI: " ++ x
+    Just x  -> x