Example #1
0
    def test_wrong_customer_authentication_failed(self):
        bad_instance = AIS(customer="wrong_name", key_static="wrong_key",
                           cert_file=self.cert_file,
                           cert_key=self.cert_key)

        with self.assertRaises(AuthenticationFailed):
            with my_vcr.use_cassette('wrong_customer'):
                bad_instance.sign_one_pdf(PDF(fixture_path('one.pdf')))
Example #2
0
    def test_sign_single_unprepared_pdf(self):
        self.assertIsNone(self.instance.last_request_id)

        pdf = PDF(fixture_path('one.pdf'))
        with my_vcr.use_cassette('sign_unprepared_pdf'):
            self.instance.sign_one_pdf(pdf)

        self.assertIsNotNone(self.instance.last_request_id)
Example #3
0
 def test_sign_batch(self):
     pdfs = [
         PDF(fixture_path(filename))
         for filename in ["one.pdf", "two.pdf", "three.pdf"]
     ]
     with my_vcr.use_cassette('sign_batch'):
         self.instance.sign_batch(pdfs)
     from pprint import pprint as pp
     pp([p.out_filename for p in pdfs])
Example #4
0
    def test_sign_batch(self):
        self.assertIsNone(self.instance.last_request_id)

        pdfs = [PDF(fixture_path(filename))
                for filename in ["one.pdf", "two.pdf", "three.pdf"]]
        with my_vcr.use_cassette('sign_batch'):
            self.instance.sign_batch(pdfs)

        self.assertIsNotNone(self.instance.last_request_id)
Example #5
0
    def test_prepare_then_get_digest(self):
        pdf = PDF(fixture_path('one.pdf'))

        pdf.prepare()
        self.assertEqual(44, len(pdf.digest()))  # digest changes every time
Example #6
0
    def test_get_digest_of_prepared_file(self):
        pdf = PDF(fixture_path('prepared.pdf'), prepared=True)

        with open(fixture_path('expected_digest')) as fp:
            self.assertEqual(fp.read().strip(), pdf.digest())
Example #7
0
 def test_sign_single_unprepared_pdf(self):
     pdf = PDF(fixture_path('one.pdf'))
     with my_vcr.use_cassette('sign_unprepared_pdf'):
         self.instance.sign_one_pdf(pdf)
Example #8
0
 def test_sign_single_prepared_pdf(self):
     pdf = PDF(fixture_path('prepared.pdf'), prepared=True)
     with my_vcr.use_cassette('sign_prepared_pdf'):
         self.instance.sign_one_pdf(pdf)
Example #9
0
    def test_prepare_then_get_digest(self):
        pdf = PDF(fixture_path('one.pdf'))

        pdf.prepare()
        self.assertEqual(44, len(pdf.digest()))   # digest changes every time
Example #10
0
    def test_get_digest_of_prepared_file(self):
        pdf = PDF(fixture_path('prepared.pdf'), prepared=True)

        with open(fixture_path('expected_digest')) as fp:
            self.assertEqual(fp.read().strip(), pdf.digest())