Example #1
0
def change_user_password(step, new_pw, stored, name):
    name = get_stored_or_store_name("user", stored, name)
    user_id, version = UserModel().get_resid(name)

    do_put(
        UserModel().root_path + "/" + "%s/passwordchange/%s" %
        (user_id, new_pw), {"originalVersionId": version})
def user_marks_testcase_status(step, stored_user, user_name, stored_testrun, testrun_name):
    trModel = TestrunModel()
    testrun_name = trModel.get_stored_or_store_name(stored_testrun, testrun_name)
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)

    # first we need the testrun id so we can get the latest version to approve
#    user_id = UserModel().get_resid(user_name)[0]
    testrun_id = trModel.get_resid(testrun_name)[0]

    # get the list of testcases for this testrun
    includedtestcase_list = trModel.get_included_testcases(testrun_id)

    for tc in step.hashes:
        testcase_id = TestcaseModel().get_resid(tc["name"])[0]

        result_obj = trModel.get_result(testcase_id,
                                    includedtestcase_list = includedtestcase_list)
        result_id = get_resource_identity(result_obj)[0]

        started_result = trModel.start_testcase(result_obj, user_name)
        started_result_version = get_resource_identity(started_result)[1]
        # now finally mark it with the specified status

        trModel.set_testcase_status(result_id, started_result_version, user_name, tc["status"])
def user_marks_testcase_status(step, stored_user, user_name, stored_testrun,
                               testrun_name):
    trModel = TestrunModel()
    testrun_name = trModel.get_stored_or_store_name(stored_testrun,
                                                    testrun_name)
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)

    # first we need the testrun id so we can get the latest version to approve
    #    user_id = UserModel().get_resid(user_name)[0]
    testrun_id = trModel.get_resid(testrun_name)[0]

    # get the list of testcases for this testrun
    includedtestcase_list = trModel.get_included_testcases(testrun_id)

    for tc in step.hashes:
        testcase_id = TestcaseModel().get_resid(tc["name"])[0]

        result_obj = trModel.get_result(
            testcase_id, includedtestcase_list=includedtestcase_list)
        result_id = get_resource_identity(result_obj)[0]

        started_result = trModel.start_testcase(result_obj, user_name)
        started_result_version = get_resource_identity(started_result)[1]
        # now finally mark it with the specified status

        trModel.set_testcase_status(result_id, started_result_version,
                                    user_name, tc["status"])
Example #4
0
def user_has_role(step, stored_user, user_name, stored_role, role_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)
    roleModel = RoleModel()
    role_name = roleModel.get_stored_or_store_name(stored_role, role_name)

    userModel.has_role(user_name, role_name)
def log_in_with_name(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)

    cookie = userModel.log_user_in(name)[1]
    # store the cookie in world
    world.auth_cookie = cookie
Example #6
0
def remove_role_from_user(step, stored_role, role_name, stored_user, user_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)
    roleModel = RoleModel()
    role_name = roleModel.get_stored_or_store_name(stored_role, role_name)

    userModel.remove_role(user_name, role_name)
def check_user_existence(step, stored, name, existence):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    names = name.split()
    userModel.verify_existence_on_root(existence = existence,
                                       params = {"firstName": names[0],
                                                 "lastName": names[1]})
Example #8
0
def log_in_with_name(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)

    cookie = userModel.log_user_in(name)[1]
    # store the cookie in world
    world.auth_cookie = cookie
def user_with_name_has_values(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    act_user = userModel.get_by_name(name)

    exp_user = step.hashes[0].copy()
    userModel.check_values(act_user, exp_user)
Example #10
0
def last_referenced_user_has_values(step):
    userModel = UserModel()
    act_user = userModel.get_latest_stored()
    # fetch the latest values for this user
    act_user = userModel.get_by_id(get_resource_identity(act_user)[0])

    exp_user = step.hashes[0].copy()
    userModel.check_values(act_user, exp_user)
Example #11
0
def add_roles_to_user(step, stored_user, user_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)

    '''
        adds them one at a time in the model
    '''
    userModel.add_roles(user_name, step.hashes)
Example #12
0
def logged_in_as_user(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    names = name.split()

    thisUser = userModel.get_logged_in_user()

    eq_(thisUser[ns("firstName")], names[0], "First Name field didn't match")
    eq_(thisUser[ns("lastName")], names[1], "Last Name field didn't match")
Example #13
0
def get_new_user_by_id(step):
    userModel = UserModel()
    last_created_user = userModel.get_latest_stored()
    user_id = get_resource_identity(last_created_user)[0]
    user_obj = userModel.get_by_id(user_id)

    compare_dicts_by_keys(last_created_user,
                          user_obj,
                          ("firstName", "lastName", "email", "screenName", "companyId"))
Example #14
0
def get_new_user_by_id(step):
    userModel = UserModel()
    last_created_user = userModel.get_latest_stored()
    user_id = get_resource_identity(last_created_user)[0]
    user_obj = userModel.get_by_id(user_id)

    compare_dicts_by_keys(
        last_created_user, user_obj,
        ("firstName", "lastName", "email", "screenName", "companyId"))
Example #15
0
def check_user_activated(step, stored, name, userStatus):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    names = name.split()
    statusId = get_user_status_id(userStatus)

    userModel.verify_found_on_root(params = {"firstName": names[0],
                                             "lastName": names[1],
                                             "userStatusId": statusId})
Example #16
0
def logged_in_as_user(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    names = name.split()

    thisUser = userModel.get_logged_in_user()

    eq_(thisUser[ns("firstName")], names[0], "First Name field didn't match")
    eq_(thisUser[ns("lastName")], names[1], "Last Name field didn't match")
Example #17
0
def check_user_existence(step, stored, name, existence):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    names = name.split()
    userModel.verify_existence_on_root(existence=existence,
                                       params={
                                           "firstName": names[0],
                                           "lastName": names[1]
                                       })
Example #18
0
def create_user_from_obj(user_obj):
    '''
        Create a user based on an already formed user object
    '''
    userModel = UserModel()
    created_obj = userModel.create(user_obj)

    compare_dicts_by_keys(ns_keys(user_obj),
                          created_obj,
                          ("firstName", "lastName", "email", "screenName", "companyId"))
Example #19
0
def create_user_from_obj(user_obj):
    '''
        Create a user based on an already formed user object
    '''
    userModel = UserModel()
    created_obj = userModel.create(user_obj)

    compare_dicts_by_keys(
        ns_keys(user_obj), created_obj,
        ("firstName", "lastName", "email", "screenName", "companyId"))
Example #20
0
def check_user_activated(step, stored, name, userStatus):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    names = name.split()
    statusId = get_user_status_id(userStatus)

    userModel.verify_found_on_root(params={
        "firstName": names[0],
        "lastName": names[1],
        "userStatusId": statusId
    })
Example #21
0
def replace_role_list_for_user(step, stored_user, user_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)

    role_ids = []
    for role in step.hashes:
        role_id = RoleModel().get_resid(role["name"])[0]
        role_ids.append(role_id)


    userModel.set_roles(user_name, role_ids)
Example #22
0
def update_user_with_name(step, stored, name):
    name = get_stored_or_store_name("user", stored, name)

    user_id, version = UserModel().get_resid(name)

    new_values = step.hashes[0].copy()
    company_id = CompanyModel().get_resid(new_values["company name"])
    new_values["companyId"] = company_id
    del new_values["company name"]
    new_values["originalVersionId"] = version

    do_put(UserModel().root_path + "/" + str(user_id), new_values)
def user_creates_testcase_with_name(step, stored_user, user_name, stored_testcase, testcase_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)
    testcaseModel = TestcaseModel()
    testcase_name = testcaseModel.get_stored_or_store_name(stored_testcase, testcase_name)

    post_payload = {"productId": ProductModel().get_seed_resid()[0],
                    "maxAttachmentSizeInMbytes":"10",
                    "maxNumberOfAttachments":"5",
                    "name": testcase_name,
                    "description": "Lettuce tc"
                    }
    headers = get_form_headers(userModel.get_auth_header(user_name))

    testcaseModel.create(post_payload, headers)
Example #24
0
def foo_has_these_assignments(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)

    user_id = userModel.get_resid(name)[0]
    assignment_list = userModel.get_assignment_list(user_id)

    # walk through all the expected roles and make sure it has them all
    # note, it doesn't check that ONLY these roles exist.  That should be a different
    # method.
    for role in step.hashes:
        role_name = role["name"]
        found_perm = [x for x in assignment_list if x[ns("name")] == role_name]

        assert len(found_perm) == 1, "Expected to find assignment name %s in:\n%s" % (role_name,
                                                                                jstr(assignment_list))
def retest_for_testcases(step, stored_testrun, testrun_name):
    '''
        Step hashes can have a user name field or not.  If it's not specified, it will,
        obviously, not pass a user id, so it will assign the new result object to the
        user of the previous result.
    '''
    trModel = TestrunModel()
    testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name)

    testrun_id = get_resource_identity(testrun)[0]

    # get the list of testcases for this testrun
    includedtestcase_list = trModel.get_included_testcases(testrun_id)

    for tc in step.hashes:
        testcase_id = TestcaseModel().get_resid(tc["name"])[0]

        try:
            tester_id = UserModel().get_resid(tc["user name"])[0]

        except KeyError:
            tester_id = None

        result = trModel.get_result(
            testcase_id, includedtestcase_list=includedtestcase_list)

        result_id = get_resource_identity(result)[0]

        trModel.retest_single(result_id, tester_id)
Example #26
0
def foo_has_these_assignments(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)

    user_id = userModel.get_resid(name)[0]
    assignment_list = userModel.get_assignment_list(user_id)

    # walk through all the expected roles and make sure it has them all
    # note, it doesn't check that ONLY these roles exist.  That should be a different
    # method.
    for role in step.hashes:
        role_name = role["name"]
        found_perm = [x for x in assignment_list if x[ns("name")] == role_name]

        assert len(
            found_perm) == 1, "Expected to find assignment name %s in:\n%s" % (
                role_name, jstr(assignment_list))
Example #27
0
def user_has_these_roles(step, stored_user, user_name, at_least_only):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)

    role_list = userModel.get_role_list(user_name)

    list_size_check(at_least_only, step.hashes, role_list)

    # walk through all the expected roles and make sure it has them all
    # note, it doesn't check that ONLY these roles exist.  That should be a different
    # method.
    for role in step.hashes:
        role_name = role["name"]
        found_perm = [x for x in role_list if x[ns("name")] == role_name]

        assert len(found_perm) == 1, "Expected to find role name %s in:\n%s" % (role_name,
                                                                                jstr(role_list))
Example #28
0
def log_in_with_credentials(step):
    user = step.hashes[0]
    headers = get_json_headers(get_auth_header(user["email"],
                                               user["password"]))

    cookie = do_put_for_cookie(UserModel().root_path + "/" + "login", "",
                               headers)[1]
    world.auth_cookie = cookie
Example #29
0
def user_has_permissions(step, stored, user_name, at_least_only):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored, user_name)

    perm_list = userModel.get_permission_list(user_name)

    list_size_check(at_least_only, step.hashes, perm_list)

    # walk through all the expected roles and make sure it has them all
    # note, it doesn't check that ONLY these roles exist.  That should be a different
    # method.
    for perm_code in step.hashes:
        permissionCode = perm_code["permissionCode"]
        found_perm = [x for x in perm_list if x[ns("permissionCode")] == permissionCode]

        assert len(found_perm) == 1, "Expected to find permissionCode %s in:\n%s" % (permissionCode,
                                                                                   str(perm_list))
def user_creates_testcase_with_name(step, stored_user, user_name,
                                    stored_testcase, testcase_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)
    testcaseModel = TestcaseModel()
    testcase_name = testcaseModel.get_stored_or_store_name(
        stored_testcase, testcase_name)

    post_payload = {
        "productId": ProductModel().get_seed_resid()[0],
        "maxAttachmentSizeInMbytes": "10",
        "maxNumberOfAttachments": "5",
        "name": testcase_name,
        "description": "Lettuce tc"
    }
    headers = get_form_headers(userModel.get_auth_header(user_name))

    testcaseModel.create(post_payload, headers)
def add_users_to_testrun(step, stored, testrun_name):
    testrunModel = TestrunModel()
    testrun_name = testrunModel.get_stored_or_store_name(stored, testrun_name)

    user_ids = []
    for user in step.hashes:
        user_id = UserModel().get_resid(user["name"])[0]
        user_ids.append(user_id)

    testrunModel.add_team_members(testrun_name, user_ids)
Example #32
0
def user_with_name_has_values(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    act_user = userModel.get_by_name(name)

    exp_user = step.hashes[0].copy()
    userModel.check_values(act_user, exp_user)
Example #33
0
def activate_user(step, status_action, stored, name):
    '''
        Users are not deleted, they're just registered or unregistered.
    '''
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)

    if (status_action == "activate"):
        userModel.activate(name)
    else:
        userModel.deactivate(name)
Example #34
0
def last_referenced_user_has_values(step):
    userModel = UserModel()
    act_user = userModel.get_latest_stored()
    # fetch the latest values for this user
    act_user = userModel.get_by_id(get_resource_identity(act_user)[0])

    exp_user = step.hashes[0].copy()
    userModel.check_values(act_user, exp_user)
def assign_testcases_to_user_for_testrun(step, stored_user, user_name,
                                         stored_testrun, testrun_name):
    '''
        Expect hashes to contain:
        | testcase name |
    '''
    user_name = get_stored_or_store_name("user", stored_user, user_name)
    user_id = UserModel().get_resid(user_name)[0]
    testrun_name = get_stored_or_store_name("testrun", stored_testrun,
                                            testrun_name)
    trModel = TestrunModel()

    for tc in step.hashes:
        trModel.assign_testcase(testrun_name, user_id, tc["name"])
Example #36
0
def activate_user(step, status_action, stored, name):
    '''
        Users are not deleted, they're just registered or unregistered.
    '''
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)

    if (status_action == "activate"):
        userModel.activate(name)
    else:
        userModel.deactivate(name)
Example #37
0
def create_user_with_name_foo(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    create_user_from_name(name)
Example #38
0
def create_user_with_name_foo(step, stored, name):
    userModel = UserModel()
    name = userModel.get_stored_or_store_name(stored, name)
    create_user_from_name(name)
Example #39
0
def add_role_to_user(step, stored_role, role_name, stored_user, user_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)
    roleModel = RoleModel()
    role_name = roleModel.get_stored_or_store_name(stored_role, role_name)
    userModel.add_role(user_name, role_name)
Example #40
0
def confirm_user_email(step, stored, name):
    name = get_stored_or_store_name("user", stored, name)
    user_id, version = UserModel().get_resid(name)

    do_put(UserModel().root_path + "/" + "%s/emailconfirm" % (user_id),
           {"originalVersionId": version})
Example #41
0
def log_out(step, stored, user_name):
    user_name = get_stored_or_store_name("user", stored, user_name)

    headers = {'cookie': world.auth_cookie, 'Content-Type': 'application/json'}

    return do_put(UserModel().root_path + "/" + "logout", "", headers)
Example #42
0
def user_not_logged_in(step):
    headers = {'cookie': world.auth_cookie, 'Content-Type': 'application/json'}

    do_get(UserModel().root_path + "/" + "current",
           headers=headers,
           exp_status=401)