[LBaaS v2] Validate name, description and tenant_id attributes length

* Unskip related API tests
* Fixed a number of negative pool tests which didn't pass
  listener_id with create_pool requests thus didn't actually
  test anything.

Change-Id: If50c664086e1b2bffa2899775de010c0a424f505
Related-Bug: #1408230
This commit is contained in:
Elena Ezhova 2015-09-23 15:08:10 +03:00
parent ad7072c404
commit b54dc219c1
4 changed files with 48 additions and 40 deletions

View File

@ -153,15 +153,16 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True, 'is_visible': True,
'primary_key': True}, 'primary_key': True},
'name': {'allow_post': True, 'allow_put': True, 'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None}, 'validate': {'type:string': attr.NAME_MAX_LEN},
'default': '', 'default': '',
'is_visible': True}, 'is_visible': True},
'tenant_id': {'allow_post': True, 'allow_put': False, 'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:not_empty_string': None}, 'validate': {'type:not_empty_string':
attr.TENANT_ID_MAX_LEN},
'required_by_policy': True, 'required_by_policy': True,
'is_visible': True}, 'is_visible': True},
'description': {'allow_post': True, 'allow_put': True, 'description': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None}, 'validate': {'type:string': attr.DESCRIPTION_MAX_LEN},
'is_visible': True, 'default': ''}, 'is_visible': True, 'default': ''},
'vip_subnet_id': {'allow_post': True, 'allow_put': False, 'vip_subnet_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:uuid': None}, 'validate': {'type:uuid': None},
@ -196,15 +197,16 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True, 'is_visible': True,
'primary_key': True}, 'primary_key': True},
'tenant_id': {'allow_post': True, 'allow_put': False, 'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:not_empty_string': None}, 'validate': {'type:not_empty_string':
attr.TENANT_ID_MAX_LEN},
'required_by_policy': True, 'required_by_policy': True,
'is_visible': True}, 'is_visible': True},
'name': {'allow_post': True, 'allow_put': True, 'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None}, 'validate': {'type:string': attr.NAME_MAX_LEN},
'default': '', 'default': '',
'is_visible': True}, 'is_visible': True},
'description': {'allow_post': True, 'allow_put': True, 'description': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None}, 'validate': {'type:string': attr.DESCRIPTION_MAX_LEN},
'is_visible': True, 'default': ''}, 'is_visible': True, 'default': ''},
'loadbalancer_id': {'allow_post': True, 'allow_put': False, 'loadbalancer_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:uuid': None}, 'validate': {'type:uuid': None},
@ -248,14 +250,15 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True, 'is_visible': True,
'primary_key': True}, 'primary_key': True},
'tenant_id': {'allow_post': True, 'allow_put': False, 'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:not_empty_string': None}, 'validate': {'type:not_empty_string':
attr.TENANT_ID_MAX_LEN},
'required_by_policy': True, 'required_by_policy': True,
'is_visible': True}, 'is_visible': True},
'name': {'allow_post': True, 'allow_put': True, 'name': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None}, 'validate': {'type:string': attr.NAME_MAX_LEN},
'is_visible': True, 'default': ''}, 'is_visible': True, 'default': ''},
'description': {'allow_post': True, 'allow_put': True, 'description': {'allow_post': True, 'allow_put': True,
'validate': {'type:string': None}, 'validate': {'type:string': attr.DESCRIPTION_MAX_LEN},
'is_visible': True, 'default': ''}, 'is_visible': True, 'default': ''},
'listener_id': {'allow_post': True, 'allow_put': False, 'listener_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:uuid': None}, 'validate': {'type:uuid': None},
@ -298,7 +301,8 @@ RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True, 'is_visible': True,
'primary_key': True}, 'primary_key': True},
'tenant_id': {'allow_post': True, 'allow_put': False, 'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:not_empty_string': None}, 'validate': {'type:not_empty_string':
attr.TENANT_ID_MAX_LEN},
'required_by_policy': True, 'required_by_policy': True,
'is_visible': True}, 'is_visible': True},
'pool_id': {'allow_post': True, 'allow_put': False, 'pool_id': {'allow_post': True, 'allow_put': False,
@ -362,7 +366,8 @@ SUB_RESOURCE_ATTRIBUTE_MAP = {
'is_visible': True, 'is_visible': True,
'primary_key': True}, 'primary_key': True},
'tenant_id': {'allow_post': True, 'allow_put': False, 'tenant_id': {'allow_post': True, 'allow_put': False,
'validate': {'type:not_empty_string': None}, 'validate': {'type:not_empty_string':
attr.TENANT_ID_MAX_LEN},
'required_by_policy': True, 'required_by_policy': True,
'is_visible': True}, 'is_visible': True},
'address': {'allow_post': True, 'allow_put': False, 'address': {'allow_post': True, 'allow_put': False,

View File

@ -15,7 +15,6 @@
from oslo_log import log as logging from oslo_log import log as logging
from tempest_lib.common.utils import data_utils from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions from tempest_lib import exceptions
from neutron_lbaas.tests.tempest.lib import config from neutron_lbaas.tests.tempest.lib import config
@ -218,7 +217,6 @@ class ListenersTestJSON(base.BaseTestCase):
self._check_status_tree(load_balancer_id=self.load_balancer_id, self._check_status_tree(load_balancer_id=self.load_balancer_id,
listener_ids=[self.listener_id]) listener_ids=[self.listener_id])
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_create_listener_invalid_name(self): def test_create_listener_invalid_name(self):
"""Test create listener with an invalid name""" """Test create listener with an invalid name"""
@ -231,7 +229,6 @@ class ListenersTestJSON(base.BaseTestCase):
self._check_status_tree(load_balancer_id=self.load_balancer_id, self._check_status_tree(load_balancer_id=self.load_balancer_id,
listener_ids=[self.listener_id]) listener_ids=[self.listener_id])
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_create_listener_invalid_description(self): def test_create_listener_invalid_description(self):
"""Test create listener with an invalid description""" """Test create listener with an invalid description"""
@ -403,7 +400,6 @@ class ListenersTestJSON(base.BaseTestCase):
self._check_status_tree(load_balancer_id=self.load_balancer_id, self._check_status_tree(load_balancer_id=self.load_balancer_id,
listener_ids=[self.listener_id]) listener_ids=[self.listener_id])
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_update_listener_invalid_name(self): def test_update_listener_invalid_name(self):
"""Test update a listener with an invalid name""" """Test update a listener with an invalid name"""
@ -414,7 +410,6 @@ class ListenersTestJSON(base.BaseTestCase):
self._check_status_tree(load_balancer_id=self.load_balancer_id, self._check_status_tree(load_balancer_id=self.load_balancer_id,
listener_ids=[self.listener_id]) listener_ids=[self.listener_id])
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_update_listener_invalid_description(self): def test_update_listener_invalid_description(self):
"""Test update a listener with an invalid description""" """Test update a listener with an invalid description"""

View File

@ -17,7 +17,6 @@ from netaddr import IPAddress
from oslo_log import log as logging from oslo_log import log as logging
from tempest_lib.common.utils import data_utils from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions from tempest_lib import exceptions
from neutron_lbaas.tests.tempest.lib import config from neutron_lbaas.tests.tempest.lib import config
@ -229,7 +228,6 @@ class LoadBalancersTestJSON(base.BaseTestCase):
wait=False, wait=False,
tenant_id="&^%123") tenant_id="&^%123")
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_create_load_balancer_invalid_name(self): def test_create_load_balancer_invalid_name(self):
"""Test create load balancer with an invalid name""" """Test create load balancer with an invalid name"""
@ -240,7 +238,6 @@ class LoadBalancersTestJSON(base.BaseTestCase):
vip_subnet_id=self.subnet['id'], vip_subnet_id=self.subnet['id'],
name='n' * 256) name='n' * 256)
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_create_load_balancer_invalid_description(self): def test_create_load_balancer_invalid_description(self):
"""Test create load balancer with an invalid description""" """Test create load balancer with an invalid description"""
@ -325,7 +322,6 @@ class LoadBalancersTestJSON(base.BaseTestCase):
self.load_balancer_id) self.load_balancer_id)
self.assertEqual(load_balancer.get('name'), "") self.assertEqual(load_balancer.get('name'), "")
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_update_load_balancer_invalid_name(self): def test_update_load_balancer_invalid_name(self):
"""Test update load balancer with invalid name""" """Test update load balancer with invalid name"""
@ -347,7 +343,6 @@ class LoadBalancersTestJSON(base.BaseTestCase):
load_balancer_new = load_balancer['name'] load_balancer_new = load_balancer['name']
self.assertEqual(load_balancer_initial, load_balancer_new) self.assertEqual(load_balancer_initial, load_balancer_new)
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_update_load_balancer_invalid_description(self): def test_update_load_balancer_invalid_description(self):
"""Test update load balancer with invalid description""" """Test update load balancer with invalid description"""

View File

@ -13,7 +13,6 @@
# under the License. # under the License.
from tempest_lib.common.utils import data_utils from tempest_lib.common.utils import data_utils
from tempest_lib import decorators
from tempest_lib import exceptions as ex from tempest_lib import exceptions as ex
from neutron_lbaas.tests.tempest.lib import test from neutron_lbaas.tests.tempest.lib import test
@ -48,6 +47,9 @@ class TestPools(base.BaseTestCase):
tenant_id=cls.subnet.get('tenant_id'), tenant_id=cls.subnet.get('tenant_id'),
vip_subnet_id=cls.subnet.get('id'), vip_subnet_id=cls.subnet.get('id'),
wait=True) wait=True)
cls.listener = cls._create_listener(
loadbalancer_id=cls.load_balancer.get('id'),
protocol='HTTP', protocol_port=80)
def increment_protocol_port(self): def increment_protocol_port(self):
global PROTOCOL_PORT global PROTOCOL_PORT
@ -213,7 +215,8 @@ class TestPools(base.BaseTestCase):
"""Test create pool with an invalid protocol""" """Test create pool with an invalid protocol"""
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='UDP', protocol='UDP',
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_invalid_session_persistence_field(self): def test_create_pool_invalid_session_persistence_field(self):
@ -221,14 +224,16 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='HTTP', protocol='HTTP',
session_persistence={'type': 'HTTP'}, session_persistence={'type': 'HTTP'},
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_invalid_algorithm(self): def test_create_pool_invalid_algorithm(self):
"""Test create pool with an invalid algorithm""" """Test create pool with an invalid algorithm"""
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='HTTP', protocol='HTTP',
lb_algorithm='LEAST_CON') lb_algorithm='LEAST_CON',
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_invalid_admin_state_up(self): def test_create_pool_invalid_admin_state_up(self):
@ -236,7 +241,8 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='HTTP', protocol='HTTP',
admin_state_up="$!1%9823", admin_state_up="$!1%9823",
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_invalid_listener_field(self): def test_create_pool_invalid_listener_field(self):
@ -270,7 +276,8 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='HTTP', protocol='HTTP',
lb_algorithm='ROUND_ROBIN', lb_algorithm='ROUND_ROBIN',
protocol_port=80) protocol_port=80,
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_empty_listener_field(self): def test_create_pool_empty_listener_field(self):
@ -303,7 +310,8 @@ class TestPools(base.BaseTestCase):
"""Test create pool with an empty protocol""" """Test create pool with an empty protocol"""
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol="", protocol="",
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_empty_session_persistence_field(self): def test_create_pool_empty_session_persistence_field(self):
@ -311,14 +319,16 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
session_persistence="", session_persistence="",
protocol='HTTP', protocol='HTTP',
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_empty_algorithm(self): def test_create_pool_empty_algorithm(self):
"""Test create pool with an empty algorithm""" """Test create pool with an empty algorithm"""
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='HTTP', protocol='HTTP',
lb_algorithm="") lb_algorithm="",
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_empty_admin_state_up(self): def test_create_pool_empty_admin_state_up(self):
@ -334,7 +344,8 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='HTTP', protocol='HTTP',
tenant_id="", tenant_id="",
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_for_other_tenant_field(self): def test_create_pool_for_other_tenant_field(self):
@ -343,9 +354,9 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='HTTP', protocol='HTTP',
tenant_id=tenant, tenant_id=tenant,
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_invalid_name_field(self): def test_create_pool_invalid_name_field(self):
""" """
@ -355,18 +366,19 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
protocol='HTTP', protocol='HTTP',
lb_algorithm='ROUND_ROBIN', lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'],
name='n' * 256) name='n' * 256)
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_invalid_desc_field(self): def test_create_pool_invalid_desc_field(self):
""" """
known bug with input more than 255 chars known bug with input more than 255 chars
Test create pool with invalid desc field Test create pool with invalid desc field
""" """
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._prepare_and_create_pool,
protocol='HTTP', protocol='HTTP',
lb_algorithm='ROUND_ROBIN', lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'],
description='d' * 256) description='d' * 256)
@test.attr(type='negative') @test.attr(type='negative')
@ -377,7 +389,8 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
session_persistence={'type': 'UNSUPPORTED'}, session_persistence={'type': 'UNSUPPORTED'},
protocol='HTTP', protocol='HTTP',
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='smoke') @test.attr(type='smoke')
def test_create_pool_with_session_persistence_http_cookie(self): def test_create_pool_with_session_persistence_http_cookie(self):
@ -405,7 +418,8 @@ class TestPools(base.BaseTestCase):
session_persistence={'type': 'HTTP_COOKIE', session_persistence={'type': 'HTTP_COOKIE',
'cookie_name': 'sessionId'}, 'cookie_name': 'sessionId'},
protocol='HTTP', protocol='HTTP',
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='negative') @test.attr(type='negative')
def test_create_pool_with_session_persistence_without_cookie_name(self): def test_create_pool_with_session_persistence_without_cookie_name(self):
@ -415,7 +429,8 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self._create_pool, self.assertRaises(ex.BadRequest, self._create_pool,
session_persistence={'type': 'APP_COOKIE'}, session_persistence={'type': 'APP_COOKIE'},
protocol='HTTP', protocol='HTTP',
lb_algorithm='ROUND_ROBIN') lb_algorithm='ROUND_ROBIN',
listener_id=self.listener['id'])
@test.attr(type='smoke') @test.attr(type='smoke')
def test_update_pool(self): def test_update_pool(self):
@ -466,7 +481,6 @@ class TestPools(base.BaseTestCase):
pool = self._update_pool(new_pool.get('id')) pool = self._update_pool(new_pool.get('id'))
self.assertAlmostEqual(sess_pers, pool.get('session_persistence')) self.assertAlmostEqual(sess_pers, pool.get('session_persistence'))
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_update_pool_invalid_name(self): def test_update_pool_invalid_name(self):
"""Test update pool with invalid name""" """Test update pool with invalid name"""
@ -474,7 +488,6 @@ class TestPools(base.BaseTestCase):
self.assertRaises(ex.BadRequest, self.pools_client.update_pool, self.assertRaises(ex.BadRequest, self.pools_client.update_pool,
new_pool.get('id'), name='n' * 256) new_pool.get('id'), name='n' * 256)
@decorators.skip_because(bug="1434717")
@test.attr(type='negative') @test.attr(type='negative')
def test_update_pool_invalid_desc(self): def test_update_pool_invalid_desc(self):
"""Test update pool with invalid desc""" """Test update pool with invalid desc"""