コード例 #1
0
 def test_sign_with_region_name(self):
     auth = mock.Mock()
     auth_types = {'v4': auth}
     with mock.patch.dict(ibm_botocore.auth.AUTH_TYPE_MAPS, auth_types):
         self.signer.sign('operation_name', self.request, region_name='foo')
     auth.assert_called_with(credentials=ReadOnlyCredentials(
         'key', 'secret', None),
                             service_name='signing_name',
                             region_name='foo')
コード例 #2
0
 def test_sign_override_region_from_context(self):
     auth = mock.Mock()
     auth_types = {'v4': auth}
     self.request.context = {'signing': {'region': 'my-override-region'}}
     with mock.patch.dict(ibm_botocore.auth.AUTH_TYPE_MAPS, auth_types):
         self.signer.sign('operation_name', self.request)
     auth.assert_called_with(credentials=ReadOnlyCredentials(
         'key', 'secret', None),
                             service_name='signing_name',
                             region_name='my-override-region')
コード例 #3
0
 def test_sign_with_signing_type_presign_post(self):
     auth = mock.Mock()
     post_auth = mock.Mock()
     query_auth = mock.Mock()
     auth_types = {
         'v4-presign-post': post_auth,
         'v4-query': query_auth,
         'v4': auth
     }
     with mock.patch.dict(ibm_botocore.auth.AUTH_TYPE_MAPS, auth_types):
         self.signer.sign('operation_name',
                          self.request,
                          signing_type='presign-post')
     self.assertFalse(auth.called)
     self.assertFalse(query_auth.called)
     post_auth.assert_called_with(credentials=ReadOnlyCredentials(
         'key', 'secret', None),
                                  service_name='signing_name',
                                  region_name='region_name')
コード例 #4
0
    def test_signer_with_refreshable_credentials_gets_credential_set(self):
        class FakeCredentials(Credentials):
            def get_frozen_credentials(self):
                return ReadOnlyCredentials('foo', 'bar', 'baz')
        self.credentials = FakeCredentials('a', 'b', 'c')

        self.signer = RequestSigner(
            'service_name', 'region_name', 'signing_name',
            'v4', self.credentials, self.emitter)

        auth_cls = mock.Mock()
        with mock.patch.dict(ibm_botocore.auth.AUTH_TYPE_MAPS,
                             {'v4': auth_cls}):
            auth = self.signer.get_auth('service_name', 'region_name')
            self.assertEqual(auth, auth_cls.return_value)
            # Note we're called with 'foo', 'bar', 'baz', and *not*
            # 'a', 'b', 'c'.
            auth_cls.assert_called_with(
                credentials=ReadOnlyCredentials('foo', 'bar', 'baz'),
                service_name='service_name',
                region_name='region_name')
コード例 #5
0
 def get_frozen_credentials(self):
     return ReadOnlyCredentials('foo', 'bar', 'baz')