Exemplo n.º 1
0
    def _user(role_name=None, enabled=True):
        role_name = "ROOT" if role_name is None else role_name
        role_id = get_role_id(role_name)
        user_group_and_role = make_user_group_roles({root_group_id(): role_id})
        data = {
            "$login": random_string(),
            "$fname": random_string(),
            "$lname": random_string(),
            "$password": "******",
            "$roleId": role_id,
            "$agentId": random_string(),
            "$ADlogin": random_string(),
            "$pname": random_string(),
            "$email": random_string() + '@.com.ua',
            "$phone": str(random.randint(11111, 99999999)),
            "$fax": random_string(),
            "$userGroupRoles": user_group_and_role,
            "$enabled": enabled
        }
        response = send_request.post(mgr.users, data)
        user = response.json()
        user['dateCreate'] = round(user['dateCreate'] / 1000) * 1000

        def fin():
            send_request.delete(mgr.users, id_to_url=user['userId'])

        request.addfinalizer(fin)
        return user
Exemplo n.º 2
0
 def test_addGroup_without_name(self):
     data = {"$name": None, "$parentGroupId": root_group_id()}
     response = send_request.post(mgr.groups, data)
     excepted_response = {
         'ADM_VALIDATION_GROUP_NAME': 'Group name not specified'
     }
     assert (response.status_code, response.json()) == (400,
                                                        excepted_response)
Exemplo n.º 3
0
 def test_add_role_with_templateRole(self):
     data = {
         "$name": random_string(),
         "$groupId": root_group_id(),
         "$templateRole": {
             "roleId": root_role_id()
         }
     }
     response = send_request.post(mgr.roles, data)
     assert (response.status_code,
             response.json()['templateRole']['roleId']) == (201,
                                                            root_role_id())
Exemplo n.º 4
0
def immutable_group_with_child():
    """
    :return: {}
    """
    groups_id = deque([], maxlen=5)
    data = {"$name": random_string(), "$parentGroupId": root_group_id()}
    response_parent = send_request.post(mgr.groups, data)
    groups_id.appendleft(response_parent.json()['groupId'])
    data_child = {"$name": random_string(), "$parentGroupId": groups_id[0]}
    response_child = send_request.post(mgr.groups, data_child)
    response = send_request.get(mgr.groups, id_to_url=groups_id[0])
    groups_id.appendleft(response_child.json()['groupId'])
    yield response.json()
    for i in groups_id:
        send_request.delete(mgr.groups, id_to_url=i)
Exemplo n.º 5
0
def group():
    data = {"$name": random_string(), "$parentGroupId": root_group_id()}
    response = send_request.post(mgr.groups, data)
    yield response.json()
    send_request.delete(mgr.groups, id_to_url=response.json()['groupId'])
Exemplo n.º 6
0
 def test_add_role_with_root_group(self):
     data = {"$name": random_string(), "$groupId": root_group_id()}
     response = send_request.post(mgr.roles, data)
     assert equal_schema(response.json(),
                         response.expected) and response.status_code == 201
Exemplo n.º 7
0
 def test_addGroup_with_existing_name(self, immutable_group_with_child):
     existin_group_name = immutable_group_with_child['name']
     data = {"$name": existin_group_name, "$parentGroupId": root_group_id()}
     response = send_request.post(mgr.groups, data)
     assert equal_schema(response.json(),
                         response.expected) and response.status_code == 201