"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/tests/unit/test_v3_endpoint_policy.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_v3_endpoint_policy.py  (keystone-16.0.1):test_v3_endpoint_policy.py  (keystone-17.0.0)
skipping to change at line 15 skipping to change at line 15
# a copy of the License at # a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# 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.
from six.moves import http_client import http.client
from testtools import matchers from testtools import matchers
from keystone.common import provider_api from keystone.common import provider_api
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 EndpointPolicyTestCase(test_v3.RestfulTestCase): class EndpointPolicyTestCase(test_v3.RestfulTestCase):
"""Test endpoint policy CRUD. """Test endpoint policy CRUD.
skipping to change at line 61 skipping to change at line 61
self.get(url, expected_status=expected_status) self.get(url, expected_status=expected_status)
self.head(url, expected_status=expected_status) self.head(url, expected_status=expected_status)
# endpoint policy crud tests # endpoint policy crud tests
def _crud_test(self, url): def _crud_test(self, url):
# Test when the resource does not exist also ensures # Test when the resource does not exist also ensures
# that there is not a false negative after creation. # that there is not a false negative after creation.
self.assert_head_and_get_return_same_response( self.assert_head_and_get_return_same_response(
url, url,
expected_status=http_client.NOT_FOUND) expected_status=http.client.NOT_FOUND)
self.put(url) self.put(url)
# test that the new resource is accessible. # test that the new resource is accessible.
self.assert_head_and_get_return_same_response( self.assert_head_and_get_return_same_response(
url, url,
expected_status=http_client.NO_CONTENT) expected_status=http.client.NO_CONTENT)
self.delete(url) self.delete(url)
# test that the deleted resource is no longer accessible # test that the deleted resource is no longer accessible
self.assert_head_and_get_return_same_response( self.assert_head_and_get_return_same_response(
url, url,
expected_status=http_client.NOT_FOUND) expected_status=http.client.NOT_FOUND)
def test_crud_for_policy_for_explicit_endpoint(self): def test_crud_for_policy_for_explicit_endpoint(self):
"""PUT, HEAD and DELETE for explicit endpoint policy.""" """PUT, HEAD and DELETE for explicit endpoint policy."""
url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY'
'/endpoints/%(endpoint_id)s') % { '/endpoints/%(endpoint_id)s') % {
'policy_id': self.policy['id'], 'policy_id': self.policy['id'],
'endpoint_id': self.endpoint['id']} 'endpoint_id': self.endpoint['id']}
self._crud_test(url) self._crud_test(url)
def test_crud_for_policy_for_service(self): def test_crud_for_policy_for_service(self):
skipping to change at line 112 skipping to change at line 112
def test_get_policy_for_endpoint(self): def test_get_policy_for_endpoint(self):
"""GET /endpoints/{endpoint_id}/policy.""" """GET /endpoints/{endpoint_id}/policy."""
self.put('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' self.put('/policies/%(policy_id)s/OS-ENDPOINT-POLICY'
'/endpoints/%(endpoint_id)s' % { '/endpoints/%(endpoint_id)s' % {
'policy_id': self.policy['id'], 'policy_id': self.policy['id'],
'endpoint_id': self.endpoint['id']}) 'endpoint_id': self.endpoint['id']})
self.head('/endpoints/%(endpoint_id)s/OS-ENDPOINT-POLICY' self.head('/endpoints/%(endpoint_id)s/OS-ENDPOINT-POLICY'
'/policy' % { '/policy' % {
'endpoint_id': self.endpoint['id']}, 'endpoint_id': self.endpoint['id']},
expected_status=http_client.OK) expected_status=http.client.OK)
r = self.get('/endpoints/%(endpoint_id)s/OS-ENDPOINT-POLICY' r = self.get('/endpoints/%(endpoint_id)s/OS-ENDPOINT-POLICY'
'/policy' % { '/policy' % {
'endpoint_id': self.endpoint['id']}) 'endpoint_id': self.endpoint['id']})
self.assertValidPolicyResponse(r, ref=self.policy) self.assertValidPolicyResponse(r, ref=self.policy)
def test_list_endpoints_for_policy(self): def test_list_endpoints_for_policy(self):
"""GET & HEAD /policies/%(policy_id}/endpoints.""" """GET & HEAD /policies/%(policy_id}/endpoints."""
url = ( url = (
'/policies/%(policy_id)s/OS-ENDPOINT-POLICY' '/policies/%(policy_id)s/OS-ENDPOINT-POLICY'
'/endpoints' % {'policy_id': self.policy['id']} '/endpoints' % {'policy_id': self.policy['id']}
) )
self.put(url + '/' + self.endpoint['id']) self.put(url + '/' + self.endpoint['id'])
r = self.get(url) r = self.get(url)
self.assertValidEndpointListResponse(r, ref=self.endpoint) self.assertValidEndpointListResponse(r, ref=self.endpoint)
self.assertThat(r.result.get('endpoints'), matchers.HasLength(1)) self.assertThat(r.result.get('endpoints'), matchers.HasLength(1))
self.head(url, expected_status=http_client.OK) self.head(url, expected_status=http.client.OK)
def test_endpoint_association_cleanup_when_endpoint_deleted(self): def test_endpoint_association_cleanup_when_endpoint_deleted(self):
url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY'
'/endpoints/%(endpoint_id)s') % { '/endpoints/%(endpoint_id)s') % {
'policy_id': self.policy['id'], 'policy_id': self.policy['id'],
'endpoint_id': self.endpoint['id']} 'endpoint_id': self.endpoint['id']}
self.put(url) self.put(url)
self.head(url) self.head(url)
self.delete('/endpoints/%(endpoint_id)s' % { self.delete('/endpoints/%(endpoint_id)s' % {
'endpoint_id': self.endpoint['id']}) 'endpoint_id': self.endpoint['id']})
self.head(url, expected_status=http_client.NOT_FOUND) self.head(url, expected_status=http.client.NOT_FOUND)
def test_region_service_association_cleanup_when_region_deleted(self): def test_region_service_association_cleanup_when_region_deleted(self):
url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY'
'/services/%(service_id)s/regions/%(region_id)s') % { '/services/%(service_id)s/regions/%(region_id)s') % {
'policy_id': self.policy['id'], 'policy_id': self.policy['id'],
'service_id': self.service['id'], 'service_id': self.service['id'],
'region_id': self.region['id']} 'region_id': self.region['id']}
self.put(url) self.put(url)
self.head(url) self.head(url)
self.delete('/regions/%(region_id)s' % { self.delete('/regions/%(region_id)s' % {
'region_id': self.region['id']}) 'region_id': self.region['id']})
self.head(url, expected_status=http_client.NOT_FOUND) self.head(url, expected_status=http.client.NOT_FOUND)
def test_region_service_association_cleanup_when_service_deleted(self): def test_region_service_association_cleanup_when_service_deleted(self):
url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY'
'/services/%(service_id)s/regions/%(region_id)s') % { '/services/%(service_id)s/regions/%(region_id)s') % {
'policy_id': self.policy['id'], 'policy_id': self.policy['id'],
'service_id': self.service['id'], 'service_id': self.service['id'],
'region_id': self.region['id']} 'region_id': self.region['id']}
self.put(url) self.put(url)
self.head(url) self.head(url)
self.delete('/services/%(service_id)s' % { self.delete('/services/%(service_id)s' % {
'service_id': self.service['id']}) 'service_id': self.service['id']})
self.head(url, expected_status=http_client.NOT_FOUND) self.head(url, expected_status=http.client.NOT_FOUND)
def test_service_association_cleanup_when_service_deleted(self): def test_service_association_cleanup_when_service_deleted(self):
url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY'
'/services/%(service_id)s') % { '/services/%(service_id)s') % {
'policy_id': self.policy['id'], 'policy_id': self.policy['id'],
'service_id': self.service['id']} 'service_id': self.service['id']}
self.put(url) self.put(url)
self.get(url, expected_status=http_client.NO_CONTENT) self.get(url, expected_status=http.client.NO_CONTENT)
self.delete('/policies/%(policy_id)s' % { self.delete('/policies/%(policy_id)s' % {
'policy_id': self.policy['id']}) 'policy_id': self.policy['id']})
self.head(url, expected_status=http_client.NOT_FOUND) self.head(url, expected_status=http.client.NOT_FOUND)
def test_service_association_cleanup_when_policy_deleted(self): def test_service_association_cleanup_when_policy_deleted(self):
url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY' url = ('/policies/%(policy_id)s/OS-ENDPOINT-POLICY'
'/services/%(service_id)s') % { '/services/%(service_id)s') % {
'policy_id': self.policy['id'], 'policy_id': self.policy['id'],
'service_id': self.service['id']} 'service_id': self.service['id']}
self.put(url) self.put(url)
self.get(url, expected_status=http_client.NO_CONTENT) self.get(url, expected_status=http.client.NO_CONTENT)
self.delete('/services/%(service_id)s' % { self.delete('/services/%(service_id)s' % {
'service_id': self.service['id']}) 'service_id': self.service['id']})
self.head(url, expected_status=http_client.NOT_FOUND) self.head(url, expected_status=http.client.NOT_FOUND)
class JsonHomeTests(test_v3.JsonHomeTestMixin): class JsonHomeTests(test_v3.JsonHomeTestMixin):
EXTENSION_LOCATION = ('https://docs.openstack.org/api/openstack-identity/3' EXTENSION_LOCATION = ('https://docs.openstack.org/api/openstack-identity/3'
'/ext/OS-ENDPOINT-POLICY/1.0/rel') '/ext/OS-ENDPOINT-POLICY/1.0/rel')
PARAM_LOCATION = ('https://docs.openstack.org/api/openstack-identity/3/' PARAM_LOCATION = ('https://docs.openstack.org/api/openstack-identity/3/'
'param') 'param')
JSON_HOME_DATA = { JSON_HOME_DATA = {
EXTENSION_LOCATION + '/endpoint_policy': { EXTENSION_LOCATION + '/endpoint_policy': {
'href-template': '/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/' 'href-template': '/endpoints/{endpoint_id}/OS-ENDPOINT-POLICY/'
 End of changes. 13 change blocks. 
13 lines changed or deleted 13 lines changed or added

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