8
8
from cryptojwt .jws .jws import factory
9
9
from cryptojwt .jws .jws import JWS
10
10
11
- from cryptojwt .key_bundle import keybundle_from_local_file , rsa_init
11
+ from cryptojwt .key_bundle import keybundle_from_local_file
12
+ from cryptojwt .key_bundle import rsa_init
12
13
from cryptojwt .key_bundle import KeyBundle
13
- from cryptojwt .key_jar import build_keyjar , update_keyjar , key_summary , \
14
- init_key_jar
14
+ from cryptojwt .key_jar import build_keyjar
15
+ from cryptojwt .key_jar import init_key_jar
16
+ from cryptojwt .key_jar import key_summary
17
+ from cryptojwt .key_jar import update_keyjar
15
18
from cryptojwt .key_jar import KeyJar
16
19
17
20
__author__ = 'Roland Hedberg'
@@ -176,10 +179,6 @@ def full_path(local_file):
176
179
}
177
180
178
181
179
- # def test_key_setup():
180
- # x = key_setup()
181
-
182
-
183
182
def test_build_keyjar ():
184
183
keys = [
185
184
{"type" : "RSA" , "use" : ["enc" , "sig" ]},
@@ -192,17 +191,20 @@ def test_build_keyjar():
192
191
assert "d" not in key # the JWKS shouldn't contain the private part
193
192
# of the keys
194
193
195
- assert len (keyjar ["" ]) == 2 # 1 with RSA keys and 1 with EC key
194
+ assert len (keyjar ["" ]) == 1 # One key bundle
195
+ assert len (keyjar .get_issuer_keys ('' )) == 3 # A total of 3 keys
196
+ assert len (keyjar .get ('sig' )) == 2 # 2 for signing
197
+ assert len (keyjar .get ('enc' )) == 1 # 1 for encryption
196
198
197
199
198
200
def test_build_keyjar_missing (tmpdir ):
199
201
keys = [
200
202
{"type" : "RSA" , "key" : os .path .join (tmpdir .dirname , "missing_file" ),
201
203
"use" : ["enc" , "sig" ]}]
202
204
203
- keyjar = build_keyjar (keys )
205
+ key_jar = build_keyjar (keys )
204
206
205
- assert len (keyjar ["" ]) == 1
207
+ assert len (key_jar ["" ]) == 1
206
208
207
209
208
210
class TestKeyJar (object ):
@@ -289,17 +291,6 @@ def test_get_enc_not_mine(self):
289
291
290
292
assert ks .get ('enc' , 'oct' , 'http://www.example.org/' )
291
293
292
- # def test_get_by_kid(self):
293
- # kb = keybundle_from_local_file("file://%s/jwk.json" % BASE_PATH,
294
- # "jwks",
295
- # ["sig"])
296
- # kj = KeyJar()
297
- # kj.issuer_keys["https://example.com"] = [kb]
298
- #
299
- # _key = kj.get_key_by_kid("abc", "https://example.com")
300
- # assert _key
301
- # assert _key.kid == "abc"
302
-
303
294
def test_dump_issuer_keys (self ):
304
295
kb = keybundle_from_local_file ("file://%s/jwk.json" % BASE_PATH , "jwks" ,
305
296
["sig" ])
0 commit comments