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
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
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
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
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
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
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.'
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
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
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
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
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
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
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!'
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
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"
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"
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
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!'
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
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
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
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
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!'
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!'
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"
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"
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'}
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
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