Beispiel #1
0
    def testN_login_with_inexistent_user(self):
        '''
        1. The response status code should be unauthorized;
        2. The user should not be allowed to sign in and an error message should be returned in response payload
        '''
        r = post(auth_login_endpoint,
                 json=payload.login('*****@*****.**', 'foo1234'),
                 headers=headers(vungle_src='pub'))

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.FORBIDDEN)
        assert_valid_schema(r.json(), response_schema.payload_check_error)
Beispiel #2
0
def _get_user_token(username, password):
    from qa.utils.common import post, headers
    from qa.utils import payload
    login_payload = payload.login(username, password)

    r = post(auth_login_endpoint,
             json=login_payload,
             headers=headers(vungle_src='pub'))
    if r.status_code != 200:
        raise Exception(
            "Failed to sign in with the credentitial: username=%s, password=%s"
            % (username, password))
    return r.json()['token']
Beispiel #3
0
    def testN_login_without_vungle_source_in_headers(self):
        '''
        1. An error message should be returned in the resposne payload;
        2. The response status code should be HTTP 400 bad request;
        '''
        login_payload = payload.login(test_accounts['pub']['username'],
                                      test_accounts['pub']['password'])

        r = post(auth_login_endpoint, json=login_payload, headers=headers())

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.BAD_REQUEST)
        assert_valid_schema(r.json(), response_schema.payload_check_error)
Beispiel #4
0
    def testN_login_without_vungle_version(self):
        '''
        
        '''
        login_payload = payload.login(test_accounts['pub']['username'],
                                      test_accounts['pub']['password'])

        r = requests.post(auth_login_endpoint,
                          json=login_payload,
                          headers=headers(vungle_version=None))

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.BAD_REQUEST)
        assert_valid_schema(r.json(), response_schema.payload_check_error)
Beispiel #5
0
    def test_login_with_valid_vungle_source_val_api(self):
        '''
        1.  The response status code should be HTTP 200 OK;
        2.  The user should be able to login into the system and get correct access token;
        '''

        r = post(auth_login_endpoint,
                 json=payload.login(test_accounts['pub']['username'],
                                    test_accounts['pub']['password']),
                 headers=headers(vungle_src='api'))

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.OK)

        # Verify response body
        assert_that(r.json(), has_key('token'))
Beispiel #6
0
    def testN_login_with_invalid_vungle_src_val(self):
        '''
        1. The response status code should be HTTP 400;
        2. User should not be allowed to sign in and an error message should be returned.
        '''
        login_payload = payload.login(test_accounts['pub']['username'],
                                      test_accounts['pub']['password'])

        invalid_src_param = 'foo'
        r = requests.post(auth_login_endpoint,
                          json=login_payload,
                          headers=headers(vungle_src=invalid_src_param))

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.BAD_REQUEST)
        assert_valid_schema(r.json(), response_schema.payload_check_error)
Beispiel #7
0
    def testN_login_with_incorrect_password(self):
        '''
        1. The response status code should be unauthorized;
        2. The user should not be allowed to login in and an error message should be returned.
        '''
        account_type = 'pub'
        incorrect_password = '******'

        r = post(auth_login_endpoint,
                 json=payload.login(test_accounts[account_type]['username'],
                                    incorrect_password),
                 headers=headers(vungle_src=account_type))

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.FORBIDDEN)
        assert_valid_schema(r.json(), response_schema.payload_check_error)
Beispiel #8
0
    def testN_login_with_inactivated_user(self, new_registered_user):
        '''
        1. The response status code should be HTTP 403;
        2. An error message should be returned in the response payload
        '''

        username = new_registered_user[0]
        password = new_registered_user[1]

        # Send post request
        r = post(auth_login_endpoint,
                 json=payload.login(username, password),
                 headers=headers(vungle_src='pub'))

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.FORBIDDEN)
        assert_valid_schema(r.json(), response_schema.payload_check_error)
Beispiel #9
0
    def test_login_with_valid_vungle_source_val(self, val):
        '''
        1.  The response status code should be HTTP 200 OK;
        2.  The user should be able to login into the system and get correct access token;
        '''

        r = post(auth_login_endpoint,
                 json=payload.login(test_accounts['pub']['username'],
                                    test_accounts['pub']['password']),
                 headers=headers(vungle_src=val))

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.OK)

        # Verify response body
        expected_response_payload = {
            'username': test_accounts['pub']['username'],
            'account_type': 'publisher'
        }
        assert_that(r.json(), has_entries(expected_response_payload))
        assert_that(r.json(), has_key('token'))
Beispiel #10
0
    def test_login_with_valid_user(self, account_type, username, password,
                                   expected_account_type):
        '''
        1.  The response status code should be HTTP 200 OK;
        2.  The user should be able to login into the system and get correct access token;
        '''
        # Send post request
        r = post(auth_login_endpoint,
                 json=payload.login(username, password),
                 headers=headers(vungle_src='pub'))

        # Verify status code
        assert_response_status_code(r.status_code, HTTPStatus.OK)

        # Verify response body
        expected_response_payload = {
            'username': username,
            'account_type': expected_account_type
        }
        assert_that(r.json(), has_entries(expected_response_payload))
        assert_that(r.json(), has_key('token'))