示例#1
0
def test_delete_token_again():
    resource_id = set_policy()

    body = {}
    body['request'] = [resource_id]
    r = consumer.get_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200

    token = r['response']['token']
    s = token.split("/")
    uuid = s[3]

    body = {'tokens': [uuid]}
    r = consumer.delete_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200

    r = consumer.view_tokens()

    for tokens in r['response']:
        assert tokens['uuid'] != uuid

    body = {'tokens': [uuid]}
    r = consumer.delete_token(body)
    assert r['success'] is False
    assert r['status_code'] == 400
示例#2
0
def test_delete_token_success():
    resource_id_1 = set_policy()
    resource_id_2 = set_policy()

    body = {}
    # get first token
    body['request'] = [resource_id_1]
    r = consumer.get_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200

    token = r['response']['token']
    s = token.split("/")
    uuid_1 = s[3]

    # get second token
    body['request'] = [resource_id_2]
    r = consumer.get_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200

    token = r['response']['token']
    s = token.split("/")
    uuid_2 = s[3]

    body = {'tokens': [uuid_1, uuid_2]}
    r = consumer.delete_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200

    r = consumer.view_tokens()

    for tokens in r['response']:
        assert tokens['uuid'] != uuid_1
        assert tokens['uuid'] != uuid_2
示例#3
0
def test_delete_token_invalid_request():
    body = {'tokens': []}
    r = consumer.delete_token(body)
    assert r['success'] is False
    assert r['status_code'] == 400

    body = {'tokens': ['12345']}
    r = consumer.delete_token(body)
    assert r['success'] is False
    assert r['status_code'] == 400

    body = {'tokens': [{'1234': 5678}]}
    r = consumer.delete_token(body)
    assert r['success'] is False
    assert r['status_code'] == 400

    body = {'tokens': [['12345']]}
    r = consumer.delete_token(body)
    assert r['success'] is False
    assert r['status_code'] == 400
示例#4
0
def test_delete_expired_token():
    resource_id = set_policy()

    body = {}
    body['request'] = [resource_id]
    r = consumer.get_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200

    token = r['response']['token']
    s = token.split("/")
    uuid = s[3]

    assert expire_token(uuid) is True

    body = {'tokens': [uuid]}
    r = consumer.delete_token(body)
    assert r['success'] is False
    assert r['status_code'] == 400
def test_deleted_token():
    resource_id = "rbccps.org/9cf2c2382cf661fc20a4776345a3be7a143a109c/rs.iudx.io/" + rand_rsg(
    )
    access_req = {
        "user_email": email,
        "user_role": 'consumer',
        "item_id": resource_id,
        "item_type": "resourcegroup",
        "capabilities": ["complex", "subscription", "temporal"]
    }
    r = provider.provider_access([access_req])
    assert r['success'] == True
    assert r['status_code'] == 200

    body = {}
    body['request'] = [resource_id]
    r = consumer.get_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200
    token = r['response']['token']

    r = resource_server.introspect_token(token)
    assert r['success'] is True
    assert r['status_code'] == 200

    s = token.split("/")
    uuid = s[3]

    body = {'tokens': [uuid]}
    r = consumer.delete_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200

    r = resource_server.introspect_token(token)
    assert r['success'] is False
    assert r['status_code'] == 403
示例#6
0
def test_delete_token_invalid_uuid():
    body = {'tokens': ['df64092c-93a9-4ec4-9e86-3ca23a7d46a7']}
    r = consumer.delete_token(body)
    assert r['success'] is False
    assert r['status_code'] == 400
示例#7
0
def test_delete_token_empty_body():
    body = {}
    r = consumer.delete_token(body)
    assert r['success'] is False
    assert r['status_code'] == 400