Skip to content

Commit 2c66962

Browse files
committed
tests: Add regression test for bug 1894966
You must specify the 'policies' field. Currently, not doing so will result in a HTTP 500 error code. This should be a 4xx error. Add a test to demonstrate the bug before we provide a fix. Change-Id: I72e85855f621d3a51cd58d14247abd302dcd958b Signed-off-by: Stephen Finucane <[email protected]> Related-Bug: #1894966
1 parent e0f088c commit 2c66962

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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

Comments
 (0)