示例#1
0
    def test_common_name_no_CN(self):
        csr = x509_csr.X509Csr()

        with self.assertRaises(errors.ValidationError) as e:
            custom.common_name(csr=csr,
                               allowed_domains=[],
                               allowed_networks=[])
        self.assertEqual(
            "Alt subjects have to exist if the main subject"
            " doesn't", str(e.exception))
    def test_common_name_no_CN(self):
        csr = x509_csr.X509Csr()

        with self.assertRaises(errors.ValidationError) as e:
            custom.common_name(
                csr=csr,
                allowed_domains=[],
                allowed_networks=[])
        self.assertEqual("Alt subjects have to exist if the main subject"
                         " doesn't", str(e.exception))
示例#3
0
    def test_common_name_bad_CN(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, 'bad.example.org')

        with self.assertRaises(errors.ValidationError) as e:
            custom.common_name(csr=csr, allowed_domains=['.example.com'])
        self.assertEqual(
            "Domain 'bad.example.org' not allowed (does not "
            "match known domains)", str(e.exception))
    def test_common_name_bad_CN(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, 'bad.example.org')

        with self.assertRaises(errors.ValidationError) as e:
            custom.common_name(
                csr=csr,
                allowed_domains=['.example.com'])
        self.assertEqual("Domain 'bad.example.org' not allowed (does not "
                         "match known domains)", str(e.exception))
示例#5
0
    def test_common_name_with_two_CN(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, "dummy_value")
        name.add_name_entry(x509_name.OID_commonName, "dummy_value")

        with self.assertRaises(errors.ValidationError) as e:
            custom.common_name(csr=csr,
                               allowed_domains=[],
                               allowed_networks=[])
        self.assertEqual("Too many CNs in the request", str(e.exception))
    def test_common_name_with_two_CN(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, "dummy_value")
        name.add_name_entry(x509_name.OID_commonName, "dummy_value")

        with self.assertRaises(errors.ValidationError) as e:
            custom.common_name(
                csr=csr,
                allowed_domains=[],
                allowed_networks=[])
        self.assertEqual("Too many CNs in the request", str(e.exception))
    def test_common_name_ip_bad(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, '15.1.1.1')

        with self.assertRaises(errors.ValidationError) as e:
            custom.common_name(
                csr=csr,
                allowed_domains=['.example.com'],
                allowed_networks=['10/8'])
        self.assertEqual("Address '15.1.1.1' not allowed (does not "
                         "match known networks)", str(e.exception))
示例#8
0
    def test_common_name_ip_bad(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, '15.1.1.1')

        with self.assertRaises(errors.ValidationError) as e:
            custom.common_name(csr=csr,
                               allowed_domains=['.example.com'],
                               allowed_networks=['10/8'])
        self.assertEqual(
            "Address '15.1.1.1' not allowed (does not "
            "match known networks)", str(e.exception))
示例#9
0
    def test_common_name_ip_good(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, '10.1.1.1')

        self.assertEqual(
            None,
            custom.common_name(csr=csr,
                               allowed_domains=['.example.com'],
                               allowed_networks=['10/8']))
示例#10
0
    def test_common_name_good_CN(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, "good.example.com")

        self.assertEqual(
            None,
            custom.common_name(
                csr=csr,
                allowed_domains=['.example.com'],
            ))
示例#11
0
    def test_common_name_good_CN(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, "good.example.com")

        self.assertEqual(
            None,
            custom.common_name(
                csr=csr,
                allowed_domains=['.example.com'],
            )
        )
示例#12
0
    def test_common_name_ip_good(self):
        csr = x509_csr.X509Csr()
        name = csr.get_subject()
        name.add_name_entry(x509_name.OID_commonName, '10.1.1.1')

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