-
Notifications
You must be signed in to change notification settings - Fork 1
/
authorization_rules_test.clj
42 lines (40 loc) · 1.85 KB
/
authorization_rules_test.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(ns clanhr.auth.authorization-rules-test
(:require [result.core :as result]
[clanhr.auth.authorization-rules :as authorization-rules])
(:use clojure.test
ring.mock.request))
(deftest authorization-rules-test
(testing "has access"
(is (result/succeeded?
(authorization-rules/run :notifications-access ["admin"])))
(is (result/succeeded?
(authorization-rules/run :notifications-access ["hrmanager"])))
(is (result/succeeded?
(authorization-rules/run :notifications-access ["manager"])))
(is (result/succeeded?
(authorization-rules/run :notifications-access ["hrmanager" "manager"])))
(is (result/succeeded?
(authorization-rules/run :notifications-access ["admin" "manager"])))
(is (result/succeeded?
(authorization-rules/run :notifications-access nil)))
(is (result/succeeded?
(authorization-rules/run :notifications-access "")))
(is (result/succeeded?
(authorization-rules/run :notifications-access ["admin" "hrmanager"])))
(is (result/succeeded?
(authorization-rules/run :deactivate-user ["admin" "hrmanager"])))
(is (result/succeeded?
(authorization-rules/run :change-expense-state ["expensesManager"])))
(is (result/succeeded?
(authorization-rules/run :can-auto-approve-expenses ["expensesManager"])))
(is (result/succeeded?
(authorization-rules/run :reports-access ["absencesManager"]))))
(testing "do not have access"
(is (result/forbidden?
(authorization-rules/run :notifications-access ["bubu-role"])))
(is (result/forbidden?
(authorization-rules/run :reports-access nil)))
(is (result/forbidden?
(authorization-rules/run :reports-access "")))
(is (result/forbidden?
(authorization-rules/run :deactivate-user ["manager" "" nil])))))