示例#1
0
def test_loads_1():
    jwks = {
        "keys": [
            {
                "kty": "RSA",
                "use": "sig",
                "e": "AQAB",
                "n":
                "wf-wiusGhA-gleZYQAOPQlNUIucPiqXdPVyieDqQbXXOPBe3nuggtVzeq7pVFH1dZz4dY2Q2LA5DaegvP8kRvoSB_87ds3dy3Rfym_GUSc5B0l1TgEobcyaep8jguRoHto6GWHfCfKqoUYZq4N8vh4LLMQwLR6zi6Jtu82nB5k8",
                "kid": "1",
            },
            {
                "kty": "RSA",
                "use": "enc",
                "e": "AQAB",
                "n":
                "wf-wiusGhA-gleZYQAOPQlNUIucPiqXdPVyieDqQbXXOPBe3nuggtVzeq7pVFH1dZz4dY2Q2LA5DaegvP8kRvoSB_87ds3dy3Rfym_GUSc5B0l1TgEobcyaep8jguRoHto6GWHfCfKqoUYZq4N8vh4LLMQwLR6zi6Jtu82nB5k8",
                "kid": "2",
            },
        ]
    }

    kb = KeyBundle(jwks)

    assert len(kb) == 2
    assert set(kb.kids()) == {"1", "2"}
示例#2
0
def test_loads_1():
    jwks = {
        "keys": [
            {
                'kty': 'RSA',
                'use': 'sig',
                'e': 'AQAB',
                "n":
                    'wf-wiusGhA-gleZYQAOPQlNUIucPiqXdPVyieDqQbXXOPBe3nuggtVzeq7pVFH1dZz4dY2Q2LA5DaegvP8kRvoSB_87ds3dy3Rfym_GUSc5B0l1TgEobcyaep8jguRoHto6GWHfCfKqoUYZq4N8vh4LLMQwLR6zi6Jtu82nB5k8',
                'kid': "1"
            }, {
                'kty': 'RSA',
                'use': 'enc',
                'e': 'AQAB',
                "n":
                    'wf-wiusGhA-gleZYQAOPQlNUIucPiqXdPVyieDqQbXXOPBe3nuggtVzeq7pVFH1dZz4dY2Q2LA5DaegvP8kRvoSB_87ds3dy3Rfym_GUSc5B0l1TgEobcyaep8jguRoHto6GWHfCfKqoUYZq4N8vh4LLMQwLR6zi6Jtu82nB5k8',
                'kid': "2"
            }
        ]
    }

    kb = KeyBundle(jwks)

    assert len(kb) == 2
    assert set(kb.kids()) == {'1', '2'}
示例#3
0
def test_with_2_sym_key():
    a = {"kty": "oct", "key": "highestsupersecret", "use": "sig"}
    b = {"kty": "oct", "key": "highestsupersecret", "use": "enc"}
    kb = KeyBundle([a, b])
    assert len(kb.get("oct")) == 2
    assert len(kb) == 2

    assert kb.get_key_with_kid("kid") is None
    assert len(kb.kids()) == 2