Verify error message
This commit is contained in:
parent
9856693ea6
commit
8c9d40cbc7
|
|
@ -61,8 +61,8 @@ class Login(relay.ClientIDMutation):
|
||||||
magento_token.save()
|
magento_token.save()
|
||||||
|
|
||||||
if not hep_client.is_email_verified(username):
|
if not hep_client.is_email_verified(username):
|
||||||
# Todo handle unverifed emails
|
error = LoginError(field='email_not_verified')
|
||||||
pass
|
return cls(success=False, errors=[error])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
license = License.objects.get(licensee=user)
|
license = License.objects.get(licensee=user)
|
||||||
|
|
|
||||||
|
|
@ -163,20 +163,26 @@ class PasswordResetTests(TestCase):
|
||||||
result = self.make_login_mutation(ME_DATA['email'], 'test123')
|
result = self.make_login_mutation(ME_DATA['email'], 'test123')
|
||||||
|
|
||||||
self.assertFalse(result.get('data').get('login').get('success'))
|
self.assertFalse(result.get('data').get('login').get('success'))
|
||||||
# todo check message
|
self.assertEqual(result.get('data').get('login').get('errors')[0].get('field'), 'invalid_credentials')
|
||||||
|
|
||||||
|
@patch.object(HepClient, 'customer_token', return_value={'token': FAKE_TOKEN})
|
||||||
@patch.object(HepClient, 'is_email_verified', return_value=False)
|
@patch.object(HepClient, 'is_email_verified', return_value=False)
|
||||||
def test_user_with_unconfirmed_email_cannot_login(self, post_fn):
|
@patch.object(HepClient, 'customer_me', return_value=ME_DATA)
|
||||||
|
def test_user_with_unconfirmed_email_cannot_login(self, me_fn, post_fn, token_fn):
|
||||||
result = self.make_login_mutation(ME_DATA['email'], 'test123')
|
result = self.make_login_mutation(ME_DATA['email'], 'test123')
|
||||||
|
|
||||||
|
user = User.objects.get(email=ME_DATA['email'])
|
||||||
|
token = MagentoToken.objects.get(user=user)
|
||||||
|
self.assertEqual(token.token, FAKE_TOKEN)
|
||||||
|
|
||||||
self.assertFalse(result.get('data').get('login').get('success'))
|
self.assertFalse(result.get('data').get('login').get('success'))
|
||||||
# todo check message
|
self.assertEqual(result.get('data').get('login').get('errors')[0].get('field'), 'email_not_verified')
|
||||||
|
|
||||||
## can login with license and user
|
## can login with license and user
|
||||||
## can login with no user and license
|
## can login with no user and license
|
||||||
# ?can login with no user and local license
|
# ?can login with no user and local license
|
||||||
## cannot login without user
|
## cannot login without user
|
||||||
# cannot login with user and not verfied
|
## cannot login with user and not verfied
|
||||||
# cannot login with user and no license
|
# cannot login with user and no license
|
||||||
# cannot login with user and expired license
|
# cannot login with user and expired license
|
||||||
# non 200 error
|
# non 200 error
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue