summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2017-12-16 18:00:36 +0000
committerdakkar <dakkar@thenautilus.net>2017-12-16 18:00:36 +0000
commit6a3b3f916eee0d757bd52a690bc398fe01a1dc9c (patch)
treef0a69eaa9553e4c2ff7cbe0be9e9a7fe0e0ee389 /t
parentignore file (diff)
downloadUltramarine-6a3b3f916eee0d757bd52a690bc398fe01a1dc9c.tar.gz
Ultramarine-6a3b3f916eee0d757bd52a690bc398fe01a1dc9c.tar.bz2
Ultramarine-6a3b3f916eee0d757bd52a690bc398fe01a1dc9c.zip
users model
Diffstat (limited to 't')
-rw-r--r--t/tests/model/users.t46
1 files changed, 46 insertions, 0 deletions
diff --git a/t/tests/model/users.t b/t/tests/model/users.t
new file mode 100644
index 0000000..1518831
--- /dev/null
+++ b/t/tests/model/users.t
@@ -0,0 +1,46 @@
+use v6.d.PREVIEW;
+use Test;
+use Ultramarine::Model::Users;
+
+my $u = Ultramarine::Model::Users.new(accounts => { me => 'sesame' });
+
+nok(
+ $u.authenticate(:user<me>,:password<bad>),
+ 'bad password should fail',
+);
+
+nok(
+ $u.authenticate(:user<not-there>,:password<bad>),
+ 'bad username should fail',
+);
+
+ok(
+ $u.authenticate(:user<me>,:password<sesame>),
+ 'plaintext should work',
+);
+
+ok(
+ $u.authenticate(:user<me>,:password<enc:736573616d65>),
+ 'hex-encoded should work',
+);
+
+nok(
+ $u.authenticate(:user<me>,:password<enc:736573616d64>),
+ 'bad hex-encoded should fail',
+);
+
+ok(
+ $u.authenticate(:user<me>,:token<26719a1196d2a940705a59634eb18eab>,
+ :salt<c19b2d>),
+ 'salted hash should work',
+);
+
+nok(
+ $u.authenticate(:user<me>,:token<26719a1196d2a940705a59634eb18eab>,
+ :salt<c19b2c>),
+ 'bad salted hash should work',
+);
+
+done-testing;
+
+