예제 #1
0
    def test_dbtype_both(self):
        db = nssdb.NSSDatabase(self.tmpdir, password_file=self.password_file)

        with open(os.path.join(self.tmpdir, 'cert8.db'), 'w') as f:
            f.write('testfile')
        with self.assertRaises(RuntimeError) as cm:
            db.get_dbtype()
        self.assertIn("incomplete NSS database in DBM format",
                      str(cm.exception))

        for name in ('key3.db', 'secmod.db'):
            with open(os.path.join(self.tmpdir, name), 'w') as f:
                f.write('testfile')
        self.assertEqual(db.get_dbtype(), 'dbm')

        with open(os.path.join(self.tmpdir, 'cert9.db'), 'w') as f:
            f.write('testfile')
        with self.assertRaises(RuntimeError) as cm:
            db.get_dbtype()
        self.assertIn("incomplete NSS database in SQL format",
                      str(cm.exception))

        for name in ('key4.db', 'pkcs11.txt'):
            with open(os.path.join(self.tmpdir, name), 'w') as f:
                f.write('testfile')
        self.assertEqual(db.get_dbtype(), 'sql')
예제 #2
0
 def test_dbtype_sql(self):
     db = nssdb.NSSDatabase(self.tmpdir, password_file=self.password_file)
     self.assertEqual(db.get_dbtype(), None)
     self.create_db('sql')
     self.assertSQLFiles()
     self.assertNotDBMFiles()
     self.assertEqual(db.get_dbtype(), 'sql')
예제 #3
0
    def test_convertdb(self):
        db = nssdb.NSSDatabase(self.tmpdir, password_file=self.password_file)

        self.create_db('dbm')
        self.assertDBMFiles()
        self.assertNotSQLFiles()
        self.assertEqual(db.get_dbtype(), 'dbm')

        db.convert_db()
        self.assertSQLFiles()
        self.assertNotDBMFiles()
        self.assertEqual(db.get_dbtype(), 'sql')
예제 #4
0
    def test_request_generic_ext(self):
        self.create_db('sql')
        db = nssdb.NSSDatabase('sql:' + self.tmpdir,
                               password_file=self.password_file)

        reqfile = os.path.join(self.tmpdir, "req.csr")
        generic = {'oid': SAN_OID, 'critical': True, 'data': SAN_DATA}
        db.create_request("CN=testrequest", reqfile, generic_exts=[generic])

        out = subprocess.check_output(
            ['openssl', 'req', '-text', '-in', reqfile], env={})
        self.assertIn(b'X509v3 Subject Alternative Name: critical', out)
        self.assertIn(b'DNS:example.org', out)