Skip to content

Commit 7e067c6

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Allow --insecure to override --os-cacert"
2 parents 0c5f12a + 31d785e commit 7e067c6

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

openstackclient/shell.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,21 @@ def initialize_app(self, argv):
264264
self.log.debug("cloud cfg: %s", self.cloud.config)
265265

266266
# Set up client TLS
267-
cacert = self.cloud.cacert
268-
if cacert:
269-
self.verify = cacert
270-
else:
271-
self.verify = not self.cloud.config.get('insecure', False)
272-
self.verify = self.cloud.config.get('verify', self.verify)
267+
# NOTE(dtroyer): --insecure is the non-default condition that
268+
# overrides any verify setting in clouds.yaml
269+
# so check it first, then fall back to any verify
270+
# setting provided.
271+
self.verify = not self.cloud.config.get(
272+
'insecure',
273+
not self.cloud.config.get('verify', True),
274+
)
275+
276+
# NOTE(dtroyer): Per bug https://bugs.launchpad.net/bugs/1447784
277+
# --insecure now overrides any --os-cacert setting,
278+
# where before --insecure was ignored if --os-cacert
279+
# was set.
280+
if self.verify and self.cloud.cacert:
281+
self.verify = self.cloud.cacert
273282

274283
# Save default domain
275284
self.default_domain = self.options.default_domain

openstackclient/tests/test_shell.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,15 @@ def test_shell_args_ca_options(self):
540540
self.assertTrue(_shell.verify)
541541

542542
# --os-cacert and --insecure
543-
# NOTE(dtroyer): This really is a bogus combination, the default is
544-
# to follow the requests.Session convention and let
545-
# --os-cacert override --insecure
543+
# NOTE(dtroyer): Per bug https://bugs.launchpad.net/bugs/1447784
544+
# in this combination --insecure now overrides any
545+
# --os-cacert setting, where before --insecure
546+
# was ignored if --os-cacert was set.
546547
fake_execute(_shell, "--os-cacert foo --insecure list user")
547548
self.assertIsNone(_shell.options.verify)
548549
self.assertTrue(_shell.options.insecure)
549550
self.assertEqual('foo', _shell.options.cacert)
550-
self.assertTrue(_shell.verify)
551+
self.assertFalse(_shell.verify)
551552

552553
def test_default_env(self):
553554
flag = ""

0 commit comments

Comments
 (0)