Exemplo n.º 1
0
def test_delete_log_level_by_name_false():
    """Will delete an log level with non existing name "SYNCOPE_AGAIN".

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    assert syn.delete_log_level_by_name("SYNCOPE_AGAIN") == False
Exemplo n.º 2
0
def test_get_users_count():
    """Will count the amount of users stored in the Syncope database.

    :return: Should return: 5
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    assert syn.get_users_count() == 5
Exemplo n.º 3
0
def test_get_users_id_false():
    """Will get all information for user with id: 15.

    :return: Should return: False.
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    assert syn.get_user_by_id(15) == False
Exemplo n.º 4
0
def test_get_audit_false():
    """Will get all audit rules (Wrong password).

    :return: Should return: True
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    assert syn.get_audit() == False
Exemplo n.º 5
0
def test_delete_role_false():
    """Will delete the a non existing role.

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    assert syn.delete_role_by_id(9999999) == False
Exemplo n.º 6
0
def test_delete_log_level_by_name():
    """Will delete an log level with name "SYNCOPE".

    :return: Should return: True
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    assert syn.delete_log_level_by_name("SYNCOPE") == True
Exemplo n.º 7
0
def test__post():
    """ Will test __init__ function.
    :return:
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    with pytest.raises(ValueError) as excinfo:
        data = syn._post("/syncope/cxf/users")
    assert excinfo.value.message == 'No arguments are given to POST.'
Exemplo n.º 8
0
def test_get_user_by_name():
    """Will get all information for user with username: vivaldi

    :return: Should return: 3
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    user_data = syn.get_user_by_name("vivaldi")
    assert user_data['id'] == 3
Exemplo n.º 9
0
def test_get_log_level_by_name_false():
    """Will get all information from non existing log name.

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    log_level = syn.get_log_level_by_name("SYNCOPE")
    assert log_level == False
Exemplo n.º 10
0
def test_get_log_levels_false():
    """Will test to get all log levels (Wrong password).

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    roles_data = syn.get_log_levels()
    assert roles_data == False
Exemplo n.º 11
0
def test_get_log_levels():
    """Will test to get all log levels.

    :return: Should return: 17
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    roles_data = syn.get_log_levels()
    assert len(roles_data) == 17
Exemplo n.º 12
0
def test_update_role_false():
    """Will update the role created in previous test, but no correct JSON was given as argument.

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    my_role = '{}'
    assert syn.update_role(my_role) == False
Exemplo n.º 13
0
def test_get_children_role_by_id_false():
    """Will get all children information for role with id: 24.

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    role_data = syn.get_children_role_by_id(24)
    assert role_data == False
Exemplo n.º 14
0
def test___init__password():
    """ Will test __init__ function if password is provided.

    :return:
    """
    with pytest.raises(ValueError) as excinfo:
        syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******")
    assert excinfo.value.message == 'This interface needs an password to work!'
Exemplo n.º 15
0
def test_get_users():
    """Will test to get all users.

    :return: Should return: 5
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    user_data = syn.get_users()
    assert len(user_data) == 5
Exemplo n.º 16
0
def test_reactivate_user_by_name():
    """Will reactivate the user for user username vivaldi.

    :return: Should return: active
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    user_data = syn.reactivate_user_by_name("vivaldi")
    assert user_data['status'] == "active"
Exemplo n.º 17
0
def test_suspend_user_by_name():
    """Will suspend the user for user username vivaldi.

    :return: Should return: suspended
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    user_data = syn.suspend_user_by_name("vivaldi")
    assert user_data['status'] == "suspended"
Exemplo n.º 18
0
def test_get_user_count_by_query():
    """Will count the amount of user which has 'vivaldi' as username.

    :return: Should return: 1
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    search_req = '{"type":"LEAF","attributableCond":{"type":"EQ","schema":"username","expression":"vivaldi"}}'
    assert syn.get_user_count_by_query(search_req) == 1
Exemplo n.º 19
0
def test___init__syncope_url():
    """ Will test __init__ function if syncope_url is provided.

    :return:
    """
    with pytest.raises(ValueError) as excinfo:
        syn = syncope.Syncope(username="******", password="******")
    assert excinfo.value.message == 'This interface needs an Syncope URL to work!'
Exemplo n.º 20
0
def test_delete_audit():
    """Will delete an audit rule.

    :return: Should return: True
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    delete_audit_rule = '{"type":"REST","category":"LoggerController","subcategory":null,"event":"listAudits","result":"SUCCESS"}'
    assert syn.delete_audit(delete_audit_rule) == True
Exemplo n.º 21
0
def test_delete_audit_false():
    """Will delete an audit rule.

    :return: Should return: True
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    delete_audit_rule = ''
    assert syn.delete_audit(delete_audit_rule) == False
Exemplo n.º 22
0
def test_get_audit():
    """Will get all audit rules.

    :return: Should return: 1
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    audit_rules = syn.get_audit()
    assert len(audit_rules) == 1
Exemplo n.º 23
0
def test_create_audit_false():
    """Will create an audit rule.

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    add_audit_rule = ''
    assert syn.create_audit(add_audit_rule) == False
Exemplo n.º 24
0
def test_get_log_level_by_name_raise():
    """ Will test if an name is given as argument.

    :return: Should catch the ValueError.
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    with pytest.raises(ValueError) as excinfo:
        syn.get_log_level_by_name()
    assert excinfo.value.message == 'This search needs log level name to work!'
Exemplo n.º 25
0
def test_create_audit_raise():
    """ Will test if an name is given as argument.

    :return: Should catch the ValueError.
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    with pytest.raises(ValueError) as excinfo:
        syn.delete_audit()
    assert excinfo.value.message == 'This search needs JSON data to work!'
Exemplo n.º 26
0
def test_get_user_by_id():
    """Will get all information for user with id: 5.

    :return: Should return: puccini
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    user_data = syn.get_user_by_id(5)
    username = user_data['username']
    assert username == "puccini"
Exemplo n.º 27
0
def test_create_or_update_log_level_update():
    """Will update the log level to "WARN".

    :return: Should return: "WARN"
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    update_log_level = '{"name": "org.apache.http", "level": "WARN"}'
    log_level = syn.create_or_update_log_level(update_log_level)
    assert log_level['level'] == "WARN"
Exemplo n.º 28
0
def test_create_or_update_log_level_create():
    """Will create an new loglevel named 'SYNCOPE' with level 'WARN'.

    :return: Should return: json string
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    update_log_level = '{"name": "SYNCOPE", "level": "WARN"}'
    log_level = syn.create_or_update_log_level(update_log_level)
    assert log_level == {'level': 'WARN', 'name': 'SYNCOPE'}
Exemplo n.º 29
0
def test_create_or_update_log_level_false_empty():
    """Will create an new log level, without JSON data.

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    update_log_level = '{}'
    log_level = syn.create_or_update_log_level(update_log_level)
    assert log_level == False
Exemplo n.º 30
0
def test_create_or_update_log_level_create_false():
    """Will create an new loglevel named 'SYNCOPE' with level 'WARN' (Wrong password).

    :return: Should return: False
    """
    syn = syncope.Syncope(syncope_url="http://192.168.1.145:9080", username="******", password="******")
    update_log_level = '{"name": "SYNCOPE", "level": "WARN"}'
    log_level = syn.create_or_update_log_level(update_log_level)
    assert log_level == False