def test_config_check_ask_password(self):
        print('')  # space out ask output if an unbuffered run

        self.config['confluence_ask_password'] = True
        self._try_config()

        # enable publishing enabled checks
        self._prepare_valid_publish()

        with mock_getpass('password'):
            with self.assertRaises(ConfluenceConfigurationError):
                self._try_config()

        self.config['confluence_ask_user'] = True

        with mock_input('username'), mock_getpass('password'):
            self._try_config()

        self.config['confluence_ask_user'] = False
        self.config['confluence_server_user'] = '******'

        with mock_getpass('password'):
            self._try_config()

        with mock_getpass(''):
            with self.assertRaises(ConfluenceConfigurationError):
                self._try_config()
예제 #2
0
    def test_config_check_ask_user(self):
        print('')  # space out ask output if an unbuffered run

        self.config['confluence_ask_user'] = True
        self._try_config()

        # enable publishing enabled checks
        self._prepare_valid_publish()

        with mock_input('username'):
            self._try_config()

        with mock_input(''):
            with self.assertRaises(ConfluenceConfigurationError):
                self._try_config()

        # accepting default username
        self.config['confluence_server_user'] = '******'
        with mock_input(''):
            self._try_config()

        del self.config['confluence_ask_user']
        del self.config['confluence_server_user']

        defines = {
            'confluence_ask_user': '******',
        }
        with mock_input(''):
            with self.assertRaises(ConfluenceConfigurationError):
                self._try_config(edefs=defines)

        defines = {
            'confluence_ask_user': '******',
        }
        with mock_input('username'):
            self._try_config(edefs=defines)

        defines = {
            'confluence_ask_user': '******',
        }
        with mock_input(''):
            self._try_config(edefs=defines)

        defines = {
            'confluence_ask_user': '',  # empty to "unset"
        }
        with mock_input(''):
            self._try_config(edefs=defines)