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