Skip to content

Commit

Permalink
fix key-set tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scentless-apprentice committed Aug 25, 2020
1 parent cc28b8e commit 5d09718
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions auth/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestResuseKeySource(t *testing.T) {
nextKeys := PublicKeySet{
Expiry: testTime.Add(2 * time.Second),
Keys: map[string]*rsa.PublicKey{
"8289d54280b76712de41cd2ef95972b123be9ac0": &rsa.PublicKey{N: testGoogle2, E: 65537},
"8289d54280b76712de41cd2ef95972b123be9ac0": &rsa.PublicKey{N: testGoogle(testGoogleKey2), E: 65537},
},
}

Expand Down Expand Up @@ -104,8 +104,8 @@ func TestKeySetFromURL(t *testing.T) {
wantKeys: PublicKeySet{
Expiry: testTime.Add(1 * time.Second),
Keys: map[string]*rsa.PublicKey{
"728f4016652079b9ed99861bb09bafc5a45baa86": &rsa.PublicKey{N: testGoogle1, E: 65537},
"8289d54280b76712de41cd2ef95972b123be9ac0": &rsa.PublicKey{N: testGoogle2, E: 65537},
"728f4016652079b9ed99861bb09bafc5a45baa86": {N: testGoogle(testGoogleKey1), E: 65537},
"8289d54280b76712de41cd2ef95972b123be9ac0": {N: testGoogle(testGoogleKey2), E: 65537},
},
},
},
Expand All @@ -117,8 +117,8 @@ func TestKeySetFromURL(t *testing.T) {
wantKeys: PublicKeySet{
Expiry: testTime.Add(5 * time.Second),
Keys: map[string]*rsa.PublicKey{
"728f4016652079b9ed99861bb09bafc5a45baa86": &rsa.PublicKey{N: testGoogle1, E: 65537},
"8289d54280b76712de41cd2ef95972b123be9ac0": &rsa.PublicKey{N: testGoogle2, E: 65537},
"728f4016652079b9ed99861bb09bafc5a45baa86": {N: testGoogle(testGoogleKey1), E: 65537},
"8289d54280b76712de41cd2ef95972b123be9ac0": {N: testGoogle(testGoogleKey2), E: 65537},
},
},
},
Expand All @@ -145,8 +145,8 @@ func TestKeySetFromURL(t *testing.T) {
wantKeys: PublicKeySet{
Expiry: testTime.Add(5 * time.Second),
Keys: map[string]*rsa.PublicKey{
"728f4016652079b9ed99861bb09bafc5a45baa86": &rsa.PublicKey{N: testGoogle1, E: 65537},
"8289d54280b76712de41cd2ef95972b123be9ac0": &rsa.PublicKey{N: testGoogle2, E: 65537},
"728f4016652079b9ed99861bb09bafc5a45baa86": {N: testGoogle(testGoogleKey1), E: 65537},
"8289d54280b76712de41cd2ef95972b123be9ac0": {N: testGoogle(testGoogleKey2), E: 65537},
},
},
},
Expand Down Expand Up @@ -181,20 +181,18 @@ func TestKeySetFromURL(t *testing.T) {
}

var (
testGoogleKey1 = "18112684417237113466774220553948287658642275536612278117358654328223325254239855900914880208928002193971790755769647369251185307648390933383803629253833792935549104394492595490970480288704258432536877269087694080352968836583401030682357884420432445619092471675752640354212779048186101852385524325549753366939320751885000360016238872619721767196169731422128756698973826778639560486979276112061913581353475855995717107174242233057925781337843224898645582603363390951368105740797845693907662079988391116580563176804122832211438500322243675724500523751141979116987975024595515232643410130766424608026731615327022863391377"
testGoogleKey2 = "22433090823316839640339489484457787676134304275873755218133861343920545237994470293495919014803004482856016084553850209153845425382613518932089311310596313310600424737736088033780907099977873221447195709312051528384355479077579673777886481089832045696620374920724411025483234264634539593436130076854768802102666090698524255278976644754677212286402099970599598264338136458077064875129043902522602870213617296706363155049264877048351659848686562003749244021217935734825983116131356048732262346697829165992404416525006735905763408678841171079087251498194471555953631250995421460080193870950448459655537601409828979901677"
testGoogle1 = func() *big.Int {
b := big.NewInt(0)
b.SetBytes([]byte(testGoogleKey1))
return b
}()
testGoogle2 = func() *big.Int {
b := big.NewInt(0)
b.SetBytes([]byte(testGoogleKey2))
return b
}()
testGoogleKey1 = "22433090823316839640339489484457787676134304275873755218133861343920545237994470293495919014803004482856016084553850209153845425382613518932089311310596313310600424737736088033780907099977873221447195709312051528384355479077579673777886481089832045696620374920724411025483234264634539593436130076854768802102666090698524255278976644754677212286402099970599598264338136458077064875129043902522602870213617296706363155049264877048351659848686562003749244021217935734825983116131356048732262346697829165992404416525006735905763408678841171079087251498194471555953631250995421460080193870950448459655537601409828979901677"
testGoogleKey2 = "18112684417237113466774220553948287658642275536612278117358654328223325254239855900914880208928002193971790755769647369251185307648390933383803629253833792935549104394492595490970480288704258432536877269087694080352968836583401030682357884420432445619092471675752640354212779048186101852385524325549753366939320751885000360016238872619721767196169731422128756698973826778639560486979276112061913581353475855995717107174242233057925781337843224898645582603363390951368105740797845693907662079988391116580563176804122832211438500322243675724500523751141979116987975024595515232643410130766424608026731615327022863391377"
)

func testGoogle(testKey string) *big.Int {
i, ok := new(big.Int).SetString(testKey, 10)
if !ok {
panic("bad number: " + testKey)
}
return i
}

const testGoogleCerts = `{
"keys": [
{
Expand Down

0 comments on commit 5d09718

Please sign in to comment.