]> gitweb.factorcode.org Git - factor.git/blob - basis/furnace/auth/providers/db/db-tests.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / basis / furnace / auth / providers / db / db-tests.factor
1 USING: furnace.actions
2 furnace.auth
3 furnace.auth.login
4 furnace.auth.providers
5 furnace.auth.providers.db tools.test
6 namespaces db db.sqlite db.tuples continuations
7 io.files io.files.temp io.directories accessors kernel
8 sequences system ;
9 IN: furnace.auth.providers.db.tests
10
11 <action> "test" <login-realm> realm set
12
13 : auth-test-db-name ( -- string )
14     cpu name>> "auth-test." ".db" surround ;
15
16 [ auth-test-db-name temp-file delete-file ] ignore-errors
17
18 auth-test-db-name temp-file <sqlite-db> [
19
20     user ensure-table
21
22     [ t ] [
23         "slava" <user>
24             "foobar" >>encoded-password
25             "slava@factorcode.org" >>email
26             H{ } clone >>profile
27             users new-user
28             username>> "slava" =
29     ] unit-test
30
31     [ f ] [
32         "slava" <user>
33             H{ } clone >>profile
34         users new-user
35     ] unit-test
36
37     [ f ] [ "fdasf" "slava" check-login >boolean ] unit-test
38
39     [ ] [ "foobar" "slava" check-login "user" set ] unit-test
40
41     [ t ] [ "user" get >boolean ] unit-test
42
43     [ ] [ "user" get "fdasf" >>encoded-password drop ] unit-test
44
45     [ ] [ "user" get users update-user ] unit-test
46
47     [ t ] [ "fdasf" "slava" check-login >boolean ] unit-test
48
49     [ f ] [ "foobar" "slava" check-login >boolean ] unit-test
50 ] with-db