def test_dump_load():
    jb = JWKSBundle('iss')
    for iss, op in OPERATOR.items():
        jb[op.iss] = op.keyjar

    bs = jb.dumps()

    receiver = JWKSBundle('')
    receiver.loads(bs)

    assert len(receiver.keys()) == 4
    assert set(receiver.keys()) == set([op.iss for op in OPERATOR.values()])
Example #2
0
    def import_from_bundle(self, uri, sign_key):
        _jb = {}
        p = urlparse(uri)
        if p[0] == 'file':
            jwks_bundle = open(p.path, 'r').read()
            _jb = JWKSBundle('', sign_keys=sign_key)
            _jb.loads(jwks_bundle)
        elif p[0] in ['http', 'https']:
            r = self.httpcli.http_request(uri)
            if r.status == 200:
                _jb = JWKSBundle('', sign_keys=sign_key)
                _jb.loads(r.text)
        else:
            raise ValueError('Unsupported scheme')

        if self.fo_keyjar:
            kj = self.fo_keyjar
        else:
            kj = KeyJar()

        for iss, ikj in _jb.items():
            kj.issuer_keys[iss] = ikj.issuer_keys['']