Ejemplo n.º 1
0
    def test_alternative_names_bad_domain(self):
        csr = x509_csr.X509Csr()
        ext = x509_ext.X509ExtensionSubjectAltName()
        ext.add_dns_id('bad.example.org')
        csr.add_extension(ext)

        with self.assertRaises(errors.ValidationError) as e:
            custom.alternative_names(csr=csr, allowed_domains=['.example.com'])
        self.assertEqual(
            "Domain 'bad.example.org' not allowed (doesn't "
            "match known domains)", str(e.exception))
Ejemplo n.º 2
0
    def test_alternative_names_bad_domain(self):
        csr = x509_csr.X509Csr()
        ext = x509_ext.X509ExtensionSubjectAltName()
        ext.add_dns_id('bad.example.org')
        csr.add_extension(ext)

        with self.assertRaises(errors.ValidationError) as e:
            custom.alternative_names(
                csr=csr,
                allowed_domains=['.example.com'])
        self.assertEqual("Domain 'bad.example.org' not allowed (doesn't "
                         "match known domains)", str(e.exception))
Ejemplo n.º 3
0
    def test_alternative_names_good_domain(self):
        csr = x509_csr.X509Csr()
        ext = x509_ext.X509ExtensionSubjectAltName()
        ext.add_dns_id('good.example.com')
        csr.add_extension(ext)

        self.assertEqual(
            None,
            custom.alternative_names(
                csr=csr,
                allowed_domains=['.example.com'],
            ))
Ejemplo n.º 4
0
    def test_alternative_names_good_domain(self):
        csr = x509_csr.X509Csr()
        ext = x509_ext.X509ExtensionSubjectAltName()
        ext.add_dns_id('good.example.com')
        csr.add_extension(ext)

        self.assertEqual(
            None,
            custom.alternative_names(
                csr=csr,
                allowed_domains=['.example.com'],
            )
        )