Beispiel #1
0
 def test_pkcs12_encrypted_no_pw(self):
     with CreateRequest("/certificates/add", TestCertificates.PKCS12_rsa_encrypted, password="") as request:
         handler = AddHandler.by_request(request)
         (req, page, context) = handler.handle()
     self.assertEqual("certificates/add.html", page)
     self.assertEqual(0, self.privatekeys_count())
     self.assertEqual(0, self.certificates_count())
Beispiel #2
0
 def test_pkcs1_without_certificate(self):
     with CreateRequest("/certificates/add", TestCertificates.PKCS1_ec) as request:
         handler = AddHandler.by_request(request)
         (req, page, context) = handler.handle()
     self.assertEqual("certificates/add.html", page)
     self.assertEqual(0, self.certificates_count())
     self.assertEqual(0, self.privatekeys_count())
Beispiel #3
0
 def test_x509_with_pw(self):
     with CreateRequest("/certificates/add", TestCertificates.X509_rsa_ca, password="******") as request:
         handler = AddHandler.by_request(request)
         (req, page, context) = handler.handle()
         self.assertEqual("certificates/added.html", page)
         self.assertTrue(context['public'].is_CA)
         self.assertEqual(1, self.certificates_count())
         self.assertEqual(0, self.privatekeys_count())
Beispiel #4
0
 def test_pkcs1_with_certificate(self):
     self.test_x509()  # Add x509
     with CreateRequest("/certificates/add", TestCertificates.PKCS1_rsa_ca) as request:
         handler = AddHandler.by_request(request)
         (req, page, context) = handler.handle()
     self.assertEqual("certificates/added.html", page)
     self.assertEqual(1, self.privatekeys_count())
     self.assertIsNotNone(context["public"])
     self.assertIsNotNone(context["private"])
Beispiel #5
0
 def test_pkcs12_encrypted(self):
     with CreateRequest("/certificates/add", TestCertificates.PKCS12_rsa_encrypted, password="******") as request:
         handler = AddHandler.by_request(request)
         (req, page, context) = handler.handle()
     self.assertEqual("certificates/added.html", page)
     self.assertEqual(1, self.privatekeys_count())
     self.assertEqual(2, self.certificates_count())
     self.assertIsNotNone(context["public"])
     self.assertIsNotNone(context["private"])
     self.assertIsNotNone(context["further_publics"])
Beispiel #6
0
 def test_pkcs12_ca_already_imported(self):
     self.test_x509()  # Add x509 CA
     self.assertEqual(1, self.certificates_count(), "CA imported.")
     with CreateRequest("/certificates/add", TestCertificates.PKCS12_rsa) as request:
         handler = AddHandler.by_request(request)
         (req, page, context) = handler.handle()
     self.assertEqual("certificates/added.html", page)
     self.assertEqual(1, self.privatekeys_count())
     self.assertEqual(2, self.certificates_count(), "CA should not be duplicated.")
     self.assertIsNotNone(context["public"])
     self.assertIsNotNone(context["private"])
     self.assertIsNotNone(context["further_publics"])
Beispiel #7
0
    def test_x509_valid_domains(self):
        self.add_rw_certificate()  # Add a sample domain

        with CreateRequest("/certificates/add", TestCertificates.X509_googlecom) as request:
            handler = AddHandler.by_request(request)
            (req, page, context) = handler.handle()

        self.assertEqual("certificates/added.html", page)
        self.assertTrue(not context['public'].is_CA)
        self.assertEqual(2, self.certificates_count())
        self.assertEqual(0, self.privatekeys_count())
        domains_count = context['public'].identities.all().__len__()
        self.assertEqual(505, domains_count)
Beispiel #8
0
def add_to_db(certificate):
    with CreateRequest("/certificates/add", certificate) as request:
        handler = AddHandler.by_request(request)
        (req, page, context) = handler.handle()
        assert "certificates/added.html" == page
Beispiel #9
0
 def add_rw_certificate(self):
     with CreateRequest("/certificates/add", TestCertificates.X509_rsa) as request:
         handler = AddHandler.by_request(request)
         (req, page, context) = handler.handle()