Set default value for HSTS options to None

The default value of these options was False, it means that
octaviaclient sends {'attr': False} to the Octavia API even if it is not
required.

Setting the default value to None, the attribute will not be send when
it is not needed.
It also fixes a potential issue when using recent python-octaviaclient
release with an old octavia release that doesn't support HSTS.

Closes-Bug: #2037253

Change-Id: Ica89bbd257216ef423afc44e0c81498037aece20
This commit is contained in:
Gregory Thiemonge 2023-09-22 10:55:10 -04:00
parent 7ce63497a9
commit db6b62ebdd
3 changed files with 13 additions and 0 deletions

View File

@ -215,6 +215,7 @@ class CreateListener(command.ShowOne):
'--hsts-include-subdomains',
action='store_true',
dest='hsts_include_subdomains',
default=None,
help="Define whether the includeSubDomains directive should be "
"added to the Strict-Transport-Security HTTP response "
"header."
@ -223,6 +224,7 @@ class CreateListener(command.ShowOne):
'--hsts-preload',
action='store_true',
dest='hsts_preload',
default=None,
help="Define whether the preload directive should be "
"added to the Strict-Transport-Security HTTP response "
"header."

View File

@ -195,6 +195,9 @@ class TestListenerCreate(TestListener):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertIsNone(parsed_args.hsts_include_subdomains)
self.assertIsNone(parsed_args.hsts_preload)
self.assertIsNone(parsed_args.hsts_max_age)
self.cmd.take_action(parsed_args)
self.api_mock.listener_create.assert_called_with(
json={'listener': self.listener_info})

View File

@ -0,0 +1,8 @@
---
fixes:
- |
Removed unneeded attributes that could have been passed to the API when
calling "listener create", hsts_include_subdomains and hsts_preload were
passed even when not used.
It fixes an issue when using a recent python-octaviaclient release with
older Octavia releases (without this HSTS feature).