-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken_test.go
More file actions
45 lines (39 loc) · 1.19 KB
/
token_test.go
File metadata and controls
45 lines (39 loc) · 1.19 KB
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
package main
import "testing"
func TestTokenNameIsTempus(t *testing.T) {
token := &Token{User: 1, Scenario: "email", Token: "hello_world"}
key := token.Key()
if key != "tempus_hello_world" {
t.Fatalf("Unexpected token name: %s", key)
t.FailNow()
}
}
func TestTokenImplementsBinaryMarshaler(t *testing.T) {
token := &Token{User: 1, Scenario: "email", Token: "hello_world"}
_, err := token.MarshalBinary()
if err != nil {
t.Fatalf("Error %s", err.Error())
t.FailNow()
}
}
func TestPasswordTokenSetsExpiry(t *testing.T) {
token := &Token{User: 1, Scenario: "password", Token: "hello_world"}
if token.Expires() != PASSWORD {
t.Fatalf("Error: Token does not expire %d != %d", token.Expires(), PASSWORD)
t.FailNow()
}
}
func TestEmailTokenSetsExpiry(t *testing.T) {
token := &Token{User: 1, Scenario: "email", Token: "hello_world"}
if token.Expires() != EMAIL {
t.Fatalf("Error: Token does not expire %d != %d", token.Expires(), EMAIL)
t.FailNow()
}
}
func TestRobotTokenSetsExpiry(t *testing.T) {
token := &Token{User: 0, Scenario: "robot", Token: "hello_world"}
if token.Expires() != ROBOT {
t.Fatalf("Error: Token does not expire %d != %d", token.Expires(), ROBOT)
t.FailNow()
}
}