Example #1
0
 def test_same_values_are_not_changed(self):
     # If the user enters the same value as the current value, we don't need
     # to write anything to the config.
     self.configure = configure.ConfigureCommand(prompter=EchoPrompter(),
                                                 config_writer=self.writer)
     self.configure(self.context, args=[], parsed_globals=self.global_args)
     self.assertFalse(self.writer.update_config.called)
Example #2
0
 def setUp(self):
     self.writer = mock.Mock()
     self.global_args = mock.Mock()
     self.global_args.profile = None
     self.global_args.endpoint_url = None
     self.global_args.cdp_endpoint_url = None
     self.precanned = PrecannedPrompter(value='new_value')
     self.context = FakeContext({'config_file': 'myconfigfile'})
     self.configure = configure.ConfigureCommand(prompter=self.precanned,
                                                 config_writer=self.writer)
Example #3
0
 def test_none_values_are_not_changed(self):
     # If a user hits enter, this will result in a None value which means
     # don't change the existing values.  In this case, we don't need
     # to write anything out to the config.
     user_presses_enter = None
     precanned = PrecannedPrompter(value=user_presses_enter)
     self.configure = configure.ConfigureCommand(prompter=precanned,
                                                 config_writer=self.writer)
     self.configure(self.context, args=[], parsed_globals=self.global_args)
     self.assertFalse(self.writer.update_config.called)
Example #4
0
 def setUp(self):
     self.writer = mock.Mock()
     self.global_args = mock.Mock()
     self.global_args.profile = None
     self.precanned = PrecannedPrompter(access_key_id='new_access_key_id',
                                        private_key='new_private_key',
                                        cdp_endpoint_url=None)
     self.context = FakeContext({'config_file': 'myconfigfile'})
     self.configure = configure.ConfigureCommand(prompter=self.precanned,
                                                 config_writer=self.writer)
Example #5
0
    def test_configure_command_with_cdp_endpoint_url(self):
        self.precanned = PrecannedPrompter(access_key_id='new_access_key_id',
                                           private_key='new_private_key',
                                           cdp_endpoint_url='http://foo.com')
        self.configure = configure.ConfigureCommand(prompter=self.precanned,
                                                    config_writer=self.writer)
        self.configure(self.context, args=[], parsed_globals=self.global_args)
        # Credentials are always written to the shared credentials file.
        self.assert_credentials_file_updated_with(
            {
                CDP_ACCESS_KEY_ID_KEY_NAME: 'new_access_key_id',
                CDP_PRIVATE_KEY_KEY_NAME: 'new_private_key'
            },
            config_file_comment=CREDENTIAL_FILE_COMMENT)

        # Non-credentials config is written to the config file.
        self.writer.update_config.assert_called_with(
            {EndpointResolver.CDP_ENDPOINT_URL_KEY_NAME: "http://foo.com"},
            'myconfigfile')
Example #6
0
 def test_context_says_profile_does_not_exist(self):
     # Whenever you try to get a config value from botocore,
     # it will raise an exception complaining about ProfileNotFound.
     # We should handle this case, and write out a new profile section
     # in the config file.
     context = FakeContext({'config_file': 'myconfigfile'},
                           profile_does_not_exist=True)
     self.configure = configure.ConfigureCommand(prompter=self.precanned,
                                                 config_writer=self.writer)
     self.global_args.profile = 'profile-does-not-exist'
     self.configure(context, args=[], parsed_globals=self.global_args)
     self.assert_credentials_file_updated_with(
         {
             CDP_ACCESS_KEY_ID_KEY_NAME: 'new_value',
             CDP_PRIVATE_KEY_KEY_NAME: 'new_value',
             '__section__': 'profile-does-not-exist'
         },
         config_file_comment=CREDENTIAL_FILE_COMMENT)
     self.writer.update_config.assert_called_with(
         {'__section__': 'profile profile-does-not-exist'}, 'myconfigfile')
Example #7
0
 def test_create_configure_cmd(self):
     self.configure = configure.ConfigureCommand()
     self.assertIsInstance(self.configure, configure.ConfigureCommand)