

def testSignTrove(self):
    fingerprint = 'F7440D78FE813C882212C2BF8AC2828190B1E477'
    keyCache = openpgpkey.getKeyCache()
    keyCache.getPrivateKey(fingerprint, '111111')
    self.addQuickTestComponent('test:doc', '1.0-1-1')
    self.cfg.signatureKey = fingerprint
    self.cfg.quiet = True
    self.assertRaises(errors.DigitalSignatureError, signtrove.signTroves, self.cfg, ['test:doc'])
    keyRing = open(resources.get_path('conary_test', 'archive', 'pubring.gpg'))
    keyData = openpgpfile.exportKey(fingerprint, keyRing)
    keyData.seek(0)
    keyData = keyData.read()
    repos = self.openRepository()
    repos.addNewPGPKey(self.cfg.buildLabel, 'test', keyData)
    signtrove.signTroves(self.cfg, ['test:doc'])
    v = versions.VersionFromString('/localhost@rpl:linux/1.0-1-1')
    f = deps.parseFlavor('')
    t = repos.getTrove('test:doc', v, f)
    self._checkDigitalSig(t, fingerprint)
    self.assertEqual(t.verifyDigitalSignatures(), (openpgpfile.TRUST_TRUSTED, [], set()))
    fingerprint2 = '95B457D16843B21EA3FC73BBC7C32FC1F94E405E'
    keyCache.getPrivateKey(fingerprint2, '111111')
    keyRing = open(resources.get_path('conary_test', 'archive', 'pubring.gpg'))
    keyData = openpgpfile.exportKey(fingerprint2, v)
    keyData.seek(0)
    keyData = keyData.read()
    repos.addNewPGPKey(self.cfg.buildLabel, 'test', keyData)
    self.cfg.signatureKey = fingerprint2
    self.cfg.quiet = True
    signtrove.signTroves(self.cfg, ['test:doc'])
    t = repos.getTrove('test:doc', v, f)
    self._checkDigitalSig(t, fingerprint)
    self._checkDigitalSig(t, fingerprint2)
    self.assertEqual(t.verifyDigitalSignatures(), (openpgpfile.TRUST_TRUSTED, [], set()))
    self.assertRaises(errors.DigitalSignatureError, signtrove.signTroves, self.cfg, ['test:doc'])

dataset/ETHPy150Open sassoftware/conary/conary_test/cvctest/sigtest.py SigTest.testSignTrove/VarMisuse@256/460 `keyRing`->`v`