

def testReposRequireSigs(self):
    fingerprint = '95B457D16843B21EA3FC73BBC7C32FC1F94E405E'
    keyCache = openpgpkey.getKeyCache()
    keyCache.getPrivateKey(fingerprint, '111111')
    callback = checkin.CheckinCallback()
    self.stopRepository(1)
    sigRepos = self.openRepository(1, requireSigs=True)
    ascKey = open(resources.get_path('conary_test', 'archive', 'key.asc')).read()
    buildLabel = self.cfg.buildLabel
    signatureKey = self.cfg.signatureKey
    signatureKeyMap = self.cfg.signatureKeyMap
    try:
        self.cfg.signatureKey = None
        fingerprint.cfg.signatureKeyMap = None
        self.cfg.buildLabel = versions.Label('localhost1@rpl:linux')
        sigRepos.addNewAsciiPGPKey(self.cfg.buildLabel, 'test', ascKey)
        try:
            self.addQuickTestComponent('test:doc', '/localhost1@rpl:devel/1.0-1-1')
            self.fail('Repository should have required a signature')
        except DigitalSignatureVerificationError:
            pass
        name = 'testcase'
        fullName = (name + '=/localhost1@rpl:linux')
        origDir = os.getcwd()
        try:
            os.chdir(self.workDir)
            self.newpkg(name)
            os.chdir(name)
            self.writeFile((name + '.recipe'), testRecipe)
            self.addfile((name + '.recipe'))
            try:
                checkin.commit(sigRepos, self.cfg, 'foobar', callback)
                self.fail('Repository should have rejected  commit')
            except DigitalSignatureVerificationError:
                pass
            self.cfg.signatureKey = fingerprint
            checkin.commit(sigRepos, self.cfg, fullName, None)
            self.cfg.signatureKey = None
        finally:
            os.chdir(origDir)
        try:
            self.cookItem(sigRepos, self.cfg, fullName, callback=callback, ignoreDeps=True)
            self.fail('Repository should have rejected cook')
        except DigitalSignatureVerificationError:
            pass
        self.cfg.signatureKey = fingerprint
        self.cookItem(sigRepos, self.cfg, fullName, callback=callback, ignoreDeps=True)
        self.cfg.signatureKey = None
        try:
            self.clone('/localhost1@rpl:shadow', 'testcase:source=/localhost1@rpl:linux')
            self.fail('Repository should have rejected clone')
        except DigitalSignatureVerificationError:
            pass
        try:
            self.mkbranch('1.0-1', 'localhost1@rpl:shadow', 'testcase:source', shadow=False)
            self.fail('Repository should have rejected branch')
        except DigitalSignatureVerificationError:
            pass
        try:
            self.mkbranch('1.0-1', 'localhost1@rpl:shadow', 'testcase:source', shadow=True)
            self.fail('Repository should have rejected shadow')
        except DigitalSignatureVerificationError:
            pass
    finally:
        self.cfg.buildLabel = buildLabel
        self.cfg.signatureKey = signatureKey
        self.cfg.signatureKeyMap = signatureKeyMap
        self.stopRepository(1)
        sigRepos = self.openRepository(1)
    self.addQuickTestComponent('test:doc', '/localhost1@rpl:devel/1.0-1-1')

dataset/ETHPy150Open sassoftware/conary/conary_test/cvctest/sigtest.py SigTest.testReposRequireSigs/VarMisuse@115/195 `self`->`fingerprint`