예제 #1
0
def test_unpack_metadata_statement_uri():
    s = signer[OA['sunet']]
    req = MetadataStatement(issuer='https://example.org/op')
    # Not intermediate
    ms = s.create_signed_metadata_statement(req, 'discovery', single=True)

    jb = FSJWKSBundle('',
                      None,
                      'fo_jwks',
                      key_conv={
                          'to': quote_plus,
                          'from': unquote_plus
                      })

    mds = MetaDataStore('msd')

    op = Operator(jwks_bundle=public_jwks_bundle(jb))
    op.httpcli = MockHTTPClient(mds)
    res = op.unpack_metadata_statement(jwt_ms=ms)
    assert len(res.parsed_statement) == 3
    loel = op.evaluate_metadata_statement(res.result)
    assert len(loel) == 3
    assert set([l.fo for l in loel]) == {
        'https://swamid.sunet.se', 'https://edugain.com',
        'https://www.feide.no'
    }
예제 #2
0
def test_pack_and_unpack_ms_lev0():
    cms = ClientMetadataStatement(signing_keys=json.dumps(
        FOP.keyjar.export_jwks_as_json()),
                                  contacts=['*****@*****.**'])

    _jwt = FOP.pack_metadata_statement(cms, alg='RS256', scope=['openid'])

    assert _jwt
    json_ms = unfurl(_jwt)
    #  print(json_ms.keys())
    assert set(json_ms.keys()) == {
        'signing_keys', 'iss', 'iat', 'exp', 'kid', 'scope', 'contacts', 'aud'
    }

    # Unpack what you have packed
    _kj = public_keys_keyjar(FOP.keyjar, '', None, FOP.iss)
    op = Operator(_kj, jwks_bundle=public_jwks_bundle(FOP.jwks_bundle))
    pr = op.unpack_metadata_statement(jwt_ms=_jwt)

    assert pr.result