Ejemplo n.º 1
0
def test_delete_ingester_temporal():
    global ingester_id, consumer_id

    token_body = {
        "id": diresource_id + "/someitem/someotheritem",
        "api": "/iudx/v1/adapter"
    }
    r = consumer.get_token(token_body)
    assert r['success'] is True

    token_body = {
        "id": resource_id + "/something",
        "apis": ["/ngsi-ld/v1/temporal/entities"]
    }
    r = consumer.get_token(token_body)
    assert r['success'] is True

    body = [{
        "id": ingester_id
    }, {
        "id": consumer_id,
        "capabilities": ["temporal"]
    }]
    r = untrusted.delete_rule(body)
    assert r['success'] == True
    assert r['status_code'] == 200

    token_body = {
        "id": diresource_id + "/someitem/someotheritem",
        "api": "/iudx/v1/adapter"
    }
    r = consumer.get_token(token_body)
    assert r['success'] is False

    token_body = {
        "id": resource_id + "/something",
        "apis": ["/ngsi-ld/v1/temporal/entities"]
    }
    r = consumer.get_token(token_body)
    assert r['success'] is False

    body = [{
        "id": ingester_id
    }, {
        "id": consumer_id,
        "capabilities": ["temporal"]
    }]
    r = untrusted.delete_rule(body)
    assert r['success'] == False
    assert r['status_code'] == 403
def test_deleted_delegate():
    # provider deletes delegate

    global consumer_id

    r = untrusted.delete_rule([{"id": delegate_id}])
    assert r['success'] == True
    assert r['status_code'] == 200

    # deleted delegate cannot do anything
    req = {
        "user_email": email,
        "user_role": 'consumer',
        "item_id": resource_id,
        "item_type": "resourcegroup"
    }
    req["capabilities"] = ['complex']
    r = alt_provider.provider_access([req], '*****@*****.**')
    assert r['success'] == False
    assert r['status_code'] == 401

    r = alt_provider.get_provider_access('*****@*****.**')
    assert r['success'] == False
    assert r['status_code'] == 401

    body = {"id": consumer_id}
    r = alt_provider.delete_rule([body], '*****@*****.**')
    assert r['success'] == False
    assert r['status_code'] == 401
Ejemplo n.º 3
0
def test_delete_consumer_rule():
    global consumer_id

    body = {"request": [resource_id + "/something"]}
    r = consumer.get_token(body)
    assert r['success'] is True

    check = False
    r = consumer.view_consumer_resources()
    assert r['success'] == True
    assert r['status_code'] == 200

    for i in r['response']:
        if resource_id == i['cat_id']:
            assert len(i['capabilities']) > 1
            check = True

    assert check is True

    # temporal already deleted
    body = [{
        "id": consumer_id,
        "capabilities": ["temporal", "subscription", "complex"]
    }]
    r = untrusted.delete_rule(body)
    assert r['success'] == False
    assert r['status_code'] == 403

    body = {"request": [resource_id + "/something"]}
    r = consumer.get_token(body)
    assert r['success'] is True

    body = [{"id": consumer_id}]
    r = untrusted.delete_rule(body)
    assert r['success'] == True
    assert r['status_code'] == 200

    # delete again
    body = [{"id": consumer_id}]
    r = untrusted.delete_rule(body)
    assert r['success'] == False
    assert r['status_code'] == 403

    body = {"request": [resource_id + "/something"]}
    r = consumer.get_token(body)
    assert r['success'] is False
    assert r['status_code'] == 403
def test_provider_delete_rule_set_by_delegate():
    # provider can delete rules set by delegate
    r = untrusted.delete_rule([{"id": ingester_id}])
    assert r['success'] == True
    assert r['status_code'] == 200

    r = alt_provider.delete_rule([{"id": ingester_id}], '*****@*****.**')
    assert r['success'] == False
    assert r['status_code'] == 403
Ejemplo n.º 5
0
def test_delete_consumer_rule():
    global consumer_id

    apis = [
        "/ngsi-ld/v1/entityOperations/query", "/ngsi-ld/v1/entities",
        "/ngsi-ld/v1/entities/" + resource_id, "/ngsi-ld/v1/subscription"
    ]
    token_body = {"id": resource_id + "/someitem", "apis": apis}
    r = consumer.get_token(token_body)
    assert r['success'] is True

    body = [{
        "id": consumer_id,
        "capabilities": ["temporal", "subscription", "complex"]
    }]
    r = untrusted.delete_rule(body)
    assert r['success'] == False
    assert r['status_code'] == 403

    token_body = {"id": resource_id + "/someitem", "apis": apis}
    r = consumer.get_token(token_body)
    assert r['success'] is True

    body = [{"id": consumer_id}]
    r = untrusted.delete_rule(body)
    assert r['success'] == True
    assert r['status_code'] == 200

    token_body = {"id": resource_id + "/someitem", "apis": apis}
    r = consumer.get_token(token_body)
    assert r['success'] is False

    token_body = {
        "id": resource_id + "/someitem",
        "apis": ["/ngsi-ld/v1/subscription"]
    }
    r = consumer.get_token(token_body)
    assert r['success'] is False
Ejemplo n.º 6
0
def test_delete_onboarder_rule():
    global onboarder_id

    body = {"request": [provider_id + "/catalogue.iudx.io/catalogue/crud"]}

    r = consumer.get_token(body)
    assert r['success'] is True
    assert None != r['response']['token']

    body = {"id": onboarder_id}
    r = untrusted.delete_rule([body])
    assert r['success'] == True
    assert r['status_code'] == 200

    body = {"id": onboarder_id}
    r = untrusted.delete_rule([body])
    assert r['success'] == False
    assert r['status_code'] == 403

    # onboarder token request should fail
    body = {"request": [provider_id + "/catalogue.iudx.io/catalogue/crud"]}
    r = consumer.get_token(body)
    assert r['success'] is False
    assert r['status_code'] == 403
Ejemplo n.º 7
0
                onboarder_id = r['id']
                assert r['item_type'] == 'catalogue'
        if r['email'] == email and r['role'] == 'data ingester' and diresource_id == r['item']['cat_id']:
                ingester_id = r['id']
                assert r['policy'].endswith('"/iudx/v1/adapter"')

### deleting rules ###

token_body = { "id"    : provider_id + "/catalogue.iudx.io/catalogue/crud" }

r = consumer.get_token(token_body)
assert r['success']     is True
assert None != r['response']['token']

body = {"id" : onboarder_id}
r = untrusted.delete_rule([body])
assert r['success']     == True
assert r['status_code'] == 200

# onboarder token request should fail
r = consumer.get_token(token_body)
assert r['success']     is False

# 
token_body = {"id" : diresource_id + "/someitem/someotheritem", "api" : "/iudx/v1/adapter" }
r = consumer.get_token(token_body)
assert r['success']     is True

token_body = {"id" : resource_id + "/something", "apis" : ["/ngsi-ld/v1/temporal/entities"] }
r = consumer.get_token(token_body)
assert r['success']     is True
assert check_dti == True
assert check_del == True

# deleting rules

# delete rules set by delegate
r = alt_provider.delete_rule([{
    "id": onboarder_id
}, {
    "id": consumer_id
}], '*****@*****.**')
assert r['success'] == True
assert r['status_code'] == 200

# provider can delete rules set by delegate
r = untrusted.delete_rule([{"id": ingester_id}])
assert r['success'] == True
assert r['status_code'] == 200

r = alt_provider.delete_rule([{"id": ingester_id}], '*****@*****.**')
assert r['success'] == False
assert r['status_code'] == 403

# delegate can delete rule set by provider

body = {"id": provider_set_consumer_id}
r = alt_provider.delete_rule([body], '*****@*****.**')
assert r['success'] == True
assert r['status_code'] == 200

# cannot delete delegate rule
Ejemplo n.º 9
0
def test_delete_ingester_temporal():
    global ingester_id, consumer_id

    body = {"request": [diresource_id + "/someitem/someotheritem"]}
    r = consumer.get_token(body)
    assert r['success'] is True

    body = {"request": [resource_id + "/something"]}
    r = consumer.get_token(body)
    assert r['success'] is True

    # temporal must be there
    check = False
    r = consumer.view_consumer_resources()
    assert r['success'] == True
    assert r['status_code'] == 200

    for i in r['response']:
        if resource_id == i['cat_id']:
            assert 'temporal' in i['capabilities']
            check = True

    assert check is True

    # invalid body, some items not objects
    body = [
        ingester_id, ["complex"], {
            "id": consumer_id,
            "capabilities": ["temporal"]
        }
    ]
    r = untrusted.delete_rule(body)
    assert r['success'] == False
    assert r['status_code'] == 400

    body = [{
        "id": ingester_id
    }, {
        "id": consumer_id,
        "capabilities": ["temporal"]
    }]
    r = untrusted.delete_rule(body)
    assert r['success'] == True
    assert r['status_code'] == 200

    body = {"request": [diresource_id + "/someitem/someotheritem"]}
    r = consumer.get_token(body)
    assert r['success'] is False
    assert r['status_code'] == 403

    check = False
    r = consumer.view_consumer_resources()
    assert r['success'] == True
    assert r['status_code'] == 200

    for i in r['response']:
        if resource_id == i['cat_id']:
            assert 'temporal' not in i['capabilities']
            check = True

    assert check is True

    # will still be able to get token, as other caps are there
    body = {"request": [resource_id + "/something"]}
    r = consumer.get_token(body)
    assert r['success'] is True
    assert r['status_code'] == 200

    body = [{
        "id": ingester_id
    }, {
        "id": consumer_id,
        "capabilities": ["temporal"]
    }]
    r = untrusted.delete_rule(body)
    assert r['success'] == False
    assert r['status_code'] == 403