Exemplo n.º 1
0
    def test_enstaller_userpass_upgrade(self):
        """ Username and password should be taken out of .enstaller4rc
        and stored in a keyring.
        """
        config.get_auth()
        config_contents = open(config.home_config_path).read()
        return # XXX
        self.assertTrue('EPD_auth' not in config_contents)
        username, password = config.get_auth()
        self.assertEqual(username, 'foo')
        self.assertEqual(password, 'bar')

        config.clear_auth()
        config_contents = open(config.home_config_path).read()
        self.assertTrue('EPD_username' not in config_contents)
        self.assertEqual(config.get_auth(), (None, None))
Exemplo n.º 2
0
    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'))
Exemplo n.º 3
0
    def test_enstaller_userpass_no_keyring(self):
        """ When the keyring module isn't available, username and
        password should be stored in the old method
        """
        keyring = config.keyring
        config.keyring = None
        try:
            config.get_auth()
            config_contents = open(config.home_config_path).read()
            self.assertTrue("EPD_auth = 'Zm9vOmJhcg=='" in config_contents)

            config.change_auth('bar', 'foo')
            config_contents = open(config.home_config_path).read()
            self.assertTrue("EPD_auth = 'YmFyOmZvbw=='" in config_contents)

            config.clear_auth()
            config_contents = open(config.home_config_path).read()
            self.assertTrue("EPD_auth" not in config_contents)
            self.assertEqual(config.get_auth(), (None, None))

            config.change_auth('foo', 'bar')
            self.assertEqual(config.get_auth(), ('foo', 'bar'))
        finally:
            config.keyring = keyring
Exemplo n.º 4
0
 def tearDown(self):
     config.clear_auth()