Merge "Fix test_create_security_group_with_no_name"
This commit is contained in:
commit
a625ef75c2
|
@ -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)
|
||||
|
|
|
@ -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'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue