def test_initialise(self): str = StringIO() cfg = ConfigurationFile(str) with patch('builtins.input', side_effect=['2', 'mock_client_id', 'mock_client_secret', 'mock_aws_app_id', 'mock_subdomain']): cfg.initialise() str.seek(0) self.assertEqual("""[defaults] base_uri = https://api.eu.onelogin.com/ client_id = mock_client_id client_secret = mock_client_secret aws_app_id = mock_aws_app_id subdomain = mock_subdomain """, str.getvalue())
def _load_config(parser, config_file: ConfigurationFile, args=sys.argv[1:]): cli_args = parser.parse_args(args) with open(DEFAULT_CONFIG_PATH, 'a+') as fp: fp.seek(0, 0) config_file.file = fp config_file.load() if (cli_args.configure or not config_file.is_initialised): config_file.initialise(cli_args.config_name) config_section = config_file.section(cli_args.config_name) if config_section is None: sys.exit( "Configuration '{}' not defined. " "Please run 'onelogin-aws-login -c'".format( cli_args.config_name ) ) return config_section, cli_args