Merge "Avoid any capitalization of the name "None""
This commit is contained in:
commit
a4b1482157
@ -194,6 +194,11 @@ class CreateShare(command.ShowOne):
|
|||||||
# TODO(s0ru): the table shows 'Field', 'Value'
|
# TODO(s0ru): the table shows 'Field', 'Value'
|
||||||
share_client = self.app.client_manager.share
|
share_client = self.app.client_manager.share
|
||||||
|
|
||||||
|
if parsed_args.name:
|
||||||
|
if parsed_args.name.capitalize() == 'None':
|
||||||
|
raise apiclient_exceptions.CommandError(
|
||||||
|
"Share name cannot be with the value 'None'")
|
||||||
|
|
||||||
if parsed_args.share_type:
|
if parsed_args.share_type:
|
||||||
share_type = apiutils.find_resource(share_client.share_types,
|
share_type = apiutils.find_resource(share_client.share_types,
|
||||||
parsed_args.share_type).id
|
parsed_args.share_type).id
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import ddt
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ class TestShare(manila_fakes.TestShare):
|
|||||||
return shares
|
return shares
|
||||||
|
|
||||||
|
|
||||||
|
@ddt.ddt
|
||||||
class TestShareCreate(TestShare):
|
class TestShareCreate(TestShare):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -360,6 +362,28 @@ class TestShareCreate(TestShare):
|
|||||||
self.cmd.take_action,
|
self.cmd.take_action,
|
||||||
parsed_args)
|
parsed_args)
|
||||||
|
|
||||||
|
@ddt.data('None', 'NONE', 'none')
|
||||||
|
def test_create_share_with_the_name_none(self, name):
|
||||||
|
arglist = [
|
||||||
|
'--name', name,
|
||||||
|
self.new_share.share_proto,
|
||||||
|
str(self.new_share.size),
|
||||||
|
'--share-type', self.share_type.id,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('name', name),
|
||||||
|
('share_proto', self.new_share.share_proto),
|
||||||
|
('size', self.new_share.size),
|
||||||
|
('share_type', self.share_type.id),
|
||||||
|
]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
self.assertRaises(
|
||||||
|
exceptions.CommandError,
|
||||||
|
self.cmd.take_action,
|
||||||
|
parsed_args)
|
||||||
|
|
||||||
|
|
||||||
class TestShareDelete(TestShare):
|
class TestShareDelete(TestShare):
|
||||||
|
|
||||||
|
@ -2201,6 +2201,12 @@ class ShellTest(test_utils.TestCase):
|
|||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exceptions.CommandError, self.run_command, "create nfs 1")
|
exceptions.CommandError, self.run_command, "create nfs 1")
|
||||||
|
|
||||||
|
@ddt.data('None', 'NONE', 'none')
|
||||||
|
def test_create_share_with_the_name_none(self, name):
|
||||||
|
self.assertRaises(
|
||||||
|
exceptions.CommandError, self.run_command,
|
||||||
|
"create nfs 1 --name %s --share-type test_type" % name)
|
||||||
|
|
||||||
def test_allow_access_cert(self):
|
def test_allow_access_cert(self):
|
||||||
self.run_command("access-allow 1234 cert client.example.com")
|
self.run_command("access-allow 1234 cert client.example.com")
|
||||||
|
|
||||||
|
@ -986,9 +986,10 @@ def do_create(cs, args):
|
|||||||
if args.snapshot_id:
|
if args.snapshot_id:
|
||||||
snapshot = _find_share_snapshot(cs, args.snapshot_id).id
|
snapshot = _find_share_snapshot(cs, args.snapshot_id).id
|
||||||
|
|
||||||
if args.name == 'None':
|
if args.name:
|
||||||
raise exceptions.CommandError(
|
if args.name.capitalize() == 'None':
|
||||||
"Share name cannot be with the value 'None'")
|
raise exceptions.CommandError(
|
||||||
|
"Share name cannot be with the value 'None'")
|
||||||
|
|
||||||
if not args.share_type:
|
if not args.share_type:
|
||||||
try:
|
try:
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
`Launchpad bug 1909477 <https://bugs.launchpad.net/python-manilaclient/+bug/1909477>`_
|
||||||
|
has been fixed by prevent sending the share creation request with any capitalization of
|
||||||
|
the name "None".
|
Loading…
Reference in New Issue
Block a user