-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_test.go
106 lines (79 loc) · 1.98 KB
/
utils_test.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package main
import (
"strings"
"testing"
)
func TestMakeToken(t *testing.T) {
token, _ := makeToken("415", true)
if token == "" {
t.Errorf("Expected token to be generated")
}
parts := strings.Split(token, ".")
if len(parts) != 3 {
t.Errorf("Expected token to have 3 parts")
}
}
func TestMakeAdminToken(t *testing.T) {
token, _ := makeToken("415", true, "ADMIN")
if token == "" {
t.Errorf("Expected token to be generated")
}
parts := strings.Split(token, ".")
if len(parts) != 3 {
t.Errorf("Expected token to have 3 parts")
}
}
func TestBureauJwt(t *testing.T) {
claims := Claims{}
bureauJwt(&claims)
if claims.Owner != "400" {
t.Errorf("Expected owner to be 400")
}
if claims.Login != "bureau-lead" {
t.Errorf("Expected login to be bureau-lead")
}
if claims.UserType != "BUREAU" {
t.Errorf("Expected user type to be BUREAU")
}
if claims.ActiveUserType != "BUREAU" {
t.Errorf("Expected active user type to be BUREAU")
}
if claims.Staff.Name != "bureau-lead" {
t.Errorf("Expected staff name to be bureau-lead")
}
if claims.LocCode != "400" {
t.Errorf("Expected loc code to be 400")
}
}
func TestCourtJwt(t *testing.T) {
claims := Claims{}
courtJwt(&claims, "415")
if claims.Owner != "415" {
t.Errorf("Expected owner to be 415")
}
if claims.Login != "court-manager" {
t.Errorf("Expected login to be court-manager")
}
if claims.UserType != "COURT" {
t.Errorf("Expected user type to be COURT")
}
if claims.Staff.Name != "court-manager" {
t.Errorf("Expected staff name to be court-manager")
}
if claims.LocCode != "415" {
t.Errorf("Expected loc code to be 415")
}
}
func TestGeneratePoolNumber(t *testing.T) {
locCode := "415"
poolNumber, _ := generatePoolNumber(locCode)
if poolNumber == "" {
t.Errorf("Expected pool number to be generated")
}
if len(poolNumber) != 9 {
t.Errorf("Expected pool number to be 9 characters")
}
if poolNumber[:3] != locCode {
t.Errorf("Expected pool number to start with location code")
}
}