Merge "Add "test_port_forwardings_negative" module"

This commit is contained in:
Zuul 2020-06-25 13:27:29 +00:00 committed by Gerrit Code Review
commit 11418fd4c7
1 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,83 @@
# Copyright 2020 OpenStack Foundation
# All Rights Reserved.
#
# 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.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions
from neutron_tempest_plugin.api import base
from neutron_tempest_plugin import config
CONF = config.CONF
class PortForwardingNegativeTestJSON(base.BaseNetworkTest):
required_extensions = ['router', 'floating-ip-port-forwarding']
@classmethod
def resource_setup(cls):
super(PortForwardingNegativeTestJSON, cls).resource_setup()
cls.ext_net_id = CONF.network.public_network_id
# Create network, subnet, router and add interface
cls.network = cls.create_network()
cls.subnet = cls.create_subnet(cls.network)
cls.router = cls.create_router(data_utils.rand_name('router'),
external_network_id=cls.ext_net_id)
cls.create_router_interface(cls.router['id'], cls.subnet['id'])
@decorators.attr(type='negative')
@decorators.idempotent_id('63c0d406-99d5-11ea-bb37-0242ac130002')
def test_mapping_same_fip_and_external_port_to_different_dest(self):
port1 = self.create_port(self.network)
port2 = self.create_port(self.network)
fip_for_pf = self.create_floatingip()
self.create_port_forwarding(
fip_for_pf['id'],
internal_port_id=port1['id'],
internal_ip_address=port1['fixed_ips'][0]['ip_address'],
internal_port=1111, external_port=2222,
protocol="tcp")
self.assertRaises(
exceptions.BadRequest,
self.create_port_forwarding,
fip_for_pf['id'],
internal_port_id=port2['id'],
internal_ip_address=port2['fixed_ips'][0]['ip_address'],
internal_port=3333, external_port=2222,
protocol="tcp")
@decorators.attr(type='negative')
@decorators.idempotent_id('0c229a4c-9f28-11ea-bb37-0242ac130002')
def test_mapping_different_external_ports_to_the_same_destination(self):
port = self.create_port(self.network)
fip_for_pf = self.create_floatingip()
self.create_port_forwarding(
fip_for_pf['id'],
internal_port_id=port['id'],
internal_ip_address=port['fixed_ips'][0]['ip_address'],
internal_port=1111, external_port=3333,
protocol="tcp")
self.assertRaises(
exceptions.BadRequest,
self.create_port_forwarding,
fip_for_pf['id'],
internal_port_id=port['id'],
internal_ip_address=port['fixed_ips'][0]['ip_address'],
internal_port=1111, external_port=5555,
protocol="tcp")