def test_alternative_names_ip_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_ip(
                csr=csr,
                allowed_domains=['.example.com'])
        self.assertEqual("Domain 'bad.example.org' not allowed (doesn't "
                         "match known domains)", str(e.exception))
    def test_alternative_names_ip_bad(self):
        csr = x509_csr.X509Csr()
        ext = x509_ext.X509ExtensionSubjectAltName()
        ext.add_ip(netaddr.IPAddress('10.1.1.1'))
        csr.add_extension(ext)

        with self.assertRaises(errors.ValidationError) as e:
            custom.alternative_names_ip(
                csr=csr,
                allowed_domains=['.example.com'],
                allowed_networks=['99/8'])
        self.assertEqual("IP '10.1.1.1' not allowed (doesn't match known "
                         "networks)", str(e.exception))
Example #3
0
    def test_alternative_names_ip_bad(self):
        csr = x509_csr.X509Csr()
        ext = x509_ext.X509ExtensionSubjectAltName()
        ext.add_ip(netaddr.IPAddress('10.1.1.1'))
        csr.add_extension(ext)

        with self.assertRaises(errors.ValidationError) as e:
            custom.alternative_names_ip(csr=csr,
                                        allowed_domains=['.example.com'],
                                        allowed_networks=['99/8'])
        self.assertEqual(
            "IP '10.1.1.1' not allowed (doesn't match known "
            "networks)", str(e.exception))
Example #4
0
    def test_alternative_names_ip_good(self):
        csr = x509_csr.X509Csr()
        ext = x509_ext.X509ExtensionSubjectAltName()
        ext.add_ip(netaddr.IPAddress('10.1.1.1'))
        csr.add_extension(ext)

        self.assertEqual(
            None,
            custom.alternative_names_ip(csr=csr,
                                        allowed_domains=['.example.com'],
                                        allowed_networks=['10/8']))
    def test_alternative_names_ip_good(self):
        csr = x509_csr.X509Csr()
        ext = x509_ext.X509ExtensionSubjectAltName()
        ext.add_ip(netaddr.IPAddress('10.1.1.1'))
        csr.add_extension(ext)

        self.assertEqual(
            None,
            custom.alternative_names_ip(
                csr=csr,
                allowed_domains=['.example.com'],
                allowed_networks=['10/8']
            )
        )