"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/tests/protection/v3/test_project_tags.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_project_tags.py  (keystone-16.0.1):test_project_tags.py  (keystone-17.0.0)
skipping to change at line 15 skipping to change at line 15
# 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.
import uuid import uuid
import http.client
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from six.moves import http_client
from keystone.common.policies import project as pp from keystone.common.policies import project as pp
from keystone.common import provider_api from keystone.common import provider_api
import keystone.conf import keystone.conf
from keystone.tests.common import auth as common_auth from keystone.tests.common import auth as common_auth
from keystone.tests import unit from keystone.tests import unit
from keystone.tests.unit import base_classes from keystone.tests.unit import base_classes
from keystone.tests.unit import ksfixtures from keystone.tests.unit import ksfixtures
from keystone.tests.unit.ksfixtures import temporaryfile from keystone.tests.unit.ksfixtures import temporaryfile
skipping to change at line 76 skipping to change at line 76
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.get( c.get(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.NO_CONTENT expected_status_code=http.client.NO_CONTENT
) )
def test_user_can_list_project_tags(self): def test_user_can_list_project_tags(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
skipping to change at line 109 skipping to change at line 109
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_update_project_tag(self): def test_user_cannot_update_project_tag(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
update = {"tags": [uuid.uuid4().hex]} update = {"tags": [uuid.uuid4().hex]}
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags' % project['id'], headers=self.headers, '/v3/projects/%s/tags' % project['id'], headers=self.headers,
json=update, expected_status_code=http_client.FORBIDDEN json=update, expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_delete_project_tag(self): def test_user_cannot_delete_project_tag(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
class _DomainAndProjectUserTagTests(object): class _DomainAndProjectUserTagTests(object):
def test_user_cannot_create_project_tag(self): def test_user_cannot_create_project_tag(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_update_project_tag(self): def test_user_cannot_update_project_tag(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
update = {"tags": [uuid.uuid4().hex]} update = {"tags": [uuid.uuid4().hex]}
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags' % project['id'], headers=self.headers, '/v3/projects/%s/tags' % project['id'], headers=self.headers,
json=update, expected_status_code=http_client.FORBIDDEN json=update, expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_delete_project_tag(self): def test_user_cannot_delete_project_tag(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
class SystemReaderTests(base_classes.TestCaseWithBootstrap, class SystemReaderTests(base_classes.TestCaseWithBootstrap,
common_auth.AuthTestMixin, common_auth.AuthTestMixin,
_SystemUserTests, _SystemUserTests,
_SystemMemberAndReaderTagTests): _SystemMemberAndReaderTagTests):
def setUp(self): def setUp(self):
super(SystemReaderTests, self).setUp() super(SystemReaderTests, self).setUp()
self.loadapp() self.loadapp()
skipping to change at line 297 skipping to change at line 297
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.CREATED expected_status_code=http.client.CREATED
) )
def test_user_can_update_project_tag(self): def test_user_can_update_project_tag(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
update = {"tags": [uuid.uuid4().hex]} update = {"tags": [uuid.uuid4().hex]}
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags' % project['id'], headers=self.headers, '/v3/projects/%s/tags' % project['id'], headers=self.headers,
json=update, json=update,
expected_status_code=http_client.OK expected_status_code=http.client.OK
) )
def test_user_can_delete_project_tag(self): def test_user_can_delete_project_tag(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
skipping to change at line 347 skipping to change at line 347
uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id) uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.get( c.get(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.NO_CONTENT expected_status_code=http.client.NO_CONTENT
) )
def test_user_can_list_tags_for_project_in_domain(self): def test_user_can_list_tags_for_project_in_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id) uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
skipping to change at line 377 skipping to change at line 377
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_update_project_tag_outside_domain(self): def test_user_cannot_update_project_tag_outside_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
new_tag = uuid.uuid4().hex new_tag = uuid.uuid4().hex
update = {"tags": [new_tag]} update = {"tags": [new_tag]}
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags' % project['id'], headers=self.headers, '/v3/projects/%s/tags' % project['id'], headers=self.headers,
json=update, expected_status_code=http_client.FORBIDDEN json=update, expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_delete_project_tag_outside_domain(self): def test_user_cannot_delete_project_tag_outside_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_get_tag_for_project_outside_domain(self): def test_user_cannot_get_tag_for_project_outside_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.get( c.get(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_list_tags_for_project_outside_domain(self): def test_user_cannot_list_tags_for_project_outside_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.get( c.get(
'/v3/projects/%s/tags' % project['id'], '/v3/projects/%s/tags' % project['id'],
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
class _DomainMemberAndReaderTagTests(object): class _DomainMemberAndReaderTagTests(object):
def test_user_cannot_create_project_tag_in_domain(self): def test_user_cannot_create_project_tag_in_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id) uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_update_project_tag_in_domain(self): def test_user_cannot_update_project_tag_in_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id) uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
new_tag = uuid.uuid4().hex new_tag = uuid.uuid4().hex
update = {"tags": [new_tag]} update = {"tags": [new_tag]}
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags' % project['id'], headers=self.headers, '/v3/projects/%s/tags' % project['id'], headers=self.headers,
json=update, expected_status_code=http_client.FORBIDDEN json=update, expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_delete_project_tag_in_domain(self): def test_user_cannot_delete_project_tag_in_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id) uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
class DomainAdminUserTests(base_classes.TestCaseWithBootstrap, class DomainAdminUserTests(base_classes.TestCaseWithBootstrap,
common_auth.AuthTestMixin, common_auth.AuthTestMixin,
_DomainUserTagTests): _DomainUserTagTests):
def setUp(self): def setUp(self):
super(DomainAdminUserTests, self).setUp() super(DomainAdminUserTests, self).setUp()
self.loadapp() self.loadapp()
skipping to change at line 546 skipping to change at line 546
def test_user_can_create_project_tag_in_domain(self): def test_user_can_create_project_tag_in_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id) uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, expected_status_code=http_client.CREATED headers=self.headers, expected_status_code=http.client.CREATED
) )
def test_user_can_update_project_tag_in_domain(self): def test_user_can_update_project_tag_in_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id) uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
new_tag = uuid.uuid4().hex new_tag = uuid.uuid4().hex
update = {"tags": [new_tag]} update = {"tags": [new_tag]}
with self.test_client() as c: with self.test_client() as c:
r = c.put( r = c.put(
'/v3/projects/%s/tags' % project['id'], headers=self.headers, '/v3/projects/%s/tags' % project['id'], headers=self.headers,
json=update, expected_status_code=http_client.OK json=update, expected_status_code=http.client.OK
) )
self.assertTrue(len(r.json['tags']) == 1) self.assertTrue(len(r.json['tags']) == 1)
self.assertEqual(new_tag, r.json['tags'][0]) self.assertEqual(new_tag, r.json['tags'][0])
def test_user_can_delete_project_tag_in_domain(self): def test_user_can_delete_project_tag_in_domain(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id) uuid.uuid4().hex, unit.new_project_ref(domain_id=self.domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
skipping to change at line 678 skipping to change at line 678
class _ProjectUserTagTests(object): class _ProjectUserTagTests(object):
def test_user_can_get_tag_for_project(self): def test_user_can_get_tag_for_project(self):
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(self.project_id, tag) PROVIDERS.resource_api.create_project_tag(self.project_id, tag)
with self.test_client() as c: with self.test_client() as c:
c.get( c.get(
'/v3/projects/%s/tags/%s' % (self.project_id, tag), '/v3/projects/%s/tags/%s' % (self.project_id, tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.NO_CONTENT expected_status_code=http.client.NO_CONTENT
) )
def test_user_can_list_tags_for_project(self): def test_user_can_list_tags_for_project(self):
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(self.project_id, tag) PROVIDERS.resource_api.create_project_tag(self.project_id, tag)
with self.test_client() as c: with self.test_client() as c:
r = c.get( r = c.get(
'/v3/projects/%s/tags' % self.project_id, headers=self.headers '/v3/projects/%s/tags' % self.project_id, headers=self.headers
) )
skipping to change at line 704 skipping to change at line 704
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_update_tag_for_other_project(self): def test_user_cannot_update_tag_for_other_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
update = {"tags": [uuid.uuid4().hex]} update = {"tags": [uuid.uuid4().hex]}
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags' % project['id'], headers=self.headers, '/v3/projects/%s/tags' % project['id'], headers=self.headers,
json=update, expected_status_code=http_client.FORBIDDEN json=update, expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_delete_tag_for_other_project(self): def test_user_cannot_delete_tag_for_other_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_get_tag_for_other_project(self): def test_user_cannot_get_tag_for_other_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.get( c.get(
'/v3/projects/%s/tags/%s' % (project['id'], tag), '/v3/projects/%s/tags/%s' % (project['id'], tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_list_tags_for_other_project(self): def test_user_cannot_list_tags_for_other_project(self):
project = PROVIDERS.resource_api.create_project( project = PROVIDERS.resource_api.create_project(
uuid.uuid4().hex, uuid.uuid4().hex,
unit.new_project_ref(domain_id=CONF.identity.default_domain_id) unit.new_project_ref(domain_id=CONF.identity.default_domain_id)
) )
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(project['id'], tag) PROVIDERS.resource_api.create_project_tag(project['id'], tag)
with self.test_client() as c: with self.test_client() as c:
c.get( c.get(
'/v3/projects/%s/tags' % project['id'], '/v3/projects/%s/tags' % project['id'],
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
class _ProjectMemberAndReaderTagTests(object): class _ProjectMemberAndReaderTagTests(object):
def test_user_cannot_create_project_tag(self): def test_user_cannot_create_project_tag(self):
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (self.project_id, tag), '/v3/projects/%s/tags/%s' % (self.project_id, tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_update_project_tag(self): def test_user_cannot_update_project_tag(self):
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(self.project_id, tag) PROVIDERS.resource_api.create_project_tag(self.project_id, tag)
update = {"tags": [uuid.uuid4().hex]} update = {"tags": [uuid.uuid4().hex]}
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags' % self.project_id, headers=self.headers, '/v3/projects/%s/tags' % self.project_id, headers=self.headers,
json=update, expected_status_code=http_client.FORBIDDEN json=update, expected_status_code=http.client.FORBIDDEN
) )
def test_user_cannot_delete_project_tag(self): def test_user_cannot_delete_project_tag(self):
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(self.project_id, tag) PROVIDERS.resource_api.create_project_tag(self.project_id, tag)
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/projects/%s/tags/%s' % (self.project_id, tag), '/v3/projects/%s/tags/%s' % (self.project_id, tag),
headers=self.headers, headers=self.headers,
expected_status_code=http_client.FORBIDDEN expected_status_code=http.client.FORBIDDEN
) )
class ProjectAdminTests(base_classes.TestCaseWithBootstrap, class ProjectAdminTests(base_classes.TestCaseWithBootstrap,
common_auth.AuthTestMixin, common_auth.AuthTestMixin,
_ProjectUserTagTests): _ProjectUserTagTests):
def setUp(self): def setUp(self):
super(ProjectAdminTests, self).setUp() super(ProjectAdminTests, self).setUp()
self.loadapp() self.loadapp()
skipping to change at line 848 skipping to change at line 848
with self.test_client() as c: with self.test_client() as c:
r = c.post('/v3/auth/tokens', json=auth) r = c.post('/v3/auth/tokens', json=auth)
self.token_id = r.headers['X-Subject-Token'] self.token_id = r.headers['X-Subject-Token']
self.headers = {'X-Auth-Token': self.token_id} self.headers = {'X-Auth-Token': self.token_id}
def test_user_can_create_project_tag(self): def test_user_can_create_project_tag(self):
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags/%s' % (self.project_id, tag), '/v3/projects/%s/tags/%s' % (self.project_id, tag),
headers=self.headers, expected_status_code=http_client.CREATED headers=self.headers, expected_status_code=http.client.CREATED
) )
def test_user_can_update_project_tag(self): def test_user_can_update_project_tag(self):
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(self.project_id, tag) PROVIDERS.resource_api.create_project_tag(self.project_id, tag)
update = {"tags": [uuid.uuid4().hex]} update = {"tags": [uuid.uuid4().hex]}
with self.test_client() as c: with self.test_client() as c:
c.put( c.put(
'/v3/projects/%s/tags' % self.project_id, headers=self.headers, '/v3/projects/%s/tags' % self.project_id, headers=self.headers,
json=update, expected_status_code=http_client.OK json=update, expected_status_code=http.client.OK
) )
def test_user_can_delete_project_tag(self): def test_user_can_delete_project_tag(self):
tag = uuid.uuid4().hex tag = uuid.uuid4().hex
PROVIDERS.resource_api.create_project_tag(self.project_id, tag) PROVIDERS.resource_api.create_project_tag(self.project_id, tag)
with self.test_client() as c: with self.test_client() as c:
c.delete( c.delete(
'/v3/projects/%s/tags/%s' % (self.project_id, tag), '/v3/projects/%s/tags/%s' % (self.project_id, tag),
headers=self.headers headers=self.headers
 End of changes. 33 change blocks. 
32 lines changed or deleted 32 lines changed or added

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