Esempio n. 1
0
 def testAddKey(self):
     self.assertEqual(3, self.mock.numkeys)
     keyczart.main(['addkey', '--status=primary'])
     self.assertEqual(4, self.mock.numkeys)
     # The next version number will be 100, since the previous max was 99
     self.assertEqual(keyinfo.PRIMARY, self.mock.GetStatus(100))
     self.assertEqual(keyinfo.ACTIVE, self.mock.GetStatus(42))
 def testAddKey(self):
   self.assertEqual(3, self.mock.numkeys)
   keyczart.main(['addkey', '--status=primary'])
   self.assertEqual(4, self.mock.numkeys)
   # The next version number will be 100, since the previous max was 99
   self.assertEqual(keyinfo.PRIMARY, self.mock.GetStatus(100))
   self.assertEqual(keyinfo.ACTIVE, self.mock.GetStatus(42))
Esempio n. 3
0
 def testCreate(self):
     keyczart.main([
         'create', '--name=testCreate', '--purpose=crypt',
         '--asymmetric=rsa'
     ])
     self.assertEqual('testCreate', self.mock.kmd.name)
     self.assertEqual(keyinfo.DECRYPT_AND_ENCRYPT, self.mock.kmd.purpose)
     self.assertEqual(keyinfo.RSA_PRIV, self.mock.kmd.type)
 def testAddKeyCrypterCreatesCrypter(self):
   self.dummy_location = None
   def dummyCreateCrypter(location):
     self.dummy_location = location
     return self.mock
   keyczart._CreateCrypter = dummyCreateCrypter
   keyczart.main(['addkey', '--crypter=foo'])
   self.assertEqual(self.dummy_location, 'foo')
Esempio n. 5
0
    def testAddKeyCrypterCreatesCrypter(self):
        self.dummy_location = None

        def dummyCreateCrypter(location):
            self.dummy_location = location
            return self.mock

        keyczart._CreateCrypter = dummyCreateCrypter
        keyczart.main(['addkey', '--crypter=foo'])
        self.assertEqual(self.dummy_location, 'foo')
 def testPubKey(self):
   pubmock = readers.MockReader('PUBTEST', keyinfo.DECRYPT_AND_ENCRYPT,
                                keyinfo.RSA_PRIV)
   pubmock.AddKey(33, keyinfo.PRIMARY, 1024)  # small key size for fast tests
   keyczart.mock = pubmock  # use pubmock instead
   self.assertEqual(None, pubmock.pubkmd)
   keyczart.main(['pubkey'])
   self.assertNotEqual(None, pubmock.pubkmd)
   self.assertEqual('PUBTEST', pubmock.pubkmd.name)
   self.assertEqual(keyinfo.ENCRYPT, pubmock.pubkmd.purpose)
   self.assertEqual(keyinfo.RSA_PUB, pubmock.pubkmd.type)
   self.assertTrue(pubmock.HasPubKey(33))
Esempio n. 7
0
 def testPubKey(self):
     pubmock = readers.MockReader('PUBTEST', keyinfo.DECRYPT_AND_ENCRYPT,
                                  keyinfo.RSA_PRIV)
     pubmock.AddKey(33, keyinfo.PRIMARY,
                    1024)  # small key size for fast tests
     keyczart.mock = pubmock  # use pubmock instead
     self.assertEqual(None, pubmock.pubkmd)
     keyczart.main(['pubkey'])
     self.assertNotEqual(None, pubmock.pubkmd)
     self.assertEqual('PUBTEST', pubmock.pubkmd.name)
     self.assertEqual(keyinfo.ENCRYPT, pubmock.pubkmd.purpose)
     self.assertEqual(keyinfo.RSA_PUB, pubmock.pubkmd.type)
     self.assertTrue(pubmock.HasPubKey(33))
Esempio n. 8
0
 def testRevoke(self):
     self.assertTrue(self.mock.ExistsVersion(99))
     keyczart.main(['revoke', '--version=99'])
     self.assertFalse(self.mock.ExistsVersion(99))
Esempio n. 9
0
 def testDemote(self):
     keyczart.main(['demote', '--version=77'])
     self.assertEqual(keyinfo.INACTIVE, self.mock.GetStatus(77))
Esempio n. 10
0
 def testPromote(self):
     keyczart.main(['promote', '--version=77'])
     self.assertEqual(keyinfo.PRIMARY, self.mock.GetStatus(77))
     self.assertEqual(keyinfo.ACTIVE, self.mock.GetStatus(42))
Esempio n. 11
0
 def testAddKeySizeFlag(self):
     keyczart.main(['addkey', '--size=256'])
     self.assertEqual(256, self.mock.GetKeySize(100))
 def testRevoke(self):
   self.assertTrue(self.mock.ExistsVersion(99))
   keyczart.main(['revoke', '--version=99'])
   self.assertFalse(self.mock.ExistsVersion(99))
 def testDemote(self):
   keyczart.main(['demote', '--version=77'])
   self.assertEqual(keyinfo.INACTIVE, self.mock.GetStatus(77))
 def testPromote(self):
   keyczart.main(['promote', '--version=77'])
   self.assertEqual(keyinfo.PRIMARY, self.mock.GetStatus(77))
   self.assertEqual(keyinfo.ACTIVE, self.mock.GetStatus(42))
 def testAddKeySizeFlag(self):
   keyczart.main(['addkey', '--size=256'])
   self.assertEqual(256, self.mock.GetKeySize(100))
 def testCreate(self):
   keyczart.main(['create', '--name=testCreate',
                  '--purpose=crypt', '--asymmetric=rsa'])
   self.assertEqual('testCreate', self.mock.kmd.name)
   self.assertEqual(keyinfo.DECRYPT_AND_ENCRYPT, self.mock.kmd.purpose)
   self.assertEqual(keyinfo.RSA_PRIV, self.mock.kmd.type)