keypairs/fetch_test.go

43 lines
894 B
Go
Raw Normal View History

2019-02-08 01:26:45 +00:00
package keypairs
import (
"crypto/ecdsa"
"crypto/rsa"
"errors"
"testing"
)
func TestFetchOIDCPublicKeys(t *testing.T) {
urls := []string{
//"https://bigsquid.auth0.com/.well-known/jwks.json",
"https://bigsquid.auth0.com/",
"https://api-dev.bigsquid.com/",
}
for i := range urls {
url := urls[i]
2019-02-19 23:50:46 +00:00
_, keys, err := fetchOIDCPublicKeys(url)
2019-02-08 01:26:45 +00:00
if nil != err {
t.Fatal(url, err)
}
2019-02-08 23:53:29 +00:00
for kid := range keys {
switch key := keys[kid].Key().(type) {
2019-02-08 01:26:45 +00:00
case *rsa.PublicKey:
_ = ThumbprintRSAPublicKey(key)
case *ecdsa.PublicKey:
_ = ThumbprintECPublicKey(key)
default:
t.Fatal(errors.New("unsupported interface type"))
}
}
}
}
2019-02-19 23:50:46 +00:00
func TestCachesKey(t *testing.T) {
// Raw fetch a key and get KID and Thumbprint
// Look in cache for each (and fail)
// Get with caching
// Look in cache for each (and succeed)
// Get again (should be sub-ms instant)
}