blob: 91ab9d6dc1be2624579482779edd430fd2e92ecf [file] [log] [blame]
rossellae02431e2013-11-15 17:58:29 +01001# Copyright 2013 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.api.network import base_routers as base
17from tempest.common.utils import data_utils
18from tempest import exceptions
Yoshihiro Kaneko05670262014-01-18 19:22:44 +090019from tempest import test
rossellae02431e2013-11-15 17:58:29 +010020
21
22class RoutersNegativeTest(base.BaseRouterTest):
23 _interface = 'json'
24
25 @classmethod
Masayuki Igawa6d495d62014-03-19 16:38:57 +090026 @test.safe_setup
rossellae02431e2013-11-15 17:58:29 +010027 def setUpClass(cls):
28 super(RoutersNegativeTest, cls).setUpClass()
Yoshihiro Kaneko05670262014-01-18 19:22:44 +090029 if not test.is_extension_enabled('router', 'network'):
30 msg = "router extension not enabled."
31 raise cls.skipException(msg)
rossellae02431e2013-11-15 17:58:29 +010032 cls.router = cls.create_router(data_utils.rand_name('router-'))
33 cls.network = cls.create_network()
34 cls.subnet = cls.create_subnet(cls.network)
35
Yoshihiro Kaneko05670262014-01-18 19:22:44 +090036 @test.attr(type=['negative', 'smoke'])
rossellae02431e2013-11-15 17:58:29 +010037 def test_router_add_gateway_invalid_network_returns_404(self):
38 self.assertRaises(exceptions.NotFound,
39 self.client.update_router,
40 self.router['id'],
41 external_gateway_info={
42 'network_id': self.router['id']})
43
Yoshihiro Kaneko05670262014-01-18 19:22:44 +090044 @test.attr(type=['negative', 'smoke'])
rossellae02431e2013-11-15 17:58:29 +010045 def test_router_add_gateway_net_not_external_returns_400(self):
46 self.create_subnet(self.network)
47 self.assertRaises(exceptions.BadRequest,
48 self.client.update_router,
49 self.router['id'],
50 external_gateway_info={
51 'network_id': self.network['id']})
52
Yoshihiro Kaneko05670262014-01-18 19:22:44 +090053 @test.attr(type=['negative', 'smoke'])
rossellae02431e2013-11-15 17:58:29 +010054 def test_router_remove_interface_in_use_returns_409(self):
55 self.client.add_router_interface_with_subnet_id(
56 self.router['id'], self.subnet['id'])
57 self.assertRaises(exceptions.Conflict,
58 self.client.delete_router,
59 self.router['id'])