Exemplo n.º 1
0
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
Exemplo n.º 2
0
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'
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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"}'
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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
Exemplo n.º 7
0
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()
Exemplo n.º 8
0
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
Exemplo n.º 9
0
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!'
Exemplo n.º 10
0
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'
Exemplo n.º 11
0
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'
Exemplo n.º 12
0
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'
Exemplo n.º 13
0
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.'
Exemplo n.º 14
0
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
Exemplo n.º 15
0
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'
Exemplo n.º 16
0
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.'
Exemplo n.º 17
0
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']
Exemplo n.º 18
0
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
Exemplo n.º 19
0
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
Exemplo n.º 20
0
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.'
Exemplo n.º 21
0
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']
Exemplo n.º 22
0
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.'
Exemplo n.º 23
0
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
Exemplo n.º 24
0
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
Exemplo n.º 25
0
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.'
Exemplo n.º 26
0
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.'
Exemplo n.º 27
0
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.'
Exemplo n.º 28
0
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
Exemplo n.º 29
0
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.'
Exemplo n.º 30
0
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.'