예제 #1
0
 def test_post(self, status, application_exists, new_application_created):
     """
     Verify that posting the form creates an application if the user is
     approved, and does not otherwise. Also ensure that if the user
     already has an application, it is deleted before a new
     application is created.
     """
     if application_exists:
         old_application = ApplicationFactory(user=self.user)
     ApiAccessRequestFactory(user=self.user, status=status)
     self.client.post(self.url, {
         'name': 'test.com',
         'redirect_uris': 'http://example.com'
     })
     applications = Application.objects.filter(user=self.user)
     if application_exists and new_application_created:
         self.assertEqual(applications.count(), 1)
         self.assertNotEqual(old_application, applications[0])
     elif application_exists:
         self.assertEqual(applications.count(), 1)
         self.assertEqual(old_application, applications[0])
     elif new_application_created:
         self.assertEqual(applications.count(), 1)
     else:
         self.assertEqual(applications.count(), 0)
예제 #2
0
 def test_get_with_existing_application(self):
     """
     Verify that if the user has created their client credentials, they
     are shown on the status page.
     """
     ApiAccessRequestFactory(user=self.user, status=ApiAccessRequest.APPROVED)
     application = ApplicationFactory(user=self.user)
     response = self.client.get(self.url)
     self.assertContains(response, application.client_secret)
     self.assertContains(response, application.client_id)
     self.assertContains(response, application.redirect_uris)
예제 #3
0
 def test_get_with_existing_application(self):
     """
     Verify that if the user has created their client credentials, they
     are shown on the status page.
     """
     ApiAccessRequestFactory(user=self.user, status=ApiAccessRequest.APPROVED)
     application = ApplicationFactory(user=self.user)
     response = self.client.get(self.url)
     self.assertEqual(response.status_code, 200)
     unicode_content = response.content.decode('utf-8')
     self.assertIn(application.client_secret, unicode_content)  # pylint: disable=no-member
     self.assertIn(application.client_id, unicode_content)  # pylint: disable=no-member
     self.assertIn(application.redirect_uris, unicode_content)  # pylint: disable=no-member