Merge "Add config option enable_webhooks_auth"

This commit is contained in:
Zuul 2020-02-26 13:25:24 +00:00 committed by Gerrit Code Review
commit fa37036304
3 changed files with 45 additions and 4 deletions

View File

@ -27,6 +27,10 @@ server = {
# Pecan Application Configurations
# See https://pecan.readthedocs.org/en/latest/configuration.html#application-configuration # noqa
acl_public_routes = ['/']
if not cfg.CONF.api.get("enable_webhooks_auth"):
acl_public_routes.append('/v1/webhooks/.*')
app = {
'root': 'watcher.api.controllers.root.RootController',
'modules': ['watcher.api'],
@ -36,10 +40,7 @@ app = {
],
'static_root': '%(confdir)s/public',
'enable_acl': True,
'acl_public_routes': [
'/',
'/v1/webhooks/.*',
],
'acl_public_routes': acl_public_routes,
}
# WSME Configurations

View File

@ -55,6 +55,11 @@ API_SERVICE_OPTS = [
"the service, this option should be False; note, you "
"will want to change public API endpoint to represent "
"SSL termination URL with 'public_endpoint' option."),
cfg.BoolOpt('enable_webhooks_auth',
default=True,
help='This option enables or disables webhook request '
'authentication via keystone. Default value is True.'),
]

View File

@ -0,0 +1,35 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# 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 imp
from oslo_config import cfg
from watcher.api import config as api_config
from watcher.tests.api import base
class TestRoot(base.FunctionalTest):
def test_config_enable_webhooks_auth(self):
acl_public_routes = ['/']
cfg.CONF.set_override('enable_webhooks_auth', True, 'api')
imp.reload(api_config)
self.assertEqual(acl_public_routes,
api_config.app['acl_public_routes'])
def test_config_disable_webhooks_auth(self):
acl_public_routes = ['/', '/v1/webhooks/.*']
cfg.CONF.set_override('enable_webhooks_auth', False, 'api')
imp.reload(api_config)
self.assertEqual(acl_public_routes,
api_config.app['acl_public_routes'])