コード例 #1
0
ファイル: test_codecommit.py プロジェクト: aws/aws-cli
 def test_generate_credentials_vpc_reads_region_from_url(self, stdout_mock):
     self.globals.region = None
     self.session.get_config_variable.return_value = None
     self.get_command = CodeCommitGetCommand(self.session)
     self.get_command._run_main(self.args, self.globals)
     output = stdout_mock.getvalue().strip()
     self.assertRegex(output, 'username={0}\npassword=.+'.format('access'))
 def test_generate_session_credentials(self, stdout_mock):
     self.credentials = Credentials('access', 'secret', 'token')
     self.session.get_credentials.return_value = self.credentials
     self.get_command = CodeCommitGetCommand(self.session)
     self.get_command._run_main(self.args, self.globals)
     output = stdout_mock.getvalue().strip()
     self.assertRegexpMatches(
         output, 'username={0}%{1}\npassword=.+'.format('access', 'token'))
 def test_generate_credentials_creates_a_valid_request(
         self, signature, string_to_sign):
     self.credentials = Credentials('access', 'secret')
     self.session.get_credentials.return_value = self.credentials
     self.get_command = CodeCommitGetCommand(self.session)
     self.get_command._run_main(self.args, self.globals)
     aws_request = signature.call_args[0][1]
     self.assertEquals('GIT', aws_request.method)
     self.assertEquals(
         'https://git-codecommit.us-east-1.amazonaws.com//v1/repos/myrepo',
         aws_request.url)
     self.assertEquals(('GIT\n//v1/repos/myrepo\n\n'
                        'host:git-codecommit.us-east-1.amazonaws.com\n\n'
                        'host\n'), string_to_sign.call_args[0][1])
 def test_generate_credentials(self, stdout_mock):
     self.get_command = CodeCommitGetCommand(self.session)
     self.get_command._run_main(self.args, self.globals)
     output = stdout_mock.getvalue().strip()
     self.assertRegexpMatches(output,
                              'username={0}\npassword=.+'.format('access'))
 def test_does_nothing_for_non_amazon_domain(self, stdout_mock):
     self.get_command = CodeCommitGetCommand(self.session)
     self.get_command._run_main(self.args, self.globals)
     output = stdout_mock.getvalue().strip()
     self.assertEquals('', output)