def test__delete_wrong_port(): """Test the _delete function on wrong port. :return: """ am = openam.Openam(openam_url="http://openam.example.com:880/opeam") data = am._delete(uri='wrong_uri') assert 'error' in data
def test__type_validator(): """ :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/opeam") data = am._type_validator(type="groups") assert data == 'groups'
def test_update_resourcetype(openam_version): """Update a resourcetype. :return: """ if openam_version != 12: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") for result in am.list_resourcetypes()['result']: if result['name'] == 'My Resource Type': uuid = result['uuid'] resource_data = { "uuid": uuid, "name": "My Updated Resource Type", "actions": { "LEFT": "false", "RIGHT": "false", "UP": "false", "DOWN": "false" }, "patterns": ["http://device/location/*"] } data = am.update_resourcetype(uuid=uuid, resource_data=resource_data) assert data['name'] == 'My Updated Resource Type' else: pass
def test__to_string_dict(): """Test the _to_string with a dict. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/opeam") data = am._to_string(data={"sunOrganizationStatus": "Inactive"}) assert data == '{"sunOrganizationStatus": "Inactive"}'
def test__put_wrong_port(): """Test the _put function on wrong port. :return: """ am = openam.Openam(openam_url="http://openam.example.com:880/opeam") data = am._put(uri='wrong_uri', data='{}', headers={}) assert 'error' in data
def test__put(): """Test the _put function with wrong_uri. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam") data = am._put(uri='wrong_uri', data='{}', headers={}) assert not data
def test_logout(): """Test if a user can logout. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") assert am.logout()
def test__delete(): """Test the _delete function with wrong_uri. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam") data = am._delete(uri='wrong_uri') assert not data
def test___init__openam_url(): """Test __init__ function if openam_url is provided. :return: """ with pytest.raises(ValueError) as excinfo: openam.Openam() assert excinfo.value.message == 'This interface needs an OpenAM URL to work!'
def test__to_string_string(): """Test the _to_string with a string :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/opeam") data = am._to_string(data='my list') assert data == 'my list'
def test__type_validator_wrong_type(): """ :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/opeam") data = am._type_validator(type="wrong") assert data == 'users'
def test__uri_realm_creator(): """ :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/opeam") data = am._uri_realm_creator(uri='wrong_uri') assert data == 'json/wrong_uri'
def test_authenticate_no_password(): """ Will test authenticate function if no password is provided. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******") assert excinfo.value.message == 'You will need to provide a password to login.'
def test_authenticate_wrong_password(): """Test the authentication function with a wrong password. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") auth_data = am.authenticate(username="******", password="******") am.logout() assert not auth_data
def test_authenticate(): """Test the authentication function. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") auth_data = am.authenticate(username="******", password="******") am.logout() assert auth_data['successUrl'] == '/openam/console'
def test__to_string_no_data(): """Test the _to_string without any data. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") data = am._to_string() assert excinfo.value.message == 'Please provide a correct data structure.'
def test_list_realms(): """ :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") data = am.list_realms() assert data['result'] == ['/', '/myRealm']
def test_list_realms_wrong_realm(): """ :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") data = am.list_realms(realm="wrong") assert not data
def test_token_validation_wrong_realm(): """Test a wrong token to validate. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") auth_data = am.authenticate(username="******", password="******") data = am.token_validation(token=auth_data['tokenId'], realm="wrong") am.logout() assert not data
def test_delete_realm_no_realm(): """ Will delete an identity when no realm is provided. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") am.delete_realm() assert excinfo.value.message == 'Please provide a realm.'
def test_get_serverinfo_with_property(): """Test to get the cookieDomains configuration. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") data = am.get_serverinfo(property="cookieDomains") am.logout() assert data['domains'] == ['.example.com']
def test_update_realm_no_realm_data(): """ Will delete an identity when no username is provided. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") am.update_realm(realm="myRealm") assert excinfo.value.message == 'Please provide correct realm_data information.'
def test_get_serverinfo_with_wrong_property(): """Test with a wrong property to get server information. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") data = am.get_serverinfo(property="wrong") am.logout() assert not data
def test_token_validation(): """Test if a token is validated. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") auth_data = am.authenticate(username="******", password="******") data = am.token_validation(token=auth_data['tokenId']) am.logout() assert data
def test_get_identity_no_username(): """ Will get an identity if no username is provided. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") am.get_identity() assert excinfo.value.message == 'Please provide a username.'
def test_create_identity_no_user_data(): """ Will create an identity if no user_data is provided. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") am.create_identity() assert excinfo.value.message == 'Please provide correct user information.'
def test_update_resourcetypes_no_resource_data(): """ Will create an resourcetype when no resource_data is provided. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") am.update_resourcetype(uuid="asas") assert excinfo.value.message == 'Please provide correct resource_data information.'
def test_session_information_wrong_action(): """Get the session information with a wrong action. :return: """ am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") auth_data = am.authenticate(username="******", password="******") data = am.session_information(action="wrong", token=auth_data['tokenId']) am.logout() assert not data
def test_delete_resourcetypes_no_uuid(): """ Will delete an resourcetype when no uuid is provided. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") am.delete_resourcetype() assert excinfo.value.message == 'Please provide a uuid for a resourcetype.'
def test_session_information_no_token(): """ Will test session_information function if no token is provided. :return: """ with pytest.raises(ValueError) as excinfo: am = openam.Openam(openam_url="http://openam.example.com:8080/openam/") am.authenticate(username="******", password="******") am.session_information(action="getMaxTime") assert excinfo.value.message == 'Please provide a token.'