def test_create_tenant_fail_for_existing_domain(rs_json=None):
    # get existing domain from DB
    tenant_dao = TenantsDAO()
    existing_tenant = tenant_dao.get_random_tenant_from_db()
    existing_domain = existing_tenant[0]['domain']
    existing_name = existing_tenant[0]['name']

    # make API call
    tenant_object = RequestUtility()
    payload = {
        'domain': existing_domain,
        'admin': 2,
        'admin_name': 'adiAdmin',
        'name': existing_name
    }

    tenant_api_info = tenant_object.post(endpoint='api/tenants/tenant/',
                                         payload=payload,
                                         expected_status_code=400)

    # verify the response
    error_message = "['Client with this Subdomain already exists.']"

    assert str(tenant_api_info['domain']) == error_message, f"Expected: {error_message}" \
                                                            f" Actual: {str(tenant_api_info['domain'])} "
def test_create_user_fail_for_existing_email(rs_json=None):
    # get existing email from DB
    user_dao = UsersDAO()
    existing_user = user_dao.get_random_user_from_db()
    existing_email = existing_user[0]['email']
    existing_nick = existing_user[0]['nick_name']
    existing_calendar_url = existing_user[0]['calendar_url']
    existing_mfa = existing_user[0]['mfa_enabled']

    # make API call
    user_object = RequestUtility()
    payload = {'email': existing_email, 'nick_name': existing_nick, 'roles': ['tenant_user'],
               'mfa_enabled': existing_mfa, 'first_name': 'First User', 'last_name': 'Last', 'username': existing_email,
               'calendar_url': existing_calendar_url}
    user_api_info = user_object.post(endpoint='api/users/user/', payload=payload, expected_status_code=400)

    # verify the response
    error_message = "['This field must be unique.']"

    assert str(user_api_info['email']) == error_message, f"Expected: 'This field must be unique.' Actual: " \
                                                         f"{str(user_api_info['email'])} "
    # pdb.set_trace()


    #test test test
Exemple #3
0
def test_get_all_invoices():
    logger.info('Fetch and display all existing invoices: ')
    req_helper = RequestUtility()
    rs_api = req_helper.get('api/boast_invoicing/invoices/')

    assert rs_api, f"Response of the list 'all invoices' is empty."

    pdb.set_trace()
Exemple #4
0
class GetTenantHelper(object):
    def __init__(self):
        self.request_utility = RequestUtility()

    def get_tenant_by_id(self, tenant_id):
        return self.request_utility.get(f"api/tenants/tenant/{tenant_id}/")

    def call_create_tenant(self, payload):
        return self.request_utility.post('api/tenants/tenant/',
                                         payload=payload,
                                         expected_status_code=201)
Exemple #5
0
class CreateUserHelper(object):

    def __init__(self):
        self.requests_utility = RequestUtility()

    def call_create_users(self, email=None, **kwargs):

        if not email:
            email = generate_random_user_email()
            email = email['email']

        payload = dict()
        payload['email'] = email
        payload.update(kwargs)

        create_user_json = self.requests_utility.post('api/users/user/', payload=payload,
                                                      expected_status_code=201)
        return create_user_json

    def get_user_by_id(self, id_rand_user):
        return self.requests_utility.get(f"api/users/user/{id_rand_user}/")
Exemple #6
0
def test_get_all_tenants():
    logger.info('Fetch and display all boast tenants: ')
    req_helper = RequestUtility()
    rs_api = req_helper.get('api/tenants/tenant/')

    assert rs_api, f"Response of the list 'all tenants' is empty."
Exemple #7
0
def test_get_all_users():
    logger.info('Fetch and display all boast users: ')
    req_helper = RequestUtility()
    rs_api = req_helper.get('api/users/user/')

    assert rs_api, f"Response of the list 'all users' is empty. "
Exemple #8
0
 def __init__(self):
     self.request_utility = RequestUtility()
Exemple #9
0
def test_get_all_logs():
    logger.info('Fetch and display all boast logs: ')
    req_helper = RequestUtility()
    rs_api = req_helper.get('api/apputils/backgroundtask/')

    assert rs_api, f"Response of the list 'all logs' is empty. "