-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproject_test.go
61 lines (51 loc) · 1.39 KB
/
project_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
package authen
import (
"testing"
"time"
"src.goblgobl.com/authen/tests"
"src.goblgobl.com/tests/assert"
)
func Test_Project_NextRequestId(t *testing.T) {
seen := make(map[string]struct{}, 60)
p := Project{requestId: 1}
for i := 0; i < 20; i++ {
seen[p.NextRequestId()] = struct{}{}
}
p = Project{requestId: 100}
for i := 0; i < 20; i++ {
seen[p.NextRequestId()] = struct{}{}
}
Config.InstanceId += 1
p = Project{requestId: 1}
for i := 0; i < 20; i++ {
seen[p.NextRequestId()] = struct{}{}
}
assert.Equal(t, len(seen), 60)
}
func Test_Projects_Get_Unknown(t *testing.T) {
p, err := Projects.Get("6429C13A-DBB2-4FF2-ADDA-571C601B91E6")
assert.Nil(t, p)
assert.Nil(t, err)
}
func Test_Projects_Get_Known(t *testing.T) {
row := tests.Factory.Project.Insert(
"totp_issuer", "testing.goblgobl.com",
"totp_max", 76,
"totp_setup_ttl", 277,
"totp_secret_length", 19,
"ticket_max", 49,
"ticket_max_payload_length", 149,
)
id := row.String("id")
p, err := Projects.Get(id)
assert.Nil(t, err)
assert.Equal(t, p.Id, id)
assert.Equal(t, p.TOTPMax, 76)
assert.Equal(t, p.TOTPSetupTTL, 277*time.Second)
assert.Equal(t, p.TOTPSecretLength, 19)
assert.Nowish(t, time.Unix(int64(p.requestId), 0))
assert.Equal(t, string(p.logField.KV()), "pid="+id)
assert.Equal(t, p.TOTPIssuer, "testing.goblgobl.com")
assert.Equal(t, p.TicketMax, 49)
assert.Equal(t, p.TicketMaxPayloadLength, 149)
}