def setUp(self): self.base_cfg = join(dirname(__file__), 'config', '.enstaller4rc') test_cfg = self.base_cfg + '.copy' shutil.copy(self.base_cfg, test_cfg) config.home_config_path = test_cfg config.clear_cache() self.enst = Enstaller(Chain())
def test_enstaller_userpass_no_keyring_new_config(self): """ Username and password should be stored properly in a new config file, even with no keyring module """ config.home_config_path = self.base_cfg + '.new' if isfile(config.home_config_path): os.unlink(config.home_config_path) config.clear_cache() keyring = config.keyring config.keyring = None try: config.change_auth('foo', 'bar') config_contents = open(config.home_config_path).read() self.assertTrue("EPD_auth = 'Zm9vOmJhcg=='" in config_contents) self.assertEqual(config.get_auth(), ('foo', 'bar')) finally: config.keyring = keyring
def test_enstaller_userpass_new_config(self): """ Username and password should be stored in a keyring for brand-new config files, too """ config.home_config_path = self.base_cfg + '.new' if isfile(config.home_config_path): os.unlink(config.home_config_path) config.clear_cache() config.change_auth('foo', 'bar') config_contents = open(config.home_config_path).read() return # XXX self.assertTrue('EPD_auth' not in config_contents) self.assertEqual(config.get_auth(), ('foo', 'bar')) config.clear_auth() self.assertEqual(config.get_auth(), (None, None)) config.change_auth('foo', 'bar') self.assertEqual(config.get_auth(), ('foo', 'bar'))