Merge "Disallow specifying too long name for meter-label"
This commit is contained in:
@ -49,6 +49,7 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'is_visible': True,
|
||||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {'type:string': attr.NAME_MAX_LEN},
|
||||
'is_visible': True, 'default': ''},
|
||||
'description': {'allow_post': True, 'allow_put': False,
|
||||
'validate': {
|
||||
|
@ -15,8 +15,11 @@
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest import test
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.tests.tempest.api import base
|
||||
|
||||
LONG_NAME_OK = 'x' * (attr.NAME_MAX_LEN)
|
||||
|
||||
|
||||
class MeteringTestJSON(base.BaseAdminNetworkTest):
|
||||
|
||||
@ -81,6 +84,17 @@ class MeteringTestJSON(base.BaseAdminNetworkTest):
|
||||
id=metering_label['id']))
|
||||
self.assertEqual(len(labels['metering_labels']), 1)
|
||||
|
||||
@test.idempotent_id('46608f8d-2e27-4eb6-a0b4-dbe405144c4d')
|
||||
def test_create_delete_metering_label_with_name_max_length(self):
|
||||
name = LONG_NAME_OK
|
||||
body = self.admin_client.create_metering_label(name=name)
|
||||
metering_label = body['metering_label']
|
||||
self.addCleanup(self._delete_metering_label,
|
||||
metering_label['id'])
|
||||
labels = (self.admin_client.list_metering_labels(
|
||||
id=metering_label['id']))
|
||||
self.assertEqual(len(labels['metering_labels']), 1)
|
||||
|
||||
@test.idempotent_id('cfc500d9-9de6-4847-8803-62889c097d45')
|
||||
def test_show_metering_label(self):
|
||||
# Verifies the details of a label
|
||||
|
36
neutron/tests/tempest/api/test_metering_negative.py
Normal file
36
neutron/tests/tempest/api/test_metering_negative.py
Normal file
@ -0,0 +1,36 @@
|
||||
# Copyright 2016 FUJITSU LIMITED
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from tempest.lib import exceptions as lib_exc
|
||||
from tempest import test
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
from neutron.tests.tempest.api import base
|
||||
|
||||
LONG_NAME_NG = 'x' * (attr.NAME_MAX_LEN + 1)
|
||||
|
||||
|
||||
class MeteringNegativeTestJSON(base.BaseAdminNetworkTest):
|
||||
|
||||
@classmethod
|
||||
@test.requires_ext(extension="metering", service="network")
|
||||
def resource_setup(cls):
|
||||
super(MeteringNegativeTestJSON, cls).resource_setup()
|
||||
|
||||
@test.attr(type='negative')
|
||||
@test.idempotent_id('8b3f7c84-9d37-4771-8681-bfd2c07f3c2d')
|
||||
def test_create_metering_label_with_too_long_name(self):
|
||||
self.assertRaises(lib_exc.BadRequest,
|
||||
self.admin_client.create_metering_label,
|
||||
name=LONG_NAME_NG)
|
Reference in New Issue
Block a user