-
Notifications
You must be signed in to change notification settings - Fork 3
/
session_test.go
45 lines (40 loc) · 995 Bytes
/
session_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
package gcs
import (
"testing"
"time"
)
func TestValidSessionObject(t *testing.T) {
ts := time.Now()
session := &Session{
CreatedTimed: &ts,
ExpirationTime: &ts,
IssuerDetails: "1",
MultiFactorAuthentication: true,
UUID: "123",
UniqueID: "234",
UserCredentialID: "456",
}
_, err := ValidateSession(session)
if err != nil {
t.Fatalf("Session object should have been valid: %v", err)
}
}
func BenchmarkValidSessionObject(b *testing.B) {
b.ReportAllocs()
ts := time.Now()
session := &Session{
CreatedTimed: &ts,
ExpirationTime: &ts,
IssuerDetails: "1",
MultiFactorAuthentication: true,
UUID: "123",
UniqueID: "234",
UserCredentialID: "456",
}
for n := 0; n < b.N; n++ {
_, err := ValidateSession(session)
if err != nil {
b.Fatalf("Session object is invalid: %v", err)
}
}
}