Esempio n. 1
0
def test_login_multiple_sessions():
    auth_one = login(CONF.config["usmqe"]["username"],
                     CONF.config["usmqe"]["password"])
    auth_two = login(CONF.config["usmqe"]["username"],
                     CONF.config["usmqe"]["password"])
    logout(auth=auth_one)
    logout(auth=auth_two)
Esempio n. 2
0
def test_login_multiple_sessions():
    auth_one = login(pytest.config.getini("usm_username"),
                     pytest.config.getini("usm_password"))
    auth_two = login(pytest.config.getini("usm_username"),
                     pytest.config.getini("usm_password"))
    logout(auth=auth_one)
    logout(auth=auth_two)
Esempio n. 3
0
def api_valid_credentials():
    """
    During setup phase, login default usmqe user account (username and password
    comes from usm.ini config file) and return requests auth object.
    Then during teardown logout the user to close the session.
    """
    auth = login(pytest.config.getini("usm_username"),
                 pytest.config.getini("usm_password"))
    yield auth
    logout(auth=auth)
Esempio n. 4
0
def valid_session_credentials(request):
    """
    During setup phase, login default usmqe user account (username and password
    comes from usm.ini config file) and return requests auth object.
    Then during teardown logout the user to close the session.
    """
    auth = login(CONF.config["usmqe"]["username"],
                 CONF.config["usmqe"]["password"])
    yield auth
    logout(auth=auth)
Esempio n. 5
0
def valid_new_user(valid_user_data):
    """
    Create user from valid_user_data fixture and return these data.
    At the end remove this user.
    """
    auth = login(pytest.config.getini("usm_username"),
                 pytest.config.getini("usm_password"))
    admin = tendrlapi_user.ApiUser(auth=auth)
    admin.add_user(valid_user_data)
    yield valid_user_data
    admin.del_user(valid_user_data["username"])
    logout(auth=auth)
Esempio n. 6
0
def delete_new_user(user_data):
    """
    Delete user with given user_data.
    """
    auth = login(pytest.config.getini("usm_username"),
                 pytest.config.getini("usm_password"))
    admin = tendrlapi_user.ApiUser(auth=auth)
    if user_data['email'].endswith(
            usmqe.inventory.role2hosts("usm_client")[0]):
        SSH = usmssh.get_ssh()
        node_connection = SSH[usmqe.inventory.role2hosts("usm_client")[0]]
        userdel = 'userdel {}'.format(user_data['username'])
        userdel_response = node_connection.run(userdel)
        # userdel command returned 0 return code
        assert userdel_response[0] == 0
    admin.del_user(user_data["username"])
    logout(auth=auth)
Esempio n. 7
0
def delete_new_user(user_data):
    """
    Delete user with given user_data.
    """
    auth = login(CONF.config["usmqe"]["username"],
                 CONF.config["usmqe"]["password"])
    admin = tendrlapi_user.ApiUser(auth=auth)
    if user_data['email'].endswith(
            CONF.inventory.get_groups_dict()["usm_client"][0]):
        SSH = usmssh.get_ssh()
        node_connection = SSH[CONF.inventory.get_groups_dict()["usm_client"]
                              [0]]
        userdel = 'userdel {}'.format(user_data['username'])
        userdel_response = node_connection.run(userdel)
        # userdel command returned 0 return code
        assert userdel_response[0] == 0
    admin.del_user(user_data["username"])
    logout(auth=auth)
Esempio n. 8
0
def test_login_multiple_sessions_twisted():
    asserts = {
        "cookies": None,
        "ok": False,
        "reason": 'Unauthorized',
        "status": 401,
    }
    api_one = TendrlApi(auth=login(CONF.config["usmqe"]["username"],
                                   CONF.config["usmqe"]["password"]))
    api_two = TendrlApi(auth=login(CONF.config["usmqe"]["username"],
                                   CONF.config["usmqe"]["password"]))
    api_one.jobs()
    api_two.jobs()
    logout(auth=api_one._auth)
    api_one.jobs(asserts_in=asserts)
    api_two.jobs()
    logout(auth=api_two._auth)
    api_one.jobs(asserts_in=asserts)
    api_two.jobs(asserts_in=asserts)
Esempio n. 9
0
def test_login_multiple_sessions_twisted():
    asserts = {
        "cookies": None,
        "ok": False,
        "reason": 'Unauthorized',
        "status": 401,
    }
    api_one = TendrlApi(auth=login(pytest.config.getini("usm_username"),
                                   pytest.config.getini("usm_password")))
    api_two = TendrlApi(auth=login(pytest.config.getini("usm_username"),
                                   pytest.config.getini("usm_password")))
    api_one.flows()
    api_two.flows()
    logout(auth=api_one._auth)
    api_one.flows(asserts_in=asserts)
    api_two.flows()
    logout(auth=api_two._auth)
    api_one.flows(asserts_in=asserts)
    api_two.flows(asserts_in=asserts)
Esempio n. 10
0
def test_user_change_password(valid_new_normal_user, valid_password):
    """@pylatest api/user.edit
    API-users: edit user
    *******************

    .. test_metadata:: author [email protected]

    Description
    ===========

    Change password and email of user and login with new password.
    """
    auth = login(valid_new_normal_user["username"],
                 valid_new_normal_user["password"])
    test = tendrlapi_user.ApiUser(auth=auth)
    """@pylatest api/user.get
    .. test_step:: 1

        Send **PUT** request to ``APIURL/users``.

        During this step is set email to `[email protected]` because
        user can not be edited if he does not have set email. (e.g. admin)

    .. test_result:: 1

        Edited user data are returned.
    """
    new_email = "*****@*****.**"
    edit_data = {
        "email": new_email,
        "password": valid_password,
        "password_confirmation": valid_password
    }
    test.edit_user(valid_new_normal_user["username"], edit_data)
    """@pylatest api/user.get
    .. test_step:: 2

        Login

        Send **POST** request to ``APIURL/login``.

    .. test_result:: 2

        User is logged with new credentials.
    """
    logout(auth=auth)
    auth = login(valid_new_normal_user["username"], valid_password)
    test = tendrlapi_user.ApiUser(auth=auth)
    """@pylatest api/user.get
    .. test_step:: 3

        Check if user have edited email.

        Send **GET** request to ``APIURL/users/{user}``.

    .. test_result:: 3

        User information is checked if email was correctly changed.
    """
    valid_new_normal_user["email"] = new_email
    test.check_user(valid_new_normal_user)
    logout(auth=auth)