forked from futurenda/google-auth-id-token-verifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcerts_test.go
40 lines (35 loc) · 851 Bytes
/
certs_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
package googleAuthIDTokenVerifier
import (
"testing"
"time"
)
func TestGetFederatedSignonCerts(t *testing.T) {
certs, err := getFederatedSignonCerts()
if err != nil {
t.Error(err)
return
}
cacheAge := certs.Expiry.Sub(time.Now()).Seconds()
t.Logf("cacheAge: %d", cacheAge)
if cacheAge <= 7200 {
t.Error("max-age not found")
}
key := certs.Keys["9e84f33bf244380eb676d35db27a49f86d7b2235"]
if key == nil {
t.Error("9e84f33bf244380eb676d35db27a49f86d7b2235 should exists")
}
}
func TestGetFederatedSignonCertsCache(t *testing.T) {
certs = &Certs{
Expiry: time.Now(),
}
certs, err := getFederatedSignonCerts() // trigger update
if err != nil {
t.Error(err)
return
}
key := certs.Keys["9e84f33bf244380eb676d35db27a49f86d7b2235"]
if key == nil {
t.Error("9e84f33bf244380eb676d35db27a49f86d7b2235 should exists")
}
}