def test_save_to_aws_config__config_file_abosent(self): fileoperations.save_to_aws_config('my-access-key', 'my-secret-key') self.assertEqual( """[profile eb-cli] aws_access_key_id = my-access-key aws_secret_access_key = my-secret-key""", open(os.path.join('home', '.aws', 'config')).read().strip())
def setup_credentials(access_id=None, secret_key=None): io.log_info('Setting up ~/aws/ directory with config file') if access_id is None or secret_key is None: io.echo(strings['cred.prompt']) if access_id is None: access_id = io.prompt('aws-access-id', default='ENTER_AWS_ACCESS_ID_HERE') if secret_key is None: secret_key = io.prompt('aws-secret-key', default='ENTER_SECRET_HERE') fileoperations.save_to_aws_config(access_id, secret_key) fileoperations.touch_config_folder() fileoperations.write_config_setting('global', 'profile', 'eb-cli') aws.set_session_creds(access_id, secret_key)
def test_save_to_aws_config__config_file_present__eb_cli_profile_absent( self): os.mkdir(os.path.join('home', '.aws')) open(os.path.join('home', '.aws', 'config'), 'w').write("""[profile aws-cli] aws_access_key_id = my-access-key aws_secret_access_key = my-secret-key""") fileoperations.save_to_aws_config('my-access-key', 'my-secret-key') self.assertEqual( """[profile aws-cli] aws_access_key_id = my-access-key aws_secret_access_key = my-secret-key [profile eb-cli] aws_access_key_id = my-access-key aws_secret_access_key = my-secret-key""", open(os.path.join('home', '.aws', 'config')).read().strip())