"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/tests/unit/test_contrib_ec2_core.py" between
keystone-16.0.1.tar.gz and keystone-17.0.0.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Ussuri" series (latest release).

test_contrib_ec2_core.py  (keystone-16.0.1):test_contrib_ec2_core.py  (keystone-17.0.0)
skipping to change at line 18 skipping to change at line 18
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import datetime import datetime
import hashlib import hashlib
import http.client
from keystoneclient.contrib.ec2 import utils as ec2_utils from keystoneclient.contrib.ec2 import utils as ec2_utils
from oslo_utils import timeutils from oslo_utils import timeutils
from six.moves import http_client
from keystone.common import provider_api from keystone.common import provider_api
from keystone.common import utils from keystone.common import utils
from keystone.tests import unit from keystone.tests import unit
from keystone.tests.unit import test_v3 from keystone.tests.unit import test_v3
PROVIDERS = provider_api.ProviderAPIs PROVIDERS = provider_api.ProviderAPIs
class EC2ContribCoreV3(test_v3.RestfulTestCase): class EC2ContribCoreV3(test_v3.RestfulTestCase):
def setUp(self): def setUp(self):
skipping to change at line 57 skipping to change at line 57
'params': { 'params': {
'SignatureVersion': '2', 'SignatureVersion': '2',
'Action': 'Test', 'Action': 'Test',
'Timestamp': timestamp 'Timestamp': timestamp
}, },
} }
credentials['signature'] = signer.generate(credentials) credentials['signature'] = signer.generate(credentials)
resp = self.post( resp = self.post(
'/ec2tokens', '/ec2tokens',
body={'credentials': credentials}, body={'credentials': credentials},
expected_status=http_client.OK) expected_status=http.client.OK)
self.assertValidProjectScopedTokenResponse(resp, self.user) self.assertValidProjectScopedTokenResponse(resp, self.user)
def test_valid_authentication_response_with_signature_v4(self): def test_valid_authentication_response_with_signature_v4(self):
signer = ec2_utils.Ec2Signer(self.cred_blob['secret']) signer = ec2_utils.Ec2Signer(self.cred_blob['secret'])
timestamp = utils.isotime(timeutils.utcnow()) timestamp = utils.isotime(timeutils.utcnow())
hashed_payload = ( hashed_payload = (
'GET\n' 'GET\n'
'/\n' '/\n'
'Action=Test\n' 'Action=Test\n'
'host:localhost\n' 'host:localhost\n'
skipping to change at line 99 skipping to change at line 99
}, },
'headers': { 'headers': {
'X-Amz-Date': timestamp 'X-Amz-Date': timestamp
}, },
'body_hash': body_hash 'body_hash': body_hash
} }
credentials['signature'] = signer.generate(credentials) credentials['signature'] = signer.generate(credentials)
resp = self.post( resp = self.post(
'/ec2tokens', '/ec2tokens',
body={'credentials': credentials}, body={'credentials': credentials},
expected_status=http_client.OK) expected_status=http.client.OK)
self.assertValidProjectScopedTokenResponse(resp, self.user) self.assertValidProjectScopedTokenResponse(resp, self.user)
def test_authenticate_with_empty_body_returns_bad_request(self): def test_authenticate_with_empty_body_returns_bad_request(self):
self.post( self.post(
'/ec2tokens', '/ec2tokens',
body={}, body={},
expected_status=http_client.BAD_REQUEST) expected_status=http.client.BAD_REQUEST)
def test_authenticate_without_json_request_returns_bad_request(self): def test_authenticate_without_json_request_returns_bad_request(self):
self.post( self.post(
'/ec2tokens', '/ec2tokens',
body='not json', body='not json',
expected_status=http_client.BAD_REQUEST) expected_status=http.client.BAD_REQUEST)
def test_authenticate_without_request_body_returns_bad_request(self): def test_authenticate_without_request_body_returns_bad_request(self):
self.post( self.post(
'/ec2tokens', '/ec2tokens',
expected_status=http_client.BAD_REQUEST) expected_status=http.client.BAD_REQUEST)
def test_authenticate_without_proper_secret_returns_unauthorized(self): def test_authenticate_without_proper_secret_returns_unauthorized(self):
signer = ec2_utils.Ec2Signer('totally not the secret') signer = ec2_utils.Ec2Signer('totally not the secret')
timestamp = utils.isotime(timeutils.utcnow()) timestamp = utils.isotime(timeutils.utcnow())
credentials = { credentials = {
'access': self.cred_blob['access'], 'access': self.cred_blob['access'],
'secret': 'totally not the secret', 'secret': 'totally not the secret',
'host': 'localhost', 'host': 'localhost',
'verb': 'GET', 'verb': 'GET',
'path': '/', 'path': '/',
'params': { 'params': {
'SignatureVersion': '2', 'SignatureVersion': '2',
'Action': 'Test', 'Action': 'Test',
'Timestamp': timestamp 'Timestamp': timestamp
}, },
} }
credentials['signature'] = signer.generate(credentials) credentials['signature'] = signer.generate(credentials)
self.post( self.post(
'/ec2tokens', '/ec2tokens',
body={'credentials': credentials}, body={'credentials': credentials},
expected_status=http_client.UNAUTHORIZED) expected_status=http.client.UNAUTHORIZED)
def test_authenticate_expired_request(self): def test_authenticate_expired_request(self):
self.config_fixture.config( self.config_fixture.config(
group='credential', group='credential',
auth_ttl=5 auth_ttl=5
) )
signer = ec2_utils.Ec2Signer(self.cred_blob['secret']) signer = ec2_utils.Ec2Signer(self.cred_blob['secret'])
past = timeutils.utcnow() - datetime.timedelta(minutes=10) past = timeutils.utcnow() - datetime.timedelta(minutes=10)
timestamp = utils.isotime(past) timestamp = utils.isotime(past)
credentials = { credentials = {
skipping to change at line 164 skipping to change at line 164
'params': { 'params': {
'SignatureVersion': '2', 'SignatureVersion': '2',
'Action': 'Test', 'Action': 'Test',
'Timestamp': timestamp 'Timestamp': timestamp
}, },
} }
credentials['signature'] = signer.generate(credentials) credentials['signature'] = signer.generate(credentials)
self.post( self.post(
'/ec2tokens', '/ec2tokens',
body={'credentials': credentials}, body={'credentials': credentials},
expected_status=http_client.UNAUTHORIZED) expected_status=http.client.UNAUTHORIZED)
def test_authenticate_expired_request_v4(self): def test_authenticate_expired_request_v4(self):
self.config_fixture.config( self.config_fixture.config(
group='credential', group='credential',
auth_ttl=5 auth_ttl=5
) )
signer = ec2_utils.Ec2Signer(self.cred_blob['secret']) signer = ec2_utils.Ec2Signer(self.cred_blob['secret'])
past = timeutils.utcnow() - datetime.timedelta(minutes=10) past = timeutils.utcnow() - datetime.timedelta(minutes=10)
timestamp = utils.isotime(past) timestamp = utils.isotime(past)
hashed_payload = ( hashed_payload = (
skipping to change at line 210 skipping to change at line 210
}, },
'headers': { 'headers': {
'X-Amz-Date': timestamp 'X-Amz-Date': timestamp
}, },
'body_hash': body_hash 'body_hash': body_hash
} }
credentials['signature'] = signer.generate(credentials) credentials['signature'] = signer.generate(credentials)
self.post( self.post(
'/ec2tokens', '/ec2tokens',
body={'credentials': credentials}, body={'credentials': credentials},
expected_status=http_client.UNAUTHORIZED) expected_status=http.client.UNAUTHORIZED)
 End of changes. 10 change blocks. 
8 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)