Merge "Add test with noauth for s3tokens and ec2tokens"
This commit is contained in:
commit
90695d8da6
@ -44,7 +44,7 @@ class EC2ContribCoreV3(test_v3.RestfulTestCase):
|
||||
self.assertEqual(http.client.METHOD_NOT_ALLOWED,
|
||||
resp.status_code)
|
||||
|
||||
def test_valid_authentication_response_with_proper_secret(self):
|
||||
def _test_valid_authentication_response_with_proper_secret(self, **kwargs):
|
||||
signer = ec2_utils.Ec2Signer(self.cred_blob['secret'])
|
||||
timestamp = utils.isotime(timeutils.utcnow())
|
||||
credentials = {
|
||||
@ -63,9 +63,17 @@ class EC2ContribCoreV3(test_v3.RestfulTestCase):
|
||||
resp = self.post(
|
||||
'/ec2tokens',
|
||||
body={'credentials': credentials},
|
||||
expected_status=http.client.OK)
|
||||
expected_status=http.client.OK,
|
||||
**kwargs)
|
||||
self.assertValidProjectScopedTokenResponse(resp, self.user)
|
||||
|
||||
def test_valid_authentication_response_with_proper_secret(self):
|
||||
self._test_valid_authentication_response_with_proper_secret()
|
||||
|
||||
def test_valid_authentication_response_with_proper_secret_noauth(self):
|
||||
self._test_valid_authentication_response_with_proper_secret(
|
||||
noauth=True)
|
||||
|
||||
def test_valid_authentication_response_with_signature_v4(self):
|
||||
signer = ec2_utils.Ec2Signer(self.cred_blob['secret'])
|
||||
timestamp = utils.isotime(timeutils.utcnow())
|
||||
|
@ -46,7 +46,7 @@ class S3ContribCore(test_v3.RestfulTestCase):
|
||||
self.assertEqual(http.client.METHOD_NOT_ALLOWED,
|
||||
resp.status_code)
|
||||
|
||||
def test_good_response(self):
|
||||
def _test_good_response(self, **kwargs):
|
||||
sts = 'string to sign' # opaque string from swift3
|
||||
sig = hmac.new(self.cred_blob['secret'].encode('ascii'),
|
||||
sts.encode('ascii'), hashlib.sha1).digest()
|
||||
@ -57,10 +57,17 @@ class S3ContribCore(test_v3.RestfulTestCase):
|
||||
'signature': base64.b64encode(sig).strip(),
|
||||
'token': base64.b64encode(sts.encode('ascii')).strip(),
|
||||
}},
|
||||
expected_status=http.client.OK)
|
||||
expected_status=http.client.OK,
|
||||
**kwargs)
|
||||
self.assertValidProjectScopedTokenResponse(resp, self.user,
|
||||
forbid_token_id=True)
|
||||
|
||||
def test_good_response(self):
|
||||
self._test_good_response()
|
||||
|
||||
def test_good_response_noauth(self):
|
||||
self._test_good_response(noauth=True)
|
||||
|
||||
def test_bad_request(self):
|
||||
self.post(
|
||||
'/s3tokens',
|
||||
|
Loading…
x
Reference in New Issue
Block a user