Пример #1
0
def test_2():
    owner = DB_NAME
    client_id = "http://xenosmilus2.umdc.umu.se:8089/foo"
    collection = safe_name("%s:%s" % (owner, client_id))
    authz_db = AuthzDB(AuthzDescription, "uma_idm", collection)
    authz_db.restart(collection)
Пример #2
0
def test_1():
    authz_db = AuthzDB(AuthzDescription, DB_NAME, COLLECTION)
    authz_db.restart(COLLECTION)

    rsd = AuthzDescription(
        resource_set_id="https://idp.catalogix.se/id/[email protected]",
        entity="https://lingon.ladok.umu.se:8087/sp.xml",
        scopes=[
            "%s/givenName/Roland" % ATTR,
            "%s/surName/Hedberg" % ATTR,
            "%s/displayName/Roland%%20Hedberg" % ATTR,
            "%s/cn/Roland%%20Hedberg" % ATTR,
            "%s/eduPersonScopedAffiliation/[email protected]" % ATTR,
            "%s/eduPersonScopedAffiliation/[email protected]" % ATTR,
            "%s/eduPersonScopedAffiliation/[email protected]" % ATTR
        ],
    )

    rid = authz_db.store(rsd.to_json())

    item = authz_db.read(rid)

    assert item
    assert isinstance(item, AuthzDescription)
    for key, val in list(rsd.items()):
        assert key in item
        assert item[key] == val

    try:
        authz_db.read("phoney")
        assert False
    except UnknownObject:
        pass
    except BSONError:
        pass

    res = authz_db.match(
        resource_set_id="https://idp.catalogix.se/id/[email protected]",
        entity="https://lingon.ladok.umu.se:8087/sp.xml")

    assert res

    res = authz_db.match(
        resource_set_id="https://idp.catalogix.se/id/[email protected]",
        entity="https://lingon.ladok.umu.se:8087/sp.xml",
        scopes=["%s/givenName/Roland" % ATTR])

    assert res

    res = authz_db.match(
        resource_set_id="https://idp.catalogix.se/id/[email protected]",
        entity="https://lingon.ladok.umu.se:8087/sp.xml",
        scopes=["%s/sn/Magnusson" % ATTR])

    assert res is False

    res = authz_db.match(
        resource_set_id="https://idp.catalogix.se/id/[email protected]",
        entity="https://lingon.catalogix.se:8087/sp.xml")

    assert res is False