Esempio n. 1
0
 def test_post(self):
     """POST "send" URL creates a signature and redirects to signer view."""
     Signature = django_anysign.get_signature_model()
     self.assertEqual(Signature.objects.all().count(), 0)
     url = reverse('send')
     response = self.client.post(url)
     self.assertEqual(Signature.objects.all().count(), 1)
     signature = Signature.objects.get()
     signer = signature.signers.all()[0]
     signer_url = signature.signature_backend.get_signer_url(signer)
     self.assertRedirects(response, signer_url)
Esempio n. 2
0
 def test_post(self):
     """POST "send" URL creates a signature and redirects to signer view."""
     Signature = django_anysign.get_signature_model()
     self.assertEqual(Signature.objects.all().count(), 0)
     url = reverse('send')
     response = self.client.post(url)
     self.assertEqual(Signature.objects.all().count(), 1)
     signature = Signature.objects.get()
     signer = signature.signers.all()[0]
     signer_url = signature.signature_backend.get_signer_url(signer)
     self.assertRedirects(response, signer_url)
Esempio n. 3
0
    def test_get(self):
        """GET "anysign:signer" URL returns HTTP 200."""
        # Create a signature.
        SignatureType = django_anysign.get_signature_type_model()
        Signature = django_anysign.get_signature_model()
        Signer = django_anysign.get_signer_model()
        signature_type, created = SignatureType.objects.get_or_create(
            signature_backend_code='dummysign')
        signature = Signature.objects.create(signature_type=signature_type)
        signer = Signer()
        signature.signers.add(signer)

        url = reverse('anysign:signer', args=[signer.pk])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
Esempio n. 4
0
    def test_get(self):
        """GET "anysign:signer" URL returns HTTP 200."""
        # Create a signature.
        SignatureType = django_anysign.get_signature_type_model()
        Signature = django_anysign.get_signature_model()
        Signer = django_anysign.get_signer_model()
        signature_type, created = SignatureType.objects.get_or_create(
            signature_backend_code='dummysign')
        signature = Signature.objects.create(signature_type=signature_type)
        signer = Signer()
        signature.signers.add(signer)

        url = reverse('anysign:signer', args=[signer.pk])
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)
Esempio n. 5
0
 def form_valid(self, form):
     # Create signature instance in local DB.
     SignatureType = django_anysign.get_signature_type_model()
     Signature = django_anysign.get_signature_model()
     Signer = django_anysign.get_signer_model()
     signature_type, created = SignatureType.objects.get_or_create(
         signature_backend_code='dummysign')
     signature = Signature.objects.create(signature_type=signature_type)
     signer = Signer()
     signature.signers.add(signer)
     logger.debug(
         '[django_anysign_demo] Signature ID={id} created in local DB'
         .format(id=signature.id))
     # Register signature in backend's DB.
     signature.signature_backend.create_signature(signature)
     # Remember the signature object for later use (:meth:`get_success_url`)
     self.signature = signature
     # Handle the form as always.
     return FormView.form_valid(self, form)
Esempio n. 6
0
    def test_post(self):
        """POST "anysign:signer" URL redirects to "signer return"."""
        # Create a signature.
        SignatureType = django_anysign.get_signature_type_model()
        Signature = django_anysign.get_signature_model()
        Signer = django_anysign.get_signer_model()
        signature_type, created = SignatureType.objects.get_or_create(
            signature_backend_code='dummysign')
        signature = Signature.objects.create(signature_type=signature_type)
        signer = Signer()
        signature.signers.add(signer)

        url = reverse('anysign:signer', args=[signer.pk])
        response = self.client.post(url, follow=True)
        signer_return_url = signature.signature_backend.get_signer_return_url(
            signer)
        self.assertEqual(signer_return_url,
                         reverse('anysign:signer_return', args=[signer.pk]))
        self.assertRedirects(response, signer_return_url)
        self.assertEqual(response.status_code, 200)
Esempio n. 7
0
    def test_post(self):
        """POST "anysign:signer" URL redirects to "signer return"."""
        # Create a signature.
        SignatureType = django_anysign.get_signature_type_model()
        Signature = django_anysign.get_signature_model()
        Signer = django_anysign.get_signer_model()
        signature_type, created = SignatureType.objects.get_or_create(
            signature_backend_code='dummysign')
        signature = Signature.objects.create(signature_type=signature_type)
        signer = Signer()
        signature.signers.add(signer)

        url = reverse('anysign:signer', args=[signer.pk])
        response = self.client.post(url, follow=True)
        signer_return_url = signature.signature_backend.get_signer_return_url(
            signer)
        self.assertEqual(
            signer_return_url,
            reverse('anysign:signer_return', args=[signer.pk])
        )
        self.assertRedirects(response, signer_return_url)
        self.assertEqual(response.status_code, 200)