Example #1
0
 def login(self, resp_mock, process='login', with_refresh_token=True):
     resp = self.client.get(reverse(self.provider.id + '_login'), {
         'process': process,
         'shop': 'test'
     })
     self.assertEqual(resp.status_code, 200)  # No re-direct, JS must do it
     actual_content = resp.content.decode('utf8')
     self.assertTrue(
         'script' in actual_content,
         'Content missing script tag. [Actual: {}]'.format(actual_content))
     self.assertTrue(
         resp.xframe_options_exempt,
         'Redirect JS must be allowed to run in Shopify iframe')
     self.assertTrue(
         '<!DOCTYPE html><html><head>' in actual_content
         and '</head><body></body></html>' in actual_content,
         'Expected standard HTML skeleton. [Actual: {}]'.format(
             actual_content))
     p = urlparse(
         actual_content.split(";</script>")[0].split('location.href = "')
         [1])
     q = parse_qs(p.query)
     resp = self._complete_shopify_login(q, resp, resp_mock,
                                         with_refresh_token)
     return resp
Example #2
0
 def login(self, resp_mock, process='login', with_refresh_token=True):
     resp = self.client.get(reverse(self.provider.id + '_login'),
                            {'process': process, 'shop': 'test'})
     self.assertEqual(resp.status_code, 302)
     p = urlparse(resp['location'])
     q = parse_qs(p.query)
     resp = self._complete_shopify_login(q, resp, resp_mock,
                                         with_refresh_token)
     return resp
Example #3
0
 def login(self, resp_mock, process='login', with_refresh_token=True):
     resp = self.client.get(reverse(self.provider.id + '_login'),
                            {'process': process, 'shop': 'test'})
     self.assertEqual(resp.status_code, 302)
     p = urlparse(resp['location'])
     q = parse_qs(p.query)
     resp = self._complete_shopify_login(q, resp, resp_mock,
                                         with_refresh_token)
     return resp
Example #4
0
 def login(self, resp_mock, process='login', with_refresh_token=True):
     resp = self.client.get(reverse(self.provider.id + '_login'), {
         'process': process,
         'shop': 'test'
     })
     p = urlparse(resp['location'])
     q = parse_qs(p.query)
     complete_url = reverse(self.provider.id + '_callback')
     self.assertGreater(q['redirect_uri'][0].find(complete_url), 0)
     response_json = self \
         .get_login_response_json(with_refresh_token=with_refresh_token)
     with mocked_response(
             MockedResponse(200, response_json,
                            {'content-type': 'application/json'}),
             resp_mock):
         resp = self.client.get(complete_url, {
             'code': 'test',
             'state': q['state'][0],
             'shop': 'test',
         })
     return resp
Example #5
0
 def login(self, resp_mock, process='login', with_refresh_token=True):
     resp = self.client.get(reverse(self.provider.id + '_login'),
                            {'process': process, 'shop': 'test'})
     p = urlparse(resp['location'])
     q = parse_qs(p.query)
     complete_url = reverse(self.provider.id+'_callback')
     self.assertGreater(q['redirect_uri'][0]
                        .find(complete_url), 0)
     response_json = self \
         .get_login_response_json(with_refresh_token=with_refresh_token)
     with mocked_response(
             MockedResponse(
                 200,
                 response_json,
                 {'content-type': 'application/json'}),
             resp_mock):
         resp = self.client.get(complete_url,
                                {'code': 'test',
                                 'state': q['state'][0],
                                 'shop': 'test',
                                 })
     return resp
Example #6
0
 def login(self, resp_mock, process='login', with_refresh_token=True):
     resp = self.client.get(reverse(self.provider.id + '_login'),
                            {'process': process, 'shop': 'test'})
     self.assertEqual(resp.status_code, 200)  # No re-direct, JS must do it
     actual_content = resp.content.decode('utf8')
     self.assertTrue('script' in actual_content,
                     'Content missing script tag. [Actual: {}]'.format(
                         actual_content))
     self.assertTrue(resp.xframe_options_exempt,
                     'Redirect JS must be allowed to run in Shopify iframe')
     self.assertTrue(
         '<!DOCTYPE html><html><head>' in actual_content and
         '</head><body></body></html>' in actual_content,
         'Expected standard HTML skeleton. [Actual: {}]'.format(
             actual_content
         )
     )
     p = urlparse(actual_content.split(";</script>")[0].split(
         'location.href = "')[1])
     q = parse_qs(p.query)
     resp = self._complete_shopify_login(q, resp, resp_mock,
                                         with_refresh_token)
     return resp