|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +# you may not use this file except in compliance with the License. |
| 3 | +# You may obtain a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +# See the License for the specific language governing permissions and |
| 11 | +# limitations under the License. |
| 12 | + |
| 13 | +from nova import test |
| 14 | +from nova.tests import fixtures as nova_fixtures |
| 15 | +from nova.tests.functional.api import client |
| 16 | +from nova.tests.functional import integrated_helpers |
| 17 | + |
| 18 | + |
| 19 | +class TestCreateServerGroupWithEmptyPolicies( |
| 20 | + test.TestCase, integrated_helpers.InstanceHelperMixin, |
| 21 | +): |
| 22 | + """Demonstrate bug #1894966. |
| 23 | +
|
| 24 | + Attempt to create a server group with an invalid 'policies' field. It |
| 25 | + should fail cleanly. |
| 26 | + """ |
| 27 | + def setUp(self): |
| 28 | + super().setUp() |
| 29 | + |
| 30 | + api_fixture = self.useFixture(nova_fixtures.OSAPIFixture( |
| 31 | + api_version='v2.1')) |
| 32 | + self.api = api_fixture.api |
| 33 | + self.api.microversion = '2.63' # the last version with the bug |
| 34 | + |
| 35 | + def test_create_with_empty_policies(self): |
| 36 | + exc = self.assertRaises( |
| 37 | + client.OpenStackApiException, |
| 38 | + self.api.post_server_groups, |
| 39 | + {'name': 'test group', 'policies': []}) |
| 40 | + # FIXME(stephenfin): This should not be a 500 error |
| 41 | + self.assertEqual(500, exc.response.status_code) |
0 commit comments