Merge "Rename GOOD_RESPONSE to be version-specific"
This commit is contained in:
commit
5f9516b58c
@ -35,7 +35,7 @@ import swift3
|
||||
from swift3.test.unit import Swift3TestCase
|
||||
from swift3.test.unit.helpers import FakeSwift
|
||||
from swift3.test.unit.test_s3_token_middleware import \
|
||||
GOOD_RESPONSE, GOOD_RESPONSE_V3
|
||||
GOOD_RESPONSE_V2, GOOD_RESPONSE_V3
|
||||
from swift3.request import SigV4Request, Request as S3Request
|
||||
from swift3.etree import fromstring
|
||||
from swift3.middleware import filter_factory, Swift3Middleware
|
||||
@ -922,7 +922,7 @@ class TestSwift3Middleware(Swift3TestCase):
|
||||
swob.HTTPOk, {}, None)
|
||||
with patch.object(self.s3_token, '_json_request') as mock_req:
|
||||
mock_resp = requests.Response()
|
||||
mock_resp._content = json.dumps(GOOD_RESPONSE)
|
||||
mock_resp._content = json.dumps(GOOD_RESPONSE_V2)
|
||||
mock_resp.status_code = 201
|
||||
mock_req.return_value = mock_resp
|
||||
|
||||
@ -978,11 +978,11 @@ class TestSwift3Middleware(Swift3TestCase):
|
||||
with patch.object(self.auth_token,
|
||||
'_do_fetch_token') as mock_fetch:
|
||||
mock_resp = requests.Response()
|
||||
mock_resp._content = json.dumps(GOOD_RESPONSE)
|
||||
mock_resp._content = json.dumps(GOOD_RESPONSE_V2)
|
||||
mock_resp.status_code = 201
|
||||
mock_req.return_value = mock_resp
|
||||
|
||||
mock_access_info = AccessInfoV2(GOOD_RESPONSE)
|
||||
mock_access_info = AccessInfoV2(GOOD_RESPONSE_V2)
|
||||
mock_access_info.will_expire_soon = \
|
||||
lambda stale_duration: False
|
||||
mock_fetch.return_value = (MagicMock(), mock_access_info)
|
||||
@ -1016,14 +1016,14 @@ class TestSwift3Middleware(Swift3TestCase):
|
||||
with patch.object(self.auth_token,
|
||||
'_do_fetch_token') as mock_fetch:
|
||||
mock_resp = requests.Response()
|
||||
no_token_id_good_resp = copy.deepcopy(GOOD_RESPONSE)
|
||||
no_token_id_good_resp = copy.deepcopy(GOOD_RESPONSE_V2)
|
||||
# delete token id
|
||||
del no_token_id_good_resp['access']['token']['id']
|
||||
mock_resp._content = json.dumps(no_token_id_good_resp)
|
||||
mock_resp.status_code = 201
|
||||
mock_req.return_value = mock_resp
|
||||
|
||||
mock_access_info = AccessInfoV2(GOOD_RESPONSE)
|
||||
mock_access_info = AccessInfoV2(GOOD_RESPONSE_V2)
|
||||
mock_access_info.will_expire_soon = \
|
||||
lambda stale_duration: False
|
||||
mock_fetch.return_value = (MagicMock(), mock_access_info)
|
||||
|
@ -30,7 +30,7 @@ from swift3 import s3_token_middleware as s3_token
|
||||
from swift.common.swob import Request, Response
|
||||
from swift.common.wsgi import ConfigFileError
|
||||
|
||||
GOOD_RESPONSE = {'access': {
|
||||
GOOD_RESPONSE_V2 = {'access': {
|
||||
'user': {
|
||||
'username': 'S3_USER',
|
||||
'name': 'S3_USER',
|
||||
@ -162,7 +162,7 @@ class S3TokenMiddlewareTestGood(S3TokenMiddlewareTestBase):
|
||||
|
||||
self.requests_mock.post(self.TEST_URL,
|
||||
status_code=201,
|
||||
json=GOOD_RESPONSE)
|
||||
json=GOOD_RESPONSE_V2)
|
||||
|
||||
# Ignore the request and pass to the next middleware in the
|
||||
# pipeline if no path has been specified.
|
||||
@ -238,7 +238,7 @@ class S3TokenMiddlewareTestGood(S3TokenMiddlewareTestBase):
|
||||
self._assert_authorized(req)
|
||||
|
||||
def test_tolerate_missing_token_id(self):
|
||||
resp = copy.deepcopy(GOOD_RESPONSE)
|
||||
resp = copy.deepcopy(GOOD_RESPONSE_V2)
|
||||
del resp['access']['token']['id']
|
||||
self.requests_mock.post(self.TEST_URL,
|
||||
status_code=201,
|
||||
@ -269,7 +269,7 @@ class S3TokenMiddlewareTestGood(S3TokenMiddlewareTestBase):
|
||||
port = 35357
|
||||
self.requests_mock.post(
|
||||
'%s://%s:%s/v2.0/s3tokens' % (protocol, host, port),
|
||||
status_code=201, json=GOOD_RESPONSE)
|
||||
status_code=201, json=GOOD_RESPONSE_V2)
|
||||
|
||||
self.middleware = (
|
||||
s3_token.filter_factory({'auth_protocol': 'http',
|
||||
@ -311,7 +311,7 @@ class S3TokenMiddlewareTestGood(S3TokenMiddlewareTestBase):
|
||||
self.middleware = s3_token.filter_factory(
|
||||
{'insecure': 'True', 'auth_uri': 'http://example.com'})(self.app)
|
||||
|
||||
text_return_value = json.dumps(GOOD_RESPONSE)
|
||||
text_return_value = json.dumps(GOOD_RESPONSE_V2)
|
||||
MOCK_REQUEST.return_value = TestResponse({
|
||||
'status_code': 201,
|
||||
'text': text_return_value})
|
||||
@ -386,7 +386,7 @@ class S3TokenMiddlewareTestGood(S3TokenMiddlewareTestBase):
|
||||
|
||||
MOCK_REQUEST.return_value = TestResponse({
|
||||
'status_code': 201,
|
||||
'text': json.dumps(GOOD_RESPONSE)})
|
||||
'text': json.dumps(GOOD_RESPONSE_V2)})
|
||||
|
||||
req = Request.blank('/v1/AUTH_cfa/c/o')
|
||||
req.environ['swift3.auth_details'] = {
|
||||
@ -516,7 +516,7 @@ class S3TokenMiddlewareTestBad(S3TokenMiddlewareTestBase):
|
||||
self._test_bad_reply('<badreply>')
|
||||
|
||||
def _test_bad_reply_missing_parts(self, *parts):
|
||||
resp = copy.deepcopy(GOOD_RESPONSE)
|
||||
resp = copy.deepcopy(GOOD_RESPONSE_V2)
|
||||
part_dict = resp
|
||||
for part in parts[:-1]:
|
||||
part_dict = part_dict[part]
|
||||
|
Loading…
x
Reference in New Issue
Block a user