def test_missing_token(self, api_client):
     response = api_client.post(self.google_login_url, {})
     assert_validation_code(
         response_json=response.json(),
         attribute='token',
         code='required',
     )
Beispiel #2
0
 def test_required_refresh_token(self, auth_api_client):
     response = auth_api_client.post(self.test_logout_url, {})
     assert response.status_code == status.HTTP_400_BAD_REQUEST
     assert_validation_code(
         response_json=response.json(),
         attribute='refreshToken',
         code='required',
     )
 def test_reset_password_required_fields(self, api_client):
     response = api_client.post(self.reset_password_url)
     assert response.status_code == status.HTTP_400_BAD_REQUEST
     assert_validation_code(
         response_json=response.json(),
         attribute='user',
         code='required',
     )
 def test_email_confirmation_required_fields(self, api_client):
     response = api_client.post(self.email_confirmation_url)
     assert response.status_code == status.HTTP_400_BAD_REQUEST
     assert_validation_code(
         response_json=response.json(),
         attribute='token',
         code='required',
     )
 def test_register__existent_user(self, api_client, test_user):
     user_data = generate_user_profile()
     user_data['username'] = test_user.username
     response = api_client.post(self.register_url, user_data)
     assert response.status_code == status.HTTP_400_BAD_REQUEST
     assert_validation_code(
         response_json=response.json(),
         attribute='username',
         code=AccountsErrorCodes.USERNAME_ALREDY_USED.code,
     )
Beispiel #6
0
    def test_update_profile_alredy_used_username(self, auth_api_client):
        existent_user = UserFactory()
        profile = generate_user_profile()
        profile['username'] = existent_user.username

        response = auth_api_client.put(self.profile_url, data=profile)
        assert response.status_code == status.HTTP_400_BAD_REQUEST
        assert_validation_code(
            response_json=response.json(),
            attribute='username',
            code=AccountsErrorCodes.USERNAME_UNAVAILABLE.code,
        )
 def test_set_password__required_fields(self, auth_api_client):
     response = auth_api_client.post(self.password_url)
     assert_validation_code(
         response_json=response.json(),
         attribute='password',
         code='required',
     )
     assert_validation_code(
         response_json=response.json(),
         attribute='confirmPassword',
         code='required',
     )
 def test_set_password__usable_password(self, auth_api_client):
     data = {
         'password': self.new_test_password,
         'confirmPassword': self.new_test_password
     }
     response = auth_api_client.post(self.password_url, data)
     assert response.status_code == status.HTTP_400_BAD_REQUEST
     assert_validation_code(
         response_json=response.json(),
         attribute='password',
         code=AccountsErrorCodes.USER_HAS_PASSWORD.code,
     )
    def test_register__forbidden_username(self, api_client):
        forbidden_usernames = settings.USERNAME_BLACKLIST
        user_data = generate_user_profile()
        user_data['username'] = forbidden_usernames[0]

        response = api_client.post(self.register_url, user_data)
        assert response.status_code == status.HTTP_400_BAD_REQUEST
        assert_validation_code(
            response_json=response.json(),
            attribute='username',
            code=AccountsErrorCodes.USERNAME_ALREDY_USED.code,
        )
 def test_change_password__wrong_current_password(self, auth_api_client):
     data = {
         'password': '******',
         'newPassword': '******',
         'confirmPassword': '******',
     }
     response = auth_api_client.put(self.password_url, data)
     assert response.status_code == status.HTTP_400_BAD_REQUEST
     assert_validation_code(
         response_json=response.json(),
         attribute='password',
         code=AccountsErrorCodes.INVALID_PASSWORD.code,
     )
 def test_change_password__required_fields(self, auth_api_client):
     response = auth_api_client.put(self.password_url)
     assert response.status_code == status.HTTP_400_BAD_REQUEST
     assert_validation_code(
         response_json=response.json(),
         attribute='password',
         code='required',
     )
     assert_validation_code(
         response_json=response.json(),
         attribute='newPassword',
         code='required',
     )
     assert_validation_code(
         response_json=response.json(),
         attribute='confirmPassword',
         code='required',
     )