예제 #1
0
파일: test_ais.py 프로젝트: cyrilgdn/AIS.py
 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])
예제 #2
0
    def test_sign_filename_returns_signature(self):
        with my_vcr.use_cassette('sign_one') as cassette:
            result = self.instance.sign(filename=fixture_path('one.pdf'))

        self.assertEqual(1, len(cassette))
        self.assertIsInstance(result, Signature)
        self.assertIsInstance(result.contents, bytes)
예제 #3
0
파일: test_ais.py 프로젝트: cyrilgdn/AIS.py
    def test_sign_filename_returns_signature(self):
        with my_vcr.use_cassette('sign_one') as cassette:
            result = self.instance.sign(filename=fixture_path('one.pdf'))

        self.assertEqual(1, len(cassette))
        self.assertIsInstance(result, Signature)
        self.assertIsInstance(result.contents, bytes)
예제 #4
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)
예제 #5
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')))
예제 #6
0
파일: test_ais.py 프로젝트: seantis/AIS.py
    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')))
예제 #7
0
파일: test_ais.py 프로젝트: seantis/AIS.py
    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)
예제 #8
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])
예제 #9
0
파일: test_ais.py 프로젝트: seantis/AIS.py
    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)
예제 #10
0
    def setUp(self):
        """Setup an AIS instance to be used in the tests.

        If you have real credentials to AIS and wish to use them to run tests,
        you can set the AIS_CUSTOMER, AIS_KEY_STATIC, AIS_CERT_FILE and
        AIS_CERT_KEY environment variables.

        Tests should still pass without them, including on CI and offline,
        because the interaction to the webservice are mocked and stored as
        cassettes. Delete the cassettes and set those variables to test with
        real interactions.

        """
        self.customer = environ.get('AIS_CUSTOMER', 'bonnie')
        self.key_static = environ.get('AIS_KEY_STATIC', 'the_secret')
        self.cert_file = environ.get('AIS_CERT_FILE', fixture_path('test.crt'))
        self.cert_key = environ.get('AIS_CERT_KEY', fixture_path('test.key'))

        self.instance = AIS(self.customer, self.key_static, self.cert_file,
                            self.cert_key)
예제 #11
0
    def setUp(self):
        """Setup an AIS instance to be used in the tests.

        If you have real credentials to AIS and wish to use them to run tests,
        you can set the AIS_CUSTOMER, AIS_KEY_STATIC, AIS_CERT_FILE and
        AIS_CERT_KEY environment variables.

        Tests should still pass without them, including on CI and offline,
        because the interaction to the webservice are mocked and stored as
        cassettes. Delete the cassettes and set those variables to test with
        real interactions.

        """
        self.customer = environ.get('AIS_CUSTOMER', 'bonnie')
        self.key_static = environ.get('AIS_KEY_STATIC', 'the_secret')
        self.cert_file = environ.get('AIS_CERT_FILE', fixture_path('test.crt'))
        self.cert_key = environ.get('AIS_CERT_KEY', fixture_path('test.key'))

        self.instance = AIS(self.customer, self.key_static,
                            self.cert_file, self.cert_key)
예제 #12
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
예제 #13
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())
예제 #14
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)
예제 #15
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)
예제 #16
0
파일: test_ais.py 프로젝트: cyrilgdn/AIS.py
 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)
예제 #17
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
예제 #18
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())
예제 #19
0
파일: test_ais.py 프로젝트: cyrilgdn/AIS.py
 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)