Verify valid product
This commit is contained in:
parent
8c9d40cbc7
commit
0e95e872c8
|
|
@ -74,8 +74,8 @@ class Login(relay.ClientIDMutation):
|
|||
product['raw'], product['edition'])
|
||||
# todo handle no license case
|
||||
else:
|
||||
# todo go to shop
|
||||
pass
|
||||
error = LoginError(field='no_valid_license')
|
||||
return cls(success=False, errors=[error])
|
||||
|
||||
UserRole.objects.create_role_for_user(user, license.for_role.key)
|
||||
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class PasswordResetTests(TestCase):
|
|||
self.assertTrue(self.user.is_authenticated)
|
||||
|
||||
@patch.object(requests, 'post', return_value=MockResponse(401))
|
||||
def test_user_with_no_login_cannot_login(self, post_fn):
|
||||
def test_user_with_no_login_cannot_login(self, post_mock):
|
||||
result = self.make_login_mutation(ME_DATA['email'], 'test123')
|
||||
|
||||
self.assertFalse(result.get('data').get('login').get('success'))
|
||||
|
|
@ -168,7 +168,7 @@ class PasswordResetTests(TestCase):
|
|||
@patch.object(HepClient, 'customer_token', return_value={'token': FAKE_TOKEN})
|
||||
@patch.object(HepClient, 'is_email_verified', return_value=False)
|
||||
@patch.object(HepClient, 'customer_me', return_value=ME_DATA)
|
||||
def test_user_with_unconfirmed_email_cannot_login(self, me_fn, post_fn, token_fn):
|
||||
def test_user_with_unconfirmed_email_cannot_login(self, me_mock, post_mock, token_mock):
|
||||
result = self.make_login_mutation(ME_DATA['email'], 'test123')
|
||||
|
||||
user = User.objects.get(email=ME_DATA['email'])
|
||||
|
|
@ -178,13 +178,25 @@ class PasswordResetTests(TestCase):
|
|||
self.assertFalse(result.get('data').get('login').get('success'))
|
||||
self.assertEqual(result.get('data').get('login').get('errors')[0].get('field'), 'email_not_verified')
|
||||
|
||||
@patch.object(HepClient, 'customer_token', return_value={'token': FAKE_TOKEN})
|
||||
@patch.object(HepClient, 'myskillbox_product_for_customer', return_value=None)
|
||||
@patch.object(HepClient, 'customer_me', return_value=ME_DATA)
|
||||
def test_user_cannot_login_without_license(self, me_mock, product_mock, token_mock):
|
||||
result = self.make_login_mutation(self.user.email, 'test123')
|
||||
|
||||
token = MagentoToken.objects.get(user=self.user)
|
||||
self.assertEqual(token.token, FAKE_TOKEN)
|
||||
|
||||
self.assertFalse(result.get('data').get('login').get('success'))
|
||||
self.assertEqual(result.get('data').get('login').get('errors')[0].get('field'), 'no_valid_license')
|
||||
|
||||
## can login with license and user
|
||||
## can login with no user and license
|
||||
# ?can login with no user and local license
|
||||
## cannot login without user
|
||||
## cannot login with user and not verfied
|
||||
# cannot login with user and no license
|
||||
# cannot login with user and expired license
|
||||
## cannot login with user and no license
|
||||
## cannot login with user and expired license
|
||||
# non 200 error
|
||||
# if more than one valid license take correct
|
||||
# if mulitple licenses and one correct take one test in own class
|
||||
|
|
|
|||
Loading…
Reference in New Issue