示例#1
0
 def test_WriteRepoYaml(self):
     """Test WriteRepoYaml and _WriteConfig."""
     options = update_release_keys.ParseArgs(self.argv)
     kd = update_release_keys.KeyringData(self.prod, self.base, options,
                                          self.config)
     self.assertEqual(kd.contents_yaml,
                      os.path.join(self.base, 'contents.yaml'))
     kd.keysets = {'metadata-version': 0, 'mp-keysets': ['foo-mp']}
     kd.WriteRepoYaml()
     self.assertEqual(osutils.ReadFile(kd.contents_yaml),
                      'metadata-version: 0\nmp-keysets:\n- foo-mp\n')
示例#2
0
 def test_ReadsRepoYaml(self):
     """Test missing file case."""
     osutils.WriteFile(os.path.join(self.base, 'contents.yaml'),
                       'metadata-version: 0\nmp-keysets: [foo-mp]\n')
     options = update_release_keys.ParseArgs(self.argv)
     kd = update_release_keys.KeyringData(self.prod, self.base, options,
                                          self.config)
     self.assertDictEqual({
         'metadata-version': 0,
         'mp-keysets': ['foo-mp']
     }, kd.keysets)
示例#3
0
 def setUp(self):
     self.prod = os.path.join(self.tempdir, 'prod')
     os.makedirs(os.path.join(self.prod, 'keys'))
     self.base = os.path.join(self.prod, 'v2-keys')
     os.makedirs(self.base)
     for dname in 'public', 'config':
         os.mkdir(os.path.join(self.base, dname))
     conf_path = os.path.join(self.prod, 'signer', 'configs',
                              'cros_common.config')
     os.makedirs(os.path.dirname(conf_path))
     with open(conf_path, 'w') as fp:
         fp.write('[keysets]\nfoo-mp-v3 = FooMPKeys-v3\n')
     self.config = update_release_keys.ParseSignerConfig(self.prod)
     self.argv = ['-d', self.base]
     options = update_release_keys.ParseArgs(self.argv)
     self.keydata = update_release_keys.KeyringData(self.prod, self.base,
                                                    options, self.config)
     os.chdir(self.keydata.public)
     self.wc = self.PatchObject(self.keydata, '_WriteConfig')
     self.logdebug = self.PatchObject(logging, 'debug')
     self.loginfo = self.PatchObject(logging, 'info')
     self.lognotice = self.PatchObject(logging, 'notice')
     self.logwarning = self.PatchObject(logging, 'warning')
     self.logerror = self.PatchObject(logging, 'error')
示例#4
0
 def test_ReadMissingRepoYaml(self):
     """Test missing file case."""
     options = update_release_keys.ParseArgs(self.argv)
     kd = update_release_keys.KeyringData(self.prod, self.base, options,
                                          self.config)
     self.assertDictEqual({'metadata-version': 0}, kd.keysets)