Ejemplo n.º 1
0
def remove_environment_from_test_case(step, environment, test_case):
    # fetch the test case's resource identity
    test_case_id = get_test_case_resid(test_case)
    environment_id = get_environment_resid(environment)
    
    world.conn.request("DELETE", add_params(world.path_testcases + test_case_id + "/environments/" + environment_id))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "delete new environment from test case")
Ejemplo n.º 2
0
def remove_environment_from_product(step, environment, product):
    # fetch the product's resource identity
    product_id = get_product_resid(product)
    environment_id = get_environment_resid(environment)
    
    world.conn.request("DELETE", add_params(world.path_products + product_id + "/environments/" + environment_id))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "delete new environment from product")
Ejemplo n.º 3
0
def add_a_new_company_with_name_foo(step, company_name):
    post_payload = post_data.get_submit_company(company_name)
    headers = {'content-Type':'text/xml',
               "Content-Length": "%d" % len(post_payload) }

    world.conn.request("POST", add_params(world.path_companies), "", headers)
    world.conn.send(post_payload)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "create new testcase")
Ejemplo n.º 4
0
def add_a_new_environment_type_with_name_foo(step, env_type_name):
    post_payload = post_data.get_submit_environment(env_type_name)
    headers = {'content-Type':'text/xml',
               "Content-Length": "%d" % len(post_payload) }

    world.conn.request("POST", add_params(world.path_environmenttypes), "", headers)
    world.conn.send(post_payload)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "create new environment type")
Ejemplo n.º 5
0
def user_has_foo__has_active_status_bar(step, name, exp_active):
    names = name.split()
    world.conn.request("GET", add_params(world.path_users, 
                                         {"firstName": names[0], "lastName": names[1]}))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched a user")

    userJson = get_single_item(response, "user")
    assert_equal(userJson.get("active"), exp_active, "active status")
Ejemplo n.º 6
0
def create_a_new_role_of_x(step, new_role):
    
    json_data = post_data.get_submit_role(new_role)
    headers = { 'content-Type':'text/xml',
            "Content-Length": "%d" % len(json_data) }

    world.conn.request("POST", add_params(world.path_roles), "", headers)
    world.conn.send(json_data)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Create new role")
Ejemplo n.º 7
0
def order_role_searches_list_foo_before_bar(step, order, first, second):
    
    # fetch the user's resource identity
    world.conn.request("GET", add_params(world.path_roles, {"sortDirection": order}))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched list of all roles")

    respJson = get_resp_list(response, "role")

    find_ordered_response("role", "description", first, second, respJson)
Ejemplo n.º 8
0
def submit_information_for_user_foo(step, name):
    names = name.split()
    
    xml_data = post_data.get_submit_user(names[0], names[1])
    headers = { 'content-Type':'text/xml',
            "Content-Length": "%d" % len(xml_data) }

    world.conn.request("POST", add_params(world.path_users), "", headers)
    world.conn.send(xml_data)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Create new user")
Ejemplo n.º 9
0
def setup_scenario_data(scenario):
    if (world.use_mock):
        scenarioData = mock_scenario_data.get_scenario_data(scenario.name).strip() 
    
        headers = {'content-Type':'text/plain',
                   "Content-Length": "%d" % len(scenarioData) }
    
        setup_connection()
        world.conn.request("POST", add_params(world.path_mockdata, {"scenario" : scenario.name}), "", headers)
    
        world.conn.send(scenarioData)
        world.conn.getresponse()
Ejemplo n.º 10
0
def upload_attachment_foo_to_test_case_bar(step, attachment, test_case):
    test_case_id = get_test_case_resid(test_case)

    content_type, body = encode_multipart_formdata([], [{'key': attachment, 
                                                         'filename': attachment, 
                                                         'value': open(world.testfile_dir + attachment, 'rb')}])

    headers = {"Accept": "application/xml", 
               "Content-Type":content_type,
               "Content-Length": "%d" % len(body) }

    world.conn.request("POST", add_params(world.path_testcases + test_case_id + "/attachments/upload"), body, headers)

    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Create new user")
Ejemplo n.º 11
0
def add_environment_foo_to_test_case_bar(step, environment, test_case):
    # this takes 2 requests.  
    #    1: get the id of this test case
    #    2: add the environment to the test case
    
    # fetch the test case's resource identity
    test_case_id = get_test_case_resid(test_case)
    
    post_payload = post_data.get_submit_environment(environment)
    headers = { 'content-Type':'text/xml',
            "Content-Length": "%d" % len(post_payload) }

    world.conn.request("POST", add_params(world.path_testcases + test_case_id + "/environments"), "", headers)
    world.conn.send(post_payload)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "post new environment to test_case")
Ejemplo n.º 12
0
def add_environment_foo_to_product_bar(step, environment, product):
    # this takes 2 requests.  
    #    1: get the id of this product
    #    2: add the environment to the product
    
    # fetch the product's resource identity
    product_id = get_product_resid(product)
    
    post_payload = post_data.get_submit_environment(environment)
    headers = {'content-Type':'text/xml',
               'Content-Length': "%d" % len(post_payload) }

    world.conn.request("POST", add_params(world.path_products + product_id + "/environments"), "", headers)
    world.conn.send(post_payload)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "post new environment to product")
Ejemplo n.º 13
0
def add_permission_foo_to_role_bar(step, permission, role):
    # this takes 2 requests.  
    #    1: get the id of this role
    #    2: add the permission to the role
    
    # fetch the role's resource identity
    role_id = get_role_resid(role)
    
    post_payload = post_data.get_submit_permission(permission)
    headers = { 'content-Type':'text/xml',
            "Content-Length": "%d" % len(post_payload) }

    world.conn.request("POST", add_params(world.path_roles + role_id + "/permissions"), "", headers)
    world.conn.send(post_payload)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "post new permission to role")
Ejemplo n.º 14
0
def logged_in_as_user_foo(step, name):
    names = name.split()
    
    name_headers = { 'firstname':names[0], 'lastname': names[1] }

    world.conn.request("GET", add_params(world.path_users + "current"), None, name_headers)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched a user")
    
    thisUser = get_single_item(response, ns("user"))

    #save this off for later steps
    world.userResId = thisUser.get("resourceIdentity").get("id")
    assert world.userResId != None, "must have some value for user resourceIdentity: "+ jstr(thisUser)
    
    assert_equal(thisUser.get(ns("firstname")), names[0], "First Name field didn't match")
    assert_equal(thisUser.get(ns("lastname")), names[1], "Last Name field didn't match")
Ejemplo n.º 15
0
def add_role_of_foo_to_user_bar(step, role, name):
    '''
    # this takes 2 requests.  
    #    1: get the id of this user
    #    2: add the role to the user
    '''
    
    # fetch the role's resource identity
    user_id = get_user_resid(name)
    
    post_payload = post_data.get_submit_role(role)
    headers = { 'content-Type':'text/xml',
            "Content-Length": "%d" % len(post_payload) }

    world.conn.request("POST", add_params(world.path_users + user_id + "/roles"), "", headers)
    world.conn.send(post_payload)
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "post new role to user")
Ejemplo n.º 16
0
def user_id_role_check(user_id, role, expected_tf, assert_text):
    # This takes 2 requests to complete
    #    1: get the id of the user
    #    2: check that user has that role
    
    world.conn.request("GET", add_params(world.path_users + str(user_id) + "/roles"))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched a user")

    # walk through all roles for this user to see if it has the requested one
    
    roleJsonList = get_resp_list(response, ns("role")) 
    
    foundRole = False
    for roleJson in roleJsonList:
        assert isinstance(roleJson, dict), "unexpected type:\n" + jstr(roleJson)
        if (roleJson.get(ns("description")) == role):
            foundRole = True
    assert_equal(foundRole, expected_tf, assert_text + ": " + jstr(roleJsonList))
Ejemplo n.º 17
0
def role_foo_has_permission_of_bar(step, role, permission):
    # This takes 2 requests to complete
    #    1: get the id of the role
    #    2: check that role has that permission
    
    # fetch the user's resource identity
    role_id = get_role_resid(role)

    world.conn.request("GET", add_params(world.path_roles + role_id + "/permissions"))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched a permission")

    permJsonList = get_resp_list(response, "permission")
    # walk through all roles for this user to see if it has the requested one
    for item in permJsonList:
        found = False
        if (item.get(ns("description")) == permission):
            found = True
    assert_equal(found, True, "looking for permission of " + permission)
Ejemplo n.º 18
0
def test_case_foo_has_attachment_bar(step, test_case, haveness, attachment):
    # fetch the test case's resource identity
    test_case_id = get_test_case_resid(test_case)
    
    
#    if haveness.strip() == "does not have":

    world.conn.request("GET", add_params(world.path_testcases + test_case_id + "/attachments"))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched environments")

    jsonList = get_resp_list(response, "attachment")

    found = False
    for item in jsonList:
        if (item.get(ns("fileName")) == attachment):
            found = True
    
    shouldFind = (haveness == "has")
    assert_equal(found, shouldFind, "looking for attachment of " + attachment + " in:\n" + jstr(jsonList))
Ejemplo n.º 19
0
def check_role_existence(roles):
    
    # fetch the user's resource identity
    world.conn.request("GET", add_params(world.path_roles))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched list of all roles")

    respJson = get_resp_list(response, "role")

    # now walk through the expected roles and check the response
    # to see that it is represented
    for exp_role in roles:
        found = False
        for act_role in respJson:
            exp = exp_role.get(ns("description"))
            act = act_role.get(ns("description"))
            if (exp == act):
                found = True
        assert_equal(found, True, "Didn't find role of:\n" + jstr(exp_role) + 
                     "\n in data:\n" + jstr(respJson))
Ejemplo n.º 20
0
def user_foo_check_registration(step, name, registered):
    names = name.split()
    headers = {'Content-Type':'application/json',
               'Authorization': get_auth_header()}

    world.conn.request("GET", add_params(world.path_users, 
                                         {"firstName": names[0], "lastName": names[1]}), "", headers)
    response = world.conn.getresponse()

    assert_equal(response.status, 200, "registration status")

    
    if registered.strip() == "not":
        # expect an empty search result
        count = get_count(response, "user")
        assert_equal(count, 0, "result size zero")
    else:

        userJson = get_single_item(response, "user")
        assert_equal(userJson.get(ns("firstName")), names[0], "First Name field didn't match")
        assert_equal(userJson.get(ns("lastName")), names[1], "Last Name field didn't match")
Ejemplo n.º 21
0
def product_foo_has_environment_bar(step, product, haveness, environment):
    # fetch the product's resource identity
    product_id = get_product_resid(product)
    
    
#    if haveness.strip() == "does not have":

    world.conn.request("GET", add_params(world.path_products + product_id + "/environments"))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched environments")

    jsonList = get_resp_list(response, "environment")

    found = False
    for item in jsonList:
        assert isinstance(item, dict), "expected a list of dicts in:\n" + jstr(jsonList)
        if (item.get(ns("name")) == environment):
            found = True
    
    shouldFind = (haveness == "has")
    assert_equal(found, shouldFind, "looking for environment of " + environment)
Ejemplo n.º 22
0
def foo_has_these_roles(step, name):
    user_id = get_user_resid(name)

    world.conn.request("GET", add_params(world.path_users + user_id + "/roles"))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched a user")

    # walk through all roles for this user to see if it has the requested one
    respJson = get_resp_list(response, "role")

    # now walk through the expected roles and check the response
    # to see that it is represented
    roles = step.hashes
    for exp_role in roles:
        found = False
        for act_role in respJson:
            exp = exp_role.get(ns("description"))
            act = act_role.get(ns("description"))
            if (exp == act):
                found = True
        assert_equal(found, True, "expected role of: " + exp)
Ejemplo n.º 23
0
def foo_has_these_assignments(step, name):
    user_id = get_user_resid(name)
    world.conn.request("GET", add_params(world.path_users + user_id + "/assignments"))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, "Fetched a user")

    # walk through all roles for this user to see if it has the requested one
    respJson = get_resp_list(response, "testcase")

    # now walk through the expected roles and check the response
    # to see that it is represented
    exp_list = step.hashes
    for exp_item in exp_list:
        found = False
        for act_item in respJson:
            exp = exp_item.get(ns("name"))
            act = act_item.get(ns("name"))
            if (exp == act):
                found = True
        assert_equal(found, True, "expected assignment of: " + str(exp) +
                      "\nin response:\n" + jstr(respJson))
Ejemplo n.º 24
0
def activate_deactivate_user_foo(step, action, name):
    user_id = get_user_resid(name)
    
    world.conn.request("PUT", add_params(world.path_users + user_id + "/" + action))
    response = world.conn.getresponse()
    assert_equal(response.status, 200, action +"ed user")