Merge "Support sha256 for vpn-ikepolicy and vpn-ipsecpolicy"

This commit is contained in:
Jenkins
2016-05-13 04:03:32 +00:00
committed by Gerrit Code Review
4 changed files with 50 additions and 12 deletions

View File

@@ -49,7 +49,7 @@ class CreateIKEPolicy(neutronv20.CreateCommand):
help=_('Description of the IKE policy')) help=_('Description of the IKE policy'))
parser.add_argument( parser.add_argument(
'--auth-algorithm', '--auth-algorithm',
default='sha1', choices=['sha1'], default='sha1', choices=['sha1', 'sha256'],
help=_('Authentication algorithm in lowercase. ' help=_('Authentication algorithm in lowercase. '
'Default:sha1')) 'Default:sha1'))
parser.add_argument( parser.add_argument(

View File

@@ -53,7 +53,7 @@ class CreateIPsecPolicy(neutronv20.CreateCommand):
help=_('Transform protocol in lowercase, default:esp')) help=_('Transform protocol in lowercase, default:esp'))
parser.add_argument( parser.add_argument(
'--auth-algorithm', '--auth-algorithm',
default='sha1', choices=['sha1'], default='sha1', choices=['sha1', 'sha256'],
help=_('Authentication algorithm in lowercase, default:sha1')) help=_('Authentication algorithm in lowercase, default:sha1'))
parser.add_argument( parser.add_argument(
'--encryption-algorithm', '--encryption-algorithm',

View File

@@ -25,13 +25,14 @@ class CLITestV20VpnIkePolicyJSON(test_cli20.CLITestV20Base):
non_admin_status_resources = ['ikepolicy'] non_admin_status_resources = ['ikepolicy']
def test_create_ikepolicy_all_params(self): def _test_create_ikepolicy_all_params(self, auth='sha1',
expected_exc=None):
# vpn-ikepolicy-create all params. # vpn-ikepolicy-create all params.
resource = 'ikepolicy' resource = 'ikepolicy'
cmd = ikepolicy.CreateIKEPolicy(test_cli20.MyApp(sys.stdout), None) cmd = ikepolicy.CreateIKEPolicy(test_cli20.MyApp(sys.stdout), None)
name = 'ikepolicy1' name = 'ikepolicy1'
description = 'my-ike-policy' description = 'my-ike-policy'
auth_algorithm = 'sha1' auth_algorithm = auth
encryption_algorithm = 'aes-256' encryption_algorithm = 'aes-256'
ike_version = 'v1' ike_version = 'v1'
phase1_negotiation_mode = 'main' phase1_negotiation_mode = 'main'
@@ -67,9 +68,27 @@ class CLITestV20VpnIkePolicyJSON(test_cli20.CLITestV20Base):
}, },
} }
self._test_create_resource(resource, cmd, name, my_id, args, if not expected_exc:
position_names, position_values, self._test_create_resource(resource, cmd, name, my_id, args,
extra_body=extra_body) position_names, position_values,
extra_body=extra_body)
else:
self.assertRaises(
expected_exc,
self._test_create_resource,
resource, cmd, name, my_id, args,
position_names, position_values,
extra_body=extra_body)
def test_create_ikepolicy_all_params(self):
self._test_create_ikepolicy_all_params()
def test_create_ikepolicy_auth_sha256(self):
self._test_create_ikepolicy_all_params(auth='sha256')
def test_create_ikepolicy_invalid_auth(self):
self._test_create_ikepolicy_all_params(auth='xyz',
expected_exc=SystemExit)
def test_create_ikepolicy_with_limited_params(self): def test_create_ikepolicy_with_limited_params(self):
# vpn-ikepolicy-create with limited params. # vpn-ikepolicy-create with limited params.

View File

@@ -25,13 +25,14 @@ class CLITestV20VpnIpsecPolicyJSON(test_cli20.CLITestV20Base):
non_admin_status_resources = ['ipsecpolicy'] non_admin_status_resources = ['ipsecpolicy']
def test_create_ipsecpolicy_all_params(self): def _test_create_ipsecpolicy_all_params(self, auth='sha1',
expected_exc=None):
# vpn-ipsecpolicy-create all params with dashes. # vpn-ipsecpolicy-create all params with dashes.
resource = 'ipsecpolicy' resource = 'ipsecpolicy'
cmd = ipsecpolicy.CreateIPsecPolicy(test_cli20.MyApp(sys.stdout), None) cmd = ipsecpolicy.CreateIPsecPolicy(test_cli20.MyApp(sys.stdout), None)
name = 'ipsecpolicy1' name = 'ipsecpolicy1'
description = 'first-ipsecpolicy1' description = 'first-ipsecpolicy1'
auth_algorithm = 'sha1' auth_algorithm = auth
encryption_algorithm = 'aes-256' encryption_algorithm = 'aes-256'
encapsulation_mode = 'tunnel' encapsulation_mode = 'tunnel'
pfs = 'group5' pfs = 'group5'
@@ -66,9 +67,27 @@ class CLITestV20VpnIpsecPolicyJSON(test_cli20.CLITestV20Base):
}, },
} }
self._test_create_resource(resource, cmd, name, my_id, args, if not expected_exc:
position_names, position_values, self._test_create_resource(resource, cmd, name, my_id, args,
extra_body=extra_body) position_names, position_values,
extra_body=extra_body)
else:
self.assertRaises(
expected_exc,
self._test_create_resource,
resource, cmd, name, my_id, args,
position_names, position_values,
extra_body=extra_body)
def test_create_ipsecpolicy_all_params(self):
self._test_create_ipsecpolicy_all_params()
def test_create_ipsecpolicy_auth_sha256(self):
self._test_create_ipsecpolicy_all_params(auth='sha256')
def test_create_ipsecpolicy_invalid_auth(self):
self._test_create_ipsecpolicy_all_params(auth='xyz',
expected_exc=SystemExit)
def test_create_ipsecpolicy_with_limited_params(self): def test_create_ipsecpolicy_with_limited_params(self):
# vpn-ipsecpolicy-create with limited params. # vpn-ipsecpolicy-create with limited params.