diff --git a/nova/tests/unit/api/openstack/compute/contrib/test_neutron_security_groups.py b/nova/tests/unit/api/openstack/compute/contrib/test_neutron_security_groups.py index f64d1ada45..e170a8461a 100644 --- a/nova/tests/unit/api/openstack/compute/contrib/test_neutron_security_groups.py +++ b/nova/tests/unit/api/openstack/compute/contrib/test_neutron_security_groups.py @@ -12,6 +12,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import six import uuid import mock @@ -638,6 +639,14 @@ class MockClient(object): def create_security_group(self, body=None): s = body.get('security_group') + if not isinstance(s.get('name', ''), six.string_types): + msg = ('BadRequest: Invalid input for name. Reason: ' + 'None is not a valid string.') + raise n_exc.BadRequest(message=msg) + if not isinstance(s.get('description.', ''), six.string_types): + msg = ('BadRequest: Invalid input for description. Reason: ' + 'None is not a valid string.') + raise n_exc.BadRequest(message=msg) if len(s.get('name')) > 255 or len(s.get('description')) > 255: msg = 'Security Group name great than 255' raise n_exc.NeutronClientException(message=msg, status_code=401) diff --git a/nova/tests/unit/api/openstack/compute/contrib/test_security_groups.py b/nova/tests/unit/api/openstack/compute/contrib/test_security_groups.py index 9669a3eb8a..580386ea84 100644 --- a/nova/tests/unit/api/openstack/compute/contrib/test_security_groups.py +++ b/nova/tests/unit/api/openstack/compute/contrib/test_security_groups.py @@ -164,7 +164,7 @@ class TestSecurityGroupsV21(test.TestCase): req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups') self.assertRaises(webob.exc.HTTPBadRequest, - self.controller.create, req, sg) + self.controller.create, req, {'security_group': sg}) self._assert_no_security_groups_reserved(req.environ['nova.context'])