Ejemplo n.º 1
0
def test_delete_resource_set():
    uas = UmaAS()

    data = ResourceSetDescription(name="stuff", scopes=ALL).to_json()

    resp = uas.resource_set_registration_endpoint_("alice", RSR_PATH, method="POST",
                                                   body=data, owner="alice",
                                                   client_id="12345678")

    _stat = StatusResponse().from_json(resp.message)
    rsid = _stat["_id"]

    read_write = [SCOPES["read"], SCOPES["write"]]
    uas.store_permission("alice", "roger", {rsid: read_write})

    resp = uas.resource_set_registration_endpoint_("alice", RSR_PATH + rsid,
                                            method="DELETE", owner="alice",
                                            client_id="12345678")
    assert isinstance(resp, NoContent)

    resp = uas.resource_set_registration_endpoint_("alice", RSR_PATH + "/" + rsid,
                                                   method="GET", owner="alice",
                                                   client_id="12345678")
    assert isinstance(resp, NotFound)

    with pytest.raises(KeyError):
        uas.read_permission("alice", "roger", rsid)  # make sure permission is removed when rs is deleted
Ejemplo n.º 2
0
def test_delete_resource_set():
    uas = UmaAS()

    data = ResourceSetDescription(name="stuff", scopes=ALL).to_json()

    resp = uas.resource_set_registration_endpoint_(
        "alice", RSR_PATH, method="POST", body=data, owner="alice", client_id="12345678"
    )

    _stat = StatusResponse().from_json(resp.message)
    rsid = _stat["_id"]

    read_write = [SCOPES["read"], SCOPES["write"]]
    uas.store_permission("alice", "roger", {rsid: read_write})

    resp = uas.resource_set_registration_endpoint_(
        "alice", RSR_PATH + rsid, method="DELETE", owner="alice", client_id="12345678"
    )
    assert isinstance(resp, NoContent)

    resp = uas.resource_set_registration_endpoint_(
        "alice", RSR_PATH + "/" + rsid, method="GET", owner="alice", client_id="12345678"
    )
    assert isinstance(resp, NotFound)

    with pytest.raises(KeyError):
        uas.read_permission("alice", "roger", rsid)  # make sure permission is removed when rs is deleted
Ejemplo n.º 3
0
def test_inital_add():
    uas = UmaAS()

    data = ResourceSetDescription(name="stuff", scopes=ALL).to_json()

    uas.resource_set_registration_endpoint_(RSR_PATH, "PUT",
                                            body=data,
                                            owner="alice",
                                            client_id="12345678")

    read_write = [SCOPES["read"], SCOPES["write"]]
    uas.store_permission("alice", "roger", "stuff", read_write)

    scopes = uas.read_permission("alice", "roger", "stuff")

    assert _eq(scopes, read_write)
Ejemplo n.º 4
0
def test_inital_add():
    uas = UmaAS()

    data = ResourceSetDescription(name="stuff", scopes=ALL).to_json()

    resp = uas.resource_set_registration_endpoint_("alice", RSR_PATH, method="POST",
                                                   body=data, client_id="12345678",
                                                   if_match="xyzzy")
    _stat = StatusResponse().from_json(resp.message)
    rsid = _stat["_id"]

    headers = dict(resp.headers)
    assert headers["Location"] == "/{}/{}".format(RSR_PATH, rsid)

    read_write = [SCOPES["read"], SCOPES["write"]]
    uas.permission_registration_endpoint_("alice", request=PermissionRegistrationRequest(
        resource_set_id=rsid, scopes=read_write).to_json())

    uas.store_permission("alice", "roger", {rsid: read_write})

    scopes, ts = uas.read_permission("alice", "roger", rsid)

    assert _eq(scopes, read_write)
Ejemplo n.º 5
0
def test_delete_resource_set():
    uas = UmaAS()

    data = ResourceSetDescription(name="stuff", scopes=ALL).to_json()

    resp = uas.resource_set_registration_endpoint_(RSR_PATH, "PUT",
                                                   body=data, owner="alice",
                                                   client_id="12345678")

    _stat = StatusResponse().from_json(resp.message)

    read_write = [SCOPES["read"], SCOPES["write"]]
    uas.store_permission("alice", "roger", "stuff", read_write)

    dresp = uas.resource_set_registration_endpoint_(RSR_PATH+_stat["_id"],
                                                    "DELETE", owner="alice",
                                                    client_id="12345678")

    scopes = uas.read_permission("alice", "roger", "stuff")
Ejemplo n.º 6
0
def test_inital_add():
    uas = UmaAS()

    data = ResourceSetDescription(name="stuff", scopes=ALL).to_json()

    resp = uas.resource_set_registration_endpoint_(
        "alice", RSR_PATH, method="POST", body=data, client_id="12345678", if_match="xyzzy"
    )
    _stat = StatusResponse().from_json(resp.message)
    rsid = _stat["_id"]

    headers = dict(resp.headers)
    assert headers["Location"] == "/{}/{}".format(RSR_PATH, rsid)

    read_write = [SCOPES["read"], SCOPES["write"]]
    uas.permission_registration_endpoint_(
        "alice", request=PermissionRegistrationRequest(resource_set_id=rsid, scopes=read_write).to_json()
    )

    uas.store_permission("alice", "roger", {rsid: read_write})

    scopes, ts = uas.read_permission("alice", "roger", rsid)

    assert _eq(scopes, read_write)