Merge "Add config option enable_webhooks_auth"
This commit is contained in:
@@ -27,6 +27,10 @@ server = {
|
|||||||
|
|
||||||
# Pecan Application Configurations
|
# Pecan Application Configurations
|
||||||
# See https://pecan.readthedocs.org/en/latest/configuration.html#application-configuration # noqa
|
# 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 = {
|
app = {
|
||||||
'root': 'watcher.api.controllers.root.RootController',
|
'root': 'watcher.api.controllers.root.RootController',
|
||||||
'modules': ['watcher.api'],
|
'modules': ['watcher.api'],
|
||||||
@@ -36,10 +40,7 @@ app = {
|
|||||||
],
|
],
|
||||||
'static_root': '%(confdir)s/public',
|
'static_root': '%(confdir)s/public',
|
||||||
'enable_acl': True,
|
'enable_acl': True,
|
||||||
'acl_public_routes': [
|
'acl_public_routes': acl_public_routes,
|
||||||
'/',
|
|
||||||
'/v1/webhooks/.*',
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# WSME Configurations
|
# WSME Configurations
|
||||||
|
|||||||
@@ -55,6 +55,11 @@ API_SERVICE_OPTS = [
|
|||||||
"the service, this option should be False; note, you "
|
"the service, this option should be False; note, you "
|
||||||
"will want to change public API endpoint to represent "
|
"will want to change public API endpoint to represent "
|
||||||
"SSL termination URL with 'public_endpoint' option."),
|
"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.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
35
watcher/tests/api/test_config.py
Normal file
35
watcher/tests/api/test_config.py
Normal 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'])
|
||||||
Reference in New Issue
Block a user