Merge "Add test with noauth for s3tokens and ec2tokens"

This commit is contained in:
Zuul 2024-06-28 17:14:41 +00:00 committed by Gerrit Code Review
commit 90695d8da6
2 changed files with 19 additions and 4 deletions

View File

@ -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())

View File

@ -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',