Skip to content

Commit

Permalink
feat: added unit test for social registration
Browse files Browse the repository at this point in the history
  • Loading branch information
AhtishamShahid committed Sep 11, 2024
1 parent 1ff6751 commit ecef1e1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions openedx/core/djangoapps/user_authn/views/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -2604,6 +2604,25 @@ def test_success(self):

self._verify_user_existence(user_exists=True, social_link_exists=True, user_is_active=False)

@override_waffle_switch(ENABLE_COUNTRY_DISABLING, True)
@override_settings(DISABLED_COUNTRIES=['US'])
def test_with_disabled_country(self):
"""
Test case to check user registration is forbidden when registration is disabled for a country
"""
self._verify_user_existence(user_exists=False, social_link_exists=False)
self._setup_provider_response(success=True)
response = self.client.post(self.url, self.data())
assert response.status_code == 400
assert response.json() == {
'country': [
{
'user_message': 'Registration from this country is not allowed due to restrictions.'
}
], 'error_code': 'validation-error'
}
self._verify_user_existence(user_exists=False, social_link_exists=False, user_is_active=False)

def test_unlinked_active_user(self):
user = UserFactory()
response = self.client.post(self.url, self.data(user))
Expand Down

0 comments on commit ecef1e1

Please sign in to comment.