Merge "Allow operators to disable v1 or v2.0 api endpoints"
This commit is contained in:
commit
e41740c61f
etc
octavia
releasenotes/notes
@ -1,35 +1,41 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
# Print debugging output (set logging level to DEBUG instead of default WARNING level).
|
# Print debugging output (set logging level to DEBUG instead of default WARNING level).
|
||||||
# debug = False
|
# debug = False
|
||||||
# bind_host = 127.0.0.1
|
|
||||||
# bind_port = 9876
|
|
||||||
# api_handler = queue_producer
|
|
||||||
#
|
|
||||||
# How should authentication be handled (keystone, noauth)
|
|
||||||
# auth_strategy = keystone
|
|
||||||
#
|
|
||||||
# Plugin options are hot_plug_plugin (Hot-pluggable controller plugin)
|
# Plugin options are hot_plug_plugin (Hot-pluggable controller plugin)
|
||||||
#
|
|
||||||
# octavia_plugins = hot_plug_plugin
|
# octavia_plugins = hot_plug_plugin
|
||||||
|
|
||||||
# Hostname to be used by the host machine for services running on it.
|
# Hostname to be used by the host machine for services running on it.
|
||||||
# The default value is the hostname of the host machine.
|
# The default value is the hostname of the host machine.
|
||||||
# host =
|
# host =
|
||||||
|
|
||||||
|
# AMQP Transport URL
|
||||||
|
# For Single Host, specify one full transport URL:
|
||||||
|
# transport_url = rabbit://<user>:<pass>@127.0.0.1:5672/<vhost>
|
||||||
|
# For HA, specify queue nodes in cluster, comma delimited:
|
||||||
|
# transport_url = rabbit://<user>:<pass>@server01,<user>:<pass>@server02/<vhost>
|
||||||
|
# transport_url =
|
||||||
|
|
||||||
|
[api_settings]
|
||||||
|
# bind_host = 127.0.0.1
|
||||||
|
# bind_port = 9876
|
||||||
|
# api_handler = queue_producer
|
||||||
|
|
||||||
|
# How should authentication be handled (keystone, noauth)
|
||||||
|
# auth_strategy = keystone
|
||||||
|
|
||||||
|
# allow_pagination = True
|
||||||
|
# allow_sorting = True
|
||||||
|
# pagination_max_limit = 1000
|
||||||
# Base URI for the API for use in pagination links.
|
# Base URI for the API for use in pagination links.
|
||||||
# This will be autodetected from the request if not overridden here.
|
# This will be autodetected from the request if not overridden here.
|
||||||
# Example:
|
# Example:
|
||||||
# api_base_uri = http://localhost:9876
|
# api_base_uri = http://localhost:9876
|
||||||
# api_base_uri =
|
# api_base_uri =
|
||||||
|
|
||||||
# AMQP Transport URL
|
# Enable/disable exposing API endpoints. By default, both v1 and v2 are enabled.
|
||||||
# For Single Host, specify one full transport URL:
|
# api_v1_enabled = True
|
||||||
# transport_url = rabbit://<user>:<pass>@127.0.0.1:5672/<vhost>
|
# api_v2_enabled = True
|
||||||
# For HA, specify queue nodes in cluster, comma delimited:
|
|
||||||
# transport_url = rabbit://<user>:<pass>@server01,<user>:<pass>@server02/<vhost>
|
|
||||||
|
|
||||||
# transport_url =
|
|
||||||
|
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
# This line MUST be changed to actually run the plugin.
|
# This line MUST be changed to actually run the plugin.
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
from keystonemiddleware import auth_token
|
from keystonemiddleware import auth_token
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
from oslo_middleware import cors
|
from oslo_middleware import cors
|
||||||
from oslo_middleware import request_id
|
from oslo_middleware import request_id
|
||||||
import pecan
|
import pecan
|
||||||
@ -22,6 +23,8 @@ from octavia.api import config as app_config
|
|||||||
from octavia.common import constants
|
from octavia.common import constants
|
||||||
from octavia.common import service as octavia_service
|
from octavia.common import service as octavia_service
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_pecan_config():
|
def get_pecan_config():
|
||||||
"""Returns the pecan config."""
|
"""Returns the pecan config."""
|
||||||
@ -32,6 +35,7 @@ def get_pecan_config():
|
|||||||
def setup_app(pecan_config=None, debug=False, argv=None):
|
def setup_app(pecan_config=None, debug=False, argv=None):
|
||||||
"""Creates and returns a pecan wsgi app."""
|
"""Creates and returns a pecan wsgi app."""
|
||||||
octavia_service.prepare_service(argv)
|
octavia_service.prepare_service(argv)
|
||||||
|
cfg.CONF.log_opt_values(LOG, logging.DEBUG)
|
||||||
|
|
||||||
if not pecan_config:
|
if not pecan_config:
|
||||||
pecan_config = get_pecan_config()
|
pecan_config = get_pecan_config()
|
||||||
@ -49,7 +53,7 @@ def setup_app(pecan_config=None, debug=False, argv=None):
|
|||||||
def _wrap_app(app):
|
def _wrap_app(app):
|
||||||
"""Wraps wsgi app with additional middlewares."""
|
"""Wraps wsgi app with additional middlewares."""
|
||||||
app = request_id.RequestId(app)
|
app = request_id.RequestId(app)
|
||||||
if cfg.CONF.auth_strategy == constants.KEYSTONE:
|
if cfg.CONF.api_settings.auth_strategy == constants.KEYSTONE:
|
||||||
app = auth_token.AuthProtocol(app, {})
|
app = auth_token.AuthProtocol(app, {})
|
||||||
|
|
||||||
# This should be the last middleware in the list (which results in
|
# This should be the last middleware in the list (which results in
|
||||||
|
@ -53,10 +53,10 @@ class PaginationHelper(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_limit(params):
|
def _parse_limit(params):
|
||||||
if CONF.pagination_max_limit == 'infinite':
|
if CONF.api_settings.pagination_max_limit == 'infinite':
|
||||||
page_max_limit = None
|
page_max_limit = None
|
||||||
else:
|
else:
|
||||||
page_max_limit = int(CONF.pagination_max_limit)
|
page_max_limit = int(CONF.api_settings.pagination_max_limit)
|
||||||
limit = params.get('limit', page_max_limit)
|
limit = params.get('limit', page_max_limit)
|
||||||
try:
|
try:
|
||||||
# Deal with limit being a string or int meaning 'Unlimited'
|
# Deal with limit being a string or int meaning 'Unlimited'
|
||||||
@ -132,9 +132,10 @@ class PaginationHelper(object):
|
|||||||
return sort_dir
|
return sort_dir
|
||||||
|
|
||||||
def _make_links(self, model_list):
|
def _make_links(self, model_list):
|
||||||
if CONF.api_base_uri:
|
if CONF.api_settings.api_base_uri:
|
||||||
path_url = "{api_base_url}{path}".format(
|
path_url = "{api_base_url}{path}".format(
|
||||||
api_base_url=CONF.api_base_uri.rstrip('/'), path=request.path)
|
api_base_url=CONF.api_settings.api_base_uri.rstrip('/'),
|
||||||
|
path=request.path)
|
||||||
else:
|
else:
|
||||||
path_url = request.path_url
|
path_url = request.path_url
|
||||||
links = []
|
links = []
|
||||||
@ -194,7 +195,7 @@ class PaginationHelper(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# Add filtering
|
# Add filtering
|
||||||
if CONF.allow_filtering:
|
if CONF.api_settings.allow_filtering:
|
||||||
filter_attrs = [attr for attr in dir(
|
filter_attrs = [attr for attr in dir(
|
||||||
model.__v2_wsme__
|
model.__v2_wsme__
|
||||||
) if not callable(
|
) if not callable(
|
||||||
@ -206,7 +207,7 @@ class PaginationHelper(object):
|
|||||||
query = model.apply_filter(query, model, self.filters)
|
query = model.apply_filter(query, model, self.filters)
|
||||||
|
|
||||||
# Add sorting
|
# Add sorting
|
||||||
if CONF.allow_sorting:
|
if CONF.api_settings.allow_sorting:
|
||||||
# Add default sort keys (if they are OK for the model)
|
# Add default sort keys (if they are OK for the model)
|
||||||
keys_only = [k[0] for k in self.sort_keys]
|
keys_only = [k[0] for k in self.sort_keys]
|
||||||
for key in constants.DEFAULT_SORT_KEYS:
|
for key in constants.DEFAULT_SORT_KEYS:
|
||||||
@ -226,7 +227,7 @@ class PaginationHelper(object):
|
|||||||
query = query.order_by(sort_dir_func(sort_key_attr))
|
query = query.order_by(sort_dir_func(sort_key_attr))
|
||||||
|
|
||||||
# Add pagination
|
# Add pagination
|
||||||
if CONF.allow_pagination:
|
if CONF.api_settings.allow_pagination:
|
||||||
default = '' # Default to an empty string if NULL
|
default = '' # Default to an empty string if NULL
|
||||||
if self.marker is not None:
|
if self.marker is not None:
|
||||||
marker_object = self._parse_marker(query.session, model)
|
marker_object = self._parse_marker(query.session, model)
|
||||||
@ -279,7 +280,7 @@ class PaginationHelper(object):
|
|||||||
model_list = query.all()
|
model_list = query.all()
|
||||||
|
|
||||||
links = None
|
links = None
|
||||||
if CONF.allow_pagination:
|
if CONF.api_settings.allow_pagination:
|
||||||
links = self._make_links(model_list)
|
links = self._make_links(model_list)
|
||||||
|
|
||||||
return model_list, links
|
return model_list, links
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
from pecan import rest
|
from pecan import rest
|
||||||
from wsme import types as wtypes
|
from wsme import types as wtypes
|
||||||
from wsmeext import pecan as wsme_pecan
|
from wsmeext import pecan as wsme_pecan
|
||||||
@ -20,23 +23,43 @@ from octavia.api.v1 import controllers as v1_controller
|
|||||||
from octavia.api.v2 import controllers as v2_controller
|
from octavia.api.v2 import controllers as v2_controller
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RootController(rest.RestController):
|
class RootController(rest.RestController):
|
||||||
"""The controller with which the pecan wsgi app should be created."""
|
"""The controller with which the pecan wsgi app should be created."""
|
||||||
v1 = None
|
_versions = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(RootController, self).__init__()
|
super(RootController, self).__init__()
|
||||||
self.v1 = v1_controller.V1Controller()
|
self._versions = []
|
||||||
setattr(self, 'v2.0', v2_controller.V2Controller())
|
v1_enabled = CONF.api_settings.api_v1_enabled
|
||||||
|
v2_enabled = CONF.api_settings.api_v2_enabled
|
||||||
|
if v1_enabled:
|
||||||
|
self.v1 = v1_controller.V1Controller()
|
||||||
|
self._versions.append(
|
||||||
|
{
|
||||||
|
'status': 'CURRENT',
|
||||||
|
'updated': '2014-12-11T00:00:00Z',
|
||||||
|
'id': 'v1'
|
||||||
|
})
|
||||||
|
if v2_enabled:
|
||||||
|
setattr(self, 'v2.0', v2_controller.V2Controller())
|
||||||
|
self._versions.append(
|
||||||
|
{
|
||||||
|
'status': 'CURRENT',
|
||||||
|
'updated': '2017-06-22T00:00:00Z',
|
||||||
|
'id': 'v2.0'
|
||||||
|
})
|
||||||
|
if not (v1_enabled or v2_enabled):
|
||||||
|
LOG.warning("Both v1 and v2.0 API endpoints are disabled -- is "
|
||||||
|
"this intentional?")
|
||||||
|
elif v1_enabled and v2_enabled:
|
||||||
|
LOG.warning("Both v1 and v2.0 API endpoints are enabled -- it is "
|
||||||
|
"a security risk to expose the v1 endpoint publicly,"
|
||||||
|
"so please make sure access to it is secured.")
|
||||||
|
|
||||||
@wsme_pecan.wsexpose(wtypes.text)
|
@wsme_pecan.wsexpose(wtypes.text)
|
||||||
def get(self):
|
def get(self):
|
||||||
# TODO(blogan): once a decision is made on how to do versions, do that
|
return {'versions': self._versions}
|
||||||
# here
|
|
||||||
return {'versions': [{'status': 'CURRENT',
|
|
||||||
'updated': '2014-12-11T00:00:00Z',
|
|
||||||
'id': 'v1'},
|
|
||||||
{'status': 'EXPERIMENTAL',
|
|
||||||
'updated': '2016-12-11T00:00:00Z',
|
|
||||||
'id': 'v2.0'}
|
|
||||||
]}
|
|
||||||
|
@ -33,7 +33,7 @@ class BaseController(rest.RestController):
|
|||||||
self.repositories = repositories.Repositories()
|
self.repositories = repositories.Repositories()
|
||||||
self.handler = stevedore_driver.DriverManager(
|
self.handler = stevedore_driver.DriverManager(
|
||||||
namespace='octavia.api.handlers',
|
namespace='octavia.api.handlers',
|
||||||
name=CONF.api_handler,
|
name=CONF.api_settings.api_handler,
|
||||||
invoke_on_load=True
|
invoke_on_load=True
|
||||||
).driver
|
).driver
|
||||||
|
|
||||||
|
@ -135,7 +135,8 @@ class LoadBalancersController(base.BaseController):
|
|||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
|
|
||||||
project_id = context.project_id
|
project_id = context.project_id
|
||||||
if context.is_admin or CONF.auth_strategy == constants.NOAUTH:
|
if context.is_admin or (CONF.api_settings.auth_strategy ==
|
||||||
|
constants.NOAUTH):
|
||||||
if load_balancer.project_id:
|
if load_balancer.project_id:
|
||||||
project_id = load_balancer.project_id
|
project_id = load_balancer.project_id
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ class QuotasController(base.BaseController):
|
|||||||
context = pecan.request.context.get('octavia_context')
|
context = pecan.request.context.get('octavia_context')
|
||||||
|
|
||||||
new_project_id = context.project_id
|
new_project_id = context.project_id
|
||||||
if context.is_admin or CONF.auth_strategy == constants.NOAUTH:
|
if context.is_admin or (CONF.api_settings.auth_strategy ==
|
||||||
|
constants.NOAUTH):
|
||||||
if project_id:
|
if project_id:
|
||||||
new_project_id = project_id
|
new_project_id = project_id
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class BaseController(rest.RestController):
|
|||||||
self.repositories = repositories.Repositories()
|
self.repositories = repositories.Repositories()
|
||||||
self.handler = stevedore_driver.DriverManager(
|
self.handler = stevedore_driver.DriverManager(
|
||||||
namespace='octavia.api.handlers',
|
namespace='octavia.api.handlers',
|
||||||
name=CONF.api_handler,
|
name=CONF.api_settings.api_handler,
|
||||||
invoke_on_load=True
|
invoke_on_load=True
|
||||||
).driver
|
).driver
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ class BaseController(rest.RestController):
|
|||||||
context.policy.authorize(action, target)
|
context.policy.authorize(action, target)
|
||||||
|
|
||||||
def _filter_fields(self, object_list, fields):
|
def _filter_fields(self, object_list, fields):
|
||||||
if CONF.allow_field_selection:
|
if CONF.api_settings.allow_field_selection:
|
||||||
for index, obj in enumerate(object_list):
|
for index, obj in enumerate(object_list):
|
||||||
members = self._get_attrs(obj)
|
members = self._get_attrs(obj)
|
||||||
for member in members:
|
for member in members:
|
||||||
|
@ -31,7 +31,8 @@ def main():
|
|||||||
|
|
||||||
app = api_app.setup_app(argv=sys.argv)
|
app = api_app.setup_app(argv=sys.argv)
|
||||||
|
|
||||||
host, port = cfg.CONF.bind_host, cfg.CONF.bind_port
|
host = cfg.CONF.api_settings.bind_host
|
||||||
|
port = cfg.CONF.api_settings.bind_port
|
||||||
LOG.info("Starting API server on %(host)s:%(port)s",
|
LOG.info("Starting API server on %(host)s:%(port)s",
|
||||||
{"host": host, "port": port})
|
{"host": host, "port": port})
|
||||||
srv = simple_server.make_server(host, port, app)
|
srv = simple_server.make_server(host, port, app)
|
||||||
|
@ -29,7 +29,40 @@ from octavia import version
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# TODO(rm_work) Remove in or after "R" release
|
||||||
|
API_SETTINGS_DEPRECATION_MESSAGE = _(
|
||||||
|
'This setting has moved to the [api_settings] section.')
|
||||||
|
|
||||||
core_opts = [
|
core_opts = [
|
||||||
|
cfg.HostnameOpt('host', default=utils.get_hostname(),
|
||||||
|
help=_("The hostname Octavia is running on")),
|
||||||
|
cfg.StrOpt('octavia_plugins', default='hot_plug_plugin',
|
||||||
|
help=_("Name of the controller plugin to use")),
|
||||||
|
|
||||||
|
# TODO(johnsom) Remove in or after "R" release
|
||||||
|
cfg.IPOpt('bind_host', help=_("The host IP to bind to"),
|
||||||
|
deprecated_for_removal=True,
|
||||||
|
deprecated_reason=API_SETTINGS_DEPRECATION_MESSAGE),
|
||||||
|
# TODO(johnsom) Remove in or after "R" release
|
||||||
|
cfg.PortOpt('bind_port', help=_("The port to bind to"),
|
||||||
|
deprecated_for_removal=True,
|
||||||
|
deprecated_reason=API_SETTINGS_DEPRECATION_MESSAGE),
|
||||||
|
# TODO(johnsom) Remove in or after "R" release
|
||||||
|
cfg.StrOpt('auth_strategy',
|
||||||
|
choices=[constants.NOAUTH,
|
||||||
|
constants.KEYSTONE,
|
||||||
|
constants.TESTING],
|
||||||
|
help=_("The auth strategy for API requests."),
|
||||||
|
deprecated_for_removal=True,
|
||||||
|
deprecated_reason=API_SETTINGS_DEPRECATION_MESSAGE),
|
||||||
|
# TODO(johnsom) Remove in or after "R" release
|
||||||
|
cfg.StrOpt('api_handler',
|
||||||
|
help=_("The handler that the API communicates with"),
|
||||||
|
deprecated_for_removal=True,
|
||||||
|
deprecated_reason=API_SETTINGS_DEPRECATION_MESSAGE),
|
||||||
|
]
|
||||||
|
|
||||||
|
api_opts = [
|
||||||
cfg.IPOpt('bind_host', default='127.0.0.1',
|
cfg.IPOpt('bind_host', default='127.0.0.1',
|
||||||
help=_("The host IP to bind to")),
|
help=_("The host IP to bind to")),
|
||||||
cfg.PortOpt('bind_port', default=9876,
|
cfg.PortOpt('bind_port', default=9876,
|
||||||
@ -42,9 +75,9 @@ core_opts = [
|
|||||||
cfg.StrOpt('api_handler', default='queue_producer',
|
cfg.StrOpt('api_handler', default='queue_producer',
|
||||||
help=_("The handler that the API communicates with")),
|
help=_("The handler that the API communicates with")),
|
||||||
cfg.BoolOpt('allow_pagination', default=True,
|
cfg.BoolOpt('allow_pagination', default=True,
|
||||||
help=_("Allow the usage of the pagination")),
|
help=_("Allow the usage of pagination")),
|
||||||
cfg.BoolOpt('allow_sorting', default=True,
|
cfg.BoolOpt('allow_sorting', default=True,
|
||||||
help=_("Allow the usage of the sorting")),
|
help=_("Allow the usage of sorting")),
|
||||||
cfg.BoolOpt('allow_filtering', default=True,
|
cfg.BoolOpt('allow_filtering', default=True,
|
||||||
help=_("Allow the usage of filtering")),
|
help=_("Allow the usage of filtering")),
|
||||||
cfg.BoolOpt('allow_field_selection', default=True,
|
cfg.BoolOpt('allow_field_selection', default=True,
|
||||||
@ -54,15 +87,14 @@ core_opts = [
|
|||||||
help=_("The maximum number of items returned in a single "
|
help=_("The maximum number of items returned in a single "
|
||||||
"response. The string 'infinite' or a negative "
|
"response. The string 'infinite' or a negative "
|
||||||
"integer value means 'no limit'")),
|
"integer value means 'no limit'")),
|
||||||
cfg.HostnameOpt('host', default=utils.get_hostname(),
|
|
||||||
help=_("The hostname Octavia is running on")),
|
|
||||||
cfg.StrOpt('api_base_uri',
|
cfg.StrOpt('api_base_uri',
|
||||||
help=_("Base URI for the API for use in pagination links. "
|
help=_("Base URI for the API for use in pagination links. "
|
||||||
"This will be autodetected from the request if not "
|
"This will be autodetected from the request if not "
|
||||||
"overridden here.")),
|
"overridden here.")),
|
||||||
cfg.StrOpt('octavia_plugins',
|
cfg.BoolOpt('api_v1_enabled', default=True,
|
||||||
default='hot_plug_plugin',
|
help=_("Expose the v1 API?")),
|
||||||
help=_('Name of the controller plugin to use'))
|
cfg.BoolOpt('api_v2_enabled', default=True,
|
||||||
|
help=_("Expose the v2 API?")),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Options only used by the amphora agent
|
# Options only used by the amphora agent
|
||||||
@ -488,6 +520,7 @@ quota_opts = [
|
|||||||
|
|
||||||
# Register the configuration options
|
# Register the configuration options
|
||||||
cfg.CONF.register_opts(core_opts)
|
cfg.CONF.register_opts(core_opts)
|
||||||
|
cfg.CONF.register_opts(api_opts, group='api_settings')
|
||||||
cfg.CONF.register_opts(amphora_agent_opts, group='amphora_agent')
|
cfg.CONF.register_opts(amphora_agent_opts, group='amphora_agent')
|
||||||
cfg.CONF.register_opts(networking_opts, group='networking')
|
cfg.CONF.register_opts(networking_opts, group='networking')
|
||||||
cfg.CONF.register_opts(oslo_messaging_opts, group='oslo_messaging')
|
cfg.CONF.register_opts(oslo_messaging_opts, group='oslo_messaging')
|
||||||
@ -524,6 +557,7 @@ def init(args, **kwargs):
|
|||||||
cfg.CONF(args=args, project='octavia',
|
cfg.CONF(args=args, project='octavia',
|
||||||
version='%%prog %s' % version.version_info.release_string(),
|
version='%%prog %s' % version.version_info.release_string(),
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
handle_deprecation_compatibility()
|
||||||
|
|
||||||
|
|
||||||
def setup_logging(conf):
|
def setup_logging(conf):
|
||||||
@ -534,3 +568,26 @@ def setup_logging(conf):
|
|||||||
product_name = "octavia"
|
product_name = "octavia"
|
||||||
logging.setup(conf, product_name)
|
logging.setup(conf, product_name)
|
||||||
LOG.info("Logging enabled!")
|
LOG.info("Logging enabled!")
|
||||||
|
|
||||||
|
|
||||||
|
# Use cfg.CONF.set_default to override the new configuration setting
|
||||||
|
# default value. This allows a value set, at the new location, to override
|
||||||
|
# a value set in the previous location while allowing settings that have
|
||||||
|
# not yet been moved to be utilized.
|
||||||
|
def handle_deprecation_compatibility():
|
||||||
|
# TODO(johnsom) Remove in or after "R" release
|
||||||
|
if cfg.CONF.bind_host is not None:
|
||||||
|
cfg.CONF.set_default('bind_host', cfg.CONF.bind_host,
|
||||||
|
group='api_settings')
|
||||||
|
# TODO(johnsom) Remove in or after "R" release
|
||||||
|
if cfg.CONF.bind_port is not None:
|
||||||
|
cfg.CONF.set_default('bind_port', cfg.CONF.bind_port,
|
||||||
|
group='api_settings')
|
||||||
|
# TODO(johnsom) Remove in or after "R" release
|
||||||
|
if cfg.CONF.auth_strategy is not None:
|
||||||
|
cfg.CONF.set_default('auth_strategy', cfg.CONF.auth_strategy,
|
||||||
|
group='api_settings')
|
||||||
|
# TODO(johnsom) Remove in or after "R" release
|
||||||
|
if cfg.CONF.api_handler is not None:
|
||||||
|
cfg.CONF.set_default('api_handler', cfg.CONF.api_handler,
|
||||||
|
group='api_settings')
|
||||||
|
@ -36,7 +36,7 @@ class Context(common_context.RequestContext):
|
|||||||
self.policy = policy.Policy(self)
|
self.policy = policy.Policy(self)
|
||||||
|
|
||||||
self.is_admin = (self.policy.check_is_admin() or
|
self.is_admin = (self.policy.check_is_admin() or
|
||||||
CONF.auth_strategy == constants.NOAUTH)
|
CONF.api_settings.auth_strategy == constants.NOAUTH)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def session(self):
|
def session(self):
|
||||||
|
@ -291,7 +291,7 @@ class Repositories(object):
|
|||||||
{'proj': project_id, 'obj': _class})
|
{'proj': project_id, 'obj': _class})
|
||||||
|
|
||||||
# Under noauth everything is admin, so no quota
|
# Under noauth everything is admin, so no quota
|
||||||
if CONF.auth_strategy == consts.NOAUTH:
|
if CONF.api_settings.auth_strategy == consts.NOAUTH:
|
||||||
LOG.debug('Auth strategy is NOAUTH, skipping quota check.')
|
LOG.debug('Auth strategy is NOAUTH, skipping quota check.')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ class Repositories(object):
|
|||||||
quotas = lock_session.query(models.Quotas).filter_by(
|
quotas = lock_session.query(models.Quotas).filter_by(
|
||||||
project_id=project_id).with_for_update().first()
|
project_id=project_id).with_for_update().first()
|
||||||
if not quotas:
|
if not quotas:
|
||||||
if not CONF.auth_strategy == consts.NOAUTH:
|
if not CONF.api_settings.auth_strategy == consts.NOAUTH:
|
||||||
LOG.error('Quota decrement on %(clss)s called on '
|
LOG.error('Quota decrement on %(clss)s called on '
|
||||||
'project: %(proj)s with no quota record in '
|
'project: %(proj)s with no quota record in '
|
||||||
'the database.',
|
'the database.',
|
||||||
@ -457,7 +457,7 @@ class Repositories(object):
|
|||||||
quotas.in_use_load_balancer = (
|
quotas.in_use_load_balancer = (
|
||||||
quotas.in_use_load_balancer - quantity)
|
quotas.in_use_load_balancer - quantity)
|
||||||
else:
|
else:
|
||||||
if not CONF.auth_strategy == consts.NOAUTH:
|
if not CONF.api_settings.auth_strategy == consts.NOAUTH:
|
||||||
LOG.warning('Quota decrement on %(clss)s called on '
|
LOG.warning('Quota decrement on %(clss)s called on '
|
||||||
'project: %(proj)s that would cause a '
|
'project: %(proj)s that would cause a '
|
||||||
'negative quota.',
|
'negative quota.',
|
||||||
@ -468,7 +468,7 @@ class Repositories(object):
|
|||||||
quotas.in_use_listener = (
|
quotas.in_use_listener = (
|
||||||
quotas.in_use_listener - quantity)
|
quotas.in_use_listener - quantity)
|
||||||
else:
|
else:
|
||||||
if not CONF.auth_strategy == consts.NOAUTH:
|
if not CONF.api_settings.auth_strategy == consts.NOAUTH:
|
||||||
LOG.warning('Quota decrement on %(clss)s called on '
|
LOG.warning('Quota decrement on %(clss)s called on '
|
||||||
'project: %(proj)s that would cause a '
|
'project: %(proj)s that would cause a '
|
||||||
'negative quota.',
|
'negative quota.',
|
||||||
@ -479,7 +479,7 @@ class Repositories(object):
|
|||||||
quotas.in_use_pool = (
|
quotas.in_use_pool = (
|
||||||
quotas.in_use_pool - quantity)
|
quotas.in_use_pool - quantity)
|
||||||
else:
|
else:
|
||||||
if not CONF.auth_strategy == consts.NOAUTH:
|
if not CONF.api_settings.auth_strategy == consts.NOAUTH:
|
||||||
LOG.warning('Quota decrement on %(clss)s called on '
|
LOG.warning('Quota decrement on %(clss)s called on '
|
||||||
'project: %(proj)s that would cause a '
|
'project: %(proj)s that would cause a '
|
||||||
'negative quota.',
|
'negative quota.',
|
||||||
@ -490,7 +490,7 @@ class Repositories(object):
|
|||||||
quotas.in_use_health_monitor = (
|
quotas.in_use_health_monitor = (
|
||||||
quotas.in_use_health_monitor - quantity)
|
quotas.in_use_health_monitor - quantity)
|
||||||
else:
|
else:
|
||||||
if not CONF.auth_strategy == consts.NOAUTH:
|
if not CONF.api_settings.auth_strategy == consts.NOAUTH:
|
||||||
LOG.warning('Quota decrement on %(clss)s called on '
|
LOG.warning('Quota decrement on %(clss)s called on '
|
||||||
'project: %(proj)s that would cause a '
|
'project: %(proj)s that would cause a '
|
||||||
'negative quota.',
|
'negative quota.',
|
||||||
@ -501,7 +501,7 @@ class Repositories(object):
|
|||||||
quotas.in_use_member = (
|
quotas.in_use_member = (
|
||||||
quotas.in_use_member - quantity)
|
quotas.in_use_member - quantity)
|
||||||
else:
|
else:
|
||||||
if not CONF.auth_strategy == consts.NOAUTH:
|
if not CONF.api_settings.auth_strategy == consts.NOAUTH:
|
||||||
LOG.warning('Quota decrement on %(clss)s called on '
|
LOG.warning('Quota decrement on %(clss)s called on '
|
||||||
'project: %(proj)s that would cause a '
|
'project: %(proj)s that would cause a '
|
||||||
'negative quota.',
|
'negative quota.',
|
||||||
|
68
octavia/tests/functional/api/test_root_controller.py
Normal file
68
octavia/tests/functional/api/test_root_controller.py
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
# Copyright 2017 GoDaddy
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_config import fixture as oslo_fixture
|
||||||
|
import pecan.testing
|
||||||
|
|
||||||
|
from octavia.api import config as pconfig
|
||||||
|
from octavia.common import constants
|
||||||
|
from octavia.tests.functional.db import base as base_db_test
|
||||||
|
|
||||||
|
|
||||||
|
class TestRootController(base_db_test.OctaviaDBTestBase):
|
||||||
|
|
||||||
|
def get(self, app, path, params=None, headers=None, status=200,
|
||||||
|
expect_errors=False):
|
||||||
|
response = app.get(
|
||||||
|
path, params=params, headers=headers, status=status,
|
||||||
|
expect_errors=expect_errors)
|
||||||
|
return response
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestRootController, self).setUp()
|
||||||
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
|
self.conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
|
|
||||||
|
def _get_versions_with_config(self, api_v1_enabled, api_v2_enabled):
|
||||||
|
self.conf.config(group='api_settings', api_v1_enabled=api_v1_enabled)
|
||||||
|
self.conf.config(group='api_settings', api_v2_enabled=api_v2_enabled)
|
||||||
|
app = pecan.testing.load_test_app({'app': pconfig.app,
|
||||||
|
'wsme': pconfig.wsme})
|
||||||
|
return self.get(app=app, path='/').json.get('versions', None)
|
||||||
|
|
||||||
|
def test_api_versions(self):
|
||||||
|
versions = self._get_versions_with_config(
|
||||||
|
api_v1_enabled=True, api_v2_enabled=True)
|
||||||
|
version_ids = tuple(v.get('id') for v in versions)
|
||||||
|
self.assertEqual(2, len(version_ids))
|
||||||
|
self.assertIn('v1', version_ids)
|
||||||
|
self.assertIn('v2.0', version_ids)
|
||||||
|
|
||||||
|
def test_api_v1_disabled(self):
|
||||||
|
versions = self._get_versions_with_config(
|
||||||
|
api_v1_enabled=False, api_v2_enabled=True)
|
||||||
|
self.assertEqual(1, len(versions))
|
||||||
|
self.assertEqual('v2.0', versions[0].get('id'))
|
||||||
|
|
||||||
|
def test_api_v2_disabled(self):
|
||||||
|
versions = self._get_versions_with_config(
|
||||||
|
api_v1_enabled=True, api_v2_enabled=False)
|
||||||
|
self.assertEqual(1, len(versions))
|
||||||
|
self.assertEqual('v1', versions[0].get('id'))
|
||||||
|
|
||||||
|
def test_api_both_disabled(self):
|
||||||
|
versions = self._get_versions_with_config(
|
||||||
|
api_v1_enabled=False, api_v2_enabled=False)
|
||||||
|
self.assertEqual(0, len(versions))
|
@ -59,10 +59,10 @@ class BaseAPITest(base_db_test.OctaviaDBTestBase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseAPITest, self).setUp()
|
super(BaseAPITest, self).setUp()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(api_handler='simulated_handler')
|
conf.config(group='api_settings', api_handler='simulated_handler')
|
||||||
conf.config(group="controller_worker",
|
conf.config(group="controller_worker",
|
||||||
network_driver='network_noop_driver')
|
network_driver='network_noop_driver')
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
self.lb_repo = repositories.LoadBalancerRepository()
|
self.lb_repo = repositories.LoadBalancerRepository()
|
||||||
self.listener_repo = repositories.ListenerRepository()
|
self.listener_repo = repositories.ListenerRepository()
|
||||||
self.listener_stats_repo = repositories.ListenerStatisticsRepository()
|
self.listener_stats_repo = repositories.ListenerStatisticsRepository()
|
||||||
|
@ -69,10 +69,10 @@ class BaseAPITest(base_db_test.OctaviaDBTestBase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseAPITest, self).setUp()
|
super(BaseAPITest, self).setUp()
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
self.conf.config(api_handler='simulated_handler')
|
self.conf.config(group='api_settings', api_handler='simulated_handler')
|
||||||
self.conf.config(group="controller_worker",
|
self.conf.config(group="controller_worker",
|
||||||
network_driver='network_noop_driver')
|
network_driver='network_noop_driver')
|
||||||
self.conf.config(auth_strategy=constants.NOAUTH)
|
self.conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
self.lb_repo = repositories.LoadBalancerRepository()
|
self.lb_repo = repositories.LoadBalancerRepository()
|
||||||
self.listener_repo = repositories.ListenerRepository()
|
self.listener_repo = repositories.ListenerRepository()
|
||||||
self.listener_stats_repo = repositories.ListenerStatisticsRepository()
|
self.listener_stats_repo = repositories.ListenerStatisticsRepository()
|
||||||
|
@ -78,8 +78,8 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -101,7 +101,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
|
|
||||||
response = self.get(self.HM_PATH.format(
|
response = self.get(self.HM_PATH.format(
|
||||||
healthmonitor_id=api_hm.get('id'))).json.get(self.root_tag)
|
healthmonitor_id=api_hm.get('id'))).json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
response.pop('updated_at')
|
response.pop('updated_at')
|
||||||
self.assertEqual(api_hm, response)
|
self.assertEqual(api_hm, response)
|
||||||
@ -117,13 +117,13 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.HM_PATH.format(
|
response = self.get(self.HM_PATH.format(
|
||||||
healthmonitor_id=api_hm.get('id')), status=401)
|
healthmonitor_id=api_hm.get('id')), status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_get_hides_deleted(self):
|
def test_get_hides_deleted(self):
|
||||||
@ -160,13 +160,13 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
1, 1, 1, 1).get(self.root_tag)
|
1, 1, 1, 1).get(self.root_tag)
|
||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
hms = self.get(self.HMS_PATH, status=401).json
|
hms = self.get(self.HMS_PATH, status=401).json
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, hms)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, hms)
|
||||||
|
|
||||||
def test_get_all_admin(self):
|
def test_get_all_admin(self):
|
||||||
@ -233,8 +233,9 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
1, 1, 1, 1).get(self.root_tag)
|
1, 1, 1, 1).get(self.root_tag)
|
||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
hm3['project_id']):
|
hm3['project_id']):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -254,7 +255,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
hms = self.get(self.HMS_PATH).json.get(self.root_tag_list)
|
hms = self.get(self.HMS_PATH).json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(1, len(hms))
|
self.assertEqual(1, len(hms))
|
||||||
hm_id_protocols = [(hm.get('id'), hm.get('type')) for hm in hms]
|
hm_id_protocols = [(hm.get('id'), hm.get('type')) for hm in hms]
|
||||||
@ -291,8 +292,9 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
1, 1, 1, 1).get(self.root_tag)
|
1, 1, 1, 1).get(self.root_tag)
|
||||||
self.set_lb_status(lb1_id)
|
self.set_lb_status(lb1_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
hm3['project_id']):
|
hm3['project_id']):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -314,7 +316,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
|
|
||||||
hms = self.get(self.HMS_PATH).json.get(self.root_tag_list)
|
hms = self.get(self.HMS_PATH).json.get(self.root_tag_list)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(3, len(hms))
|
self.assertEqual(3, len(hms))
|
||||||
hm_id_protocols = [(hm.get('id'), hm.get('type')) for hm in hms]
|
hm_id_protocols = [(hm.get('id'), hm.get('type')) for hm in hms]
|
||||||
self.assertIn((hm1.get('id'), hm1.get('type')), hm_id_protocols)
|
self.assertIn((hm1.get('id'), hm1.get('type')), hm_id_protocols)
|
||||||
@ -595,8 +597,8 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_authorized(self):
|
def test_create_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
@ -621,7 +623,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.pool_id, constants.HEALTH_MONITOR_HTTP,
|
self.pool_id, constants.HEALTH_MONITOR_HTTP,
|
||||||
1, 1, 1, 1).get(self.root_tag)
|
1, 1, 1, 1).get(self.root_tag)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
pool_id=self.pool_id, hm_id=api_hm.get('id'),
|
pool_id=self.pool_id, hm_id=api_hm.get('id'),
|
||||||
@ -643,8 +645,8 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_not_authorized(self):
|
def test_create_not_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
@ -652,7 +654,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.pool_id, constants.HEALTH_MONITOR_HTTP,
|
self.pool_id, constants.HEALTH_MONITOR_HTTP,
|
||||||
1, 1, 1, 1, status=401)
|
1, 1, 1, 1, status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_hm)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_hm)
|
||||||
|
|
||||||
def test_create_with_listener(self):
|
def test_create_with_listener(self):
|
||||||
@ -765,8 +767,8 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
new_hm = {'max_retries': 2}
|
new_hm = {'max_retries': 2}
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -790,7 +792,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
||||||
self._build_body(new_hm))
|
self._build_body(new_hm))
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
pool_id=self.pool_with_listener_id, hm_id=api_hm.get('id'),
|
pool_id=self.pool_with_listener_id, hm_id=api_hm.get('id'),
|
||||||
@ -806,15 +808,15 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
new_hm = {'max_retries': 2}
|
new_hm = {'max_retries': 2}
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.put(
|
response = self.put(
|
||||||
self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
||||||
self._build_body(new_hm), status=401)
|
self._build_body(new_hm), status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -884,8 +886,8 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.assertEqual(api_hm, hm)
|
self.assertEqual(api_hm, hm)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -906,7 +908,7 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
self.delete(
|
self.delete(
|
||||||
self.HM_PATH.format(healthmonitor_id=api_hm.get('id')))
|
self.HM_PATH.format(healthmonitor_id=api_hm.get('id')))
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
pool_id=self.pool_with_listener_id, hm_id=api_hm.get('id'),
|
pool_id=self.pool_with_listener_id, hm_id=api_hm.get('id'),
|
||||||
@ -929,14 +931,14 @@ class TestHealthMonitor(base.BaseAPITest):
|
|||||||
self.assertEqual(api_hm, hm)
|
self.assertEqual(api_hm, hm)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
self.delete(
|
self.delete(
|
||||||
self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
self.HM_PATH.format(healthmonitor_id=api_hm.get('id')),
|
||||||
status=401)
|
status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
pool_id=self.pool_with_listener_id, hm_id=api_hm.get('id'),
|
pool_id=self.pool_with_listener_id, hm_id=api_hm.get('id'),
|
||||||
|
@ -61,8 +61,8 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
constants.L7POLICY_ACTION_REJECT).get(self.root_tag)
|
constants.L7POLICY_ACTION_REJECT).get(self.root_tag)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -84,7 +84,7 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
response = self.get(self.L7POLICY_PATH.format(
|
response = self.get(self.L7POLICY_PATH.format(
|
||||||
l7policy_id=api_l7policy.get('id')))
|
l7policy_id=api_l7policy.get('id')))
|
||||||
response = response.json.get(self.root_tag)
|
response = response.json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(api_l7policy, response)
|
self.assertEqual(api_l7policy, response)
|
||||||
|
|
||||||
def test_get_not_authorized(self):
|
def test_get_not_authorized(self):
|
||||||
@ -93,13 +93,13 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
constants.L7POLICY_ACTION_REJECT).get(self.root_tag)
|
constants.L7POLICY_ACTION_REJECT).get(self.root_tag)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.L7POLICY_PATH.format(
|
response = self.get(self.L7POLICY_PATH.format(
|
||||||
l7policy_id=api_l7policy.get('id')), status=401)
|
l7policy_id=api_l7policy.get('id')), status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_get_hides_deleted(self):
|
def test_get_hides_deleted(self):
|
||||||
@ -193,8 +193,9 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
redirect_url='http://localhost/').get(self.root_tag)
|
redirect_url='http://localhost/').get(self.root_tag)
|
||||||
self.set_lb_status(lb1_id)
|
self.set_lb_status(lb1_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
api_l7p_c.get('project_id')):
|
api_l7p_c.get('project_id')):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -215,7 +216,7 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
policies = self.get(
|
policies = self.get(
|
||||||
self.L7POLICIES_PATH).json.get(self.root_tag_list)
|
self.L7POLICIES_PATH).json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(1, len(policies))
|
self.assertEqual(1, len(policies))
|
||||||
policy_id_actions = [(p.get('id'), p.get('action')) for p in policies]
|
policy_id_actions = [(p.get('id'), p.get('action')) for p in policies]
|
||||||
@ -249,8 +250,9 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
redirect_url='http://localhost/').get(self.root_tag)
|
redirect_url='http://localhost/').get(self.root_tag)
|
||||||
self.set_lb_status(lb1_id)
|
self.set_lb_status(lb1_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
api_l7p_c.get('project_id')):
|
api_l7p_c.get('project_id')):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -271,7 +273,7 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
policies = self.get(
|
policies = self.get(
|
||||||
self.L7POLICIES_PATH).json.get(self.root_tag_list)
|
self.L7POLICIES_PATH).json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(3, len(policies))
|
self.assertEqual(3, len(policies))
|
||||||
policy_id_actions = [(p.get('id'), p.get('action')) for p in policies]
|
policy_id_actions = [(p.get('id'), p.get('action')) for p in policies]
|
||||||
@ -288,13 +290,13 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
policies = self.get(self.L7POLICIES_PATH, status=401).json
|
policies = self.get(self.L7POLICIES_PATH, status=401).json
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, policies)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, policies)
|
||||||
|
|
||||||
def test_get_by_project_id(self):
|
def test_get_by_project_id(self):
|
||||||
@ -497,8 +499,8 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_policy_authorized(self):
|
def test_create_policy_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
@ -522,7 +524,7 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
self.listener_id,
|
self.listener_id,
|
||||||
constants.L7POLICY_ACTION_REJECT).get(self.root_tag)
|
constants.L7POLICY_ACTION_REJECT).get(self.root_tag)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(constants.L7POLICY_ACTION_REJECT,
|
self.assertEqual(constants.L7POLICY_ACTION_REJECT,
|
||||||
api_l7policy['action'])
|
api_l7policy['action'])
|
||||||
self.assertEqual(1, api_l7policy['position'])
|
self.assertEqual(1, api_l7policy['position'])
|
||||||
@ -539,8 +541,8 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_policy_not_authorized(self):
|
def test_create_policy_not_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
@ -548,7 +550,7 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
self.listener_id,
|
self.listener_id,
|
||||||
constants.L7POLICY_ACTION_REJECT, status=401)
|
constants.L7POLICY_ACTION_REJECT, status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_l7policy)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_l7policy)
|
||||||
|
|
||||||
def test_create_redirect_to_pool(self):
|
def test_create_redirect_to_pool(self):
|
||||||
@ -654,8 +656,8 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
'redirect_url': 'http://www.example.com'}
|
'redirect_url': 'http://www.example.com'}
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -678,7 +680,7 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
l7policy_id=api_l7policy.get('id')),
|
l7policy_id=api_l7policy.get('id')),
|
||||||
self._build_body(new_l7policy)).json.get(self.root_tag)
|
self._build_body(new_l7policy)).json.get(self.root_tag)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(constants.L7POLICY_ACTION_REJECT,
|
self.assertEqual(constants.L7POLICY_ACTION_REJECT,
|
||||||
response.get('action'))
|
response.get('action'))
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
@ -698,15 +700,15 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
'redirect_url': 'http://www.example.com'}
|
'redirect_url': 'http://www.example.com'}
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
response = self.put(self.L7POLICY_PATH.format(
|
response = self.put(self.L7POLICY_PATH.format(
|
||||||
l7policy_id=api_l7policy.get('id')),
|
l7policy_id=api_l7policy.get('id')),
|
||||||
self._build_body(new_l7policy), status=401)
|
self._build_body(new_l7policy), status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -843,8 +845,8 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
self.assertEqual(api_l7policy, response)
|
self.assertEqual(api_l7policy, response)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -867,7 +869,7 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
self.delete(self.L7POLICY_PATH.format(
|
self.delete(self.L7POLICY_PATH.format(
|
||||||
l7policy_id=api_l7policy.get('id')))
|
l7policy_id=api_l7policy.get('id')))
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
l7policy_id=api_l7policy.get('id'),
|
l7policy_id=api_l7policy.get('id'),
|
||||||
@ -891,14 +893,14 @@ class TestL7Policy(base.BaseAPITest):
|
|||||||
self.assertEqual(api_l7policy, response)
|
self.assertEqual(api_l7policy, response)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
self.delete(self.L7POLICY_PATH.format(
|
self.delete(self.L7POLICY_PATH.format(
|
||||||
l7policy_id=api_l7policy.get('id')), status=401)
|
l7policy_id=api_l7policy.get('id')), status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
l7policy_id=api_l7policy.get('id'),
|
l7policy_id=api_l7policy.get('id'),
|
||||||
|
@ -61,8 +61,8 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
constants.L7RULE_COMPARE_TYPE_STARTS_WITH,
|
constants.L7RULE_COMPARE_TYPE_STARTS_WITH,
|
||||||
'/api').get(self.root_tag)
|
'/api').get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -83,7 +83,7 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.get(self.l7rule_path.format(
|
response = self.get(self.l7rule_path.format(
|
||||||
l7rule_id=l7rule.get('id'))).json.get(self.root_tag)
|
l7rule_id=l7rule.get('id'))).json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(l7rule, response)
|
self.assertEqual(l7rule, response)
|
||||||
|
|
||||||
def test_get_not_authorized(self):
|
def test_get_not_authorized(self):
|
||||||
@ -92,13 +92,13 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
constants.L7RULE_COMPARE_TYPE_STARTS_WITH,
|
constants.L7RULE_COMPARE_TYPE_STARTS_WITH,
|
||||||
'/api').get(self.root_tag)
|
'/api').get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
response = self.get(self.l7rule_path.format(
|
response = self.get(self.l7rule_path.format(
|
||||||
l7rule_id=l7rule.get('id')), status=401).json
|
l7rule_id=l7rule.get('id')), status=401).json
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response)
|
||||||
|
|
||||||
def test_get_hides_deleted(self):
|
def test_get_hides_deleted(self):
|
||||||
@ -159,8 +159,8 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
key='some-cookie').get(self.root_tag)
|
key='some-cookie').get(self.root_tag)
|
||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -182,7 +182,7 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
rules = self.get(
|
rules = self.get(
|
||||||
self.l7rules_path).json.get(self.root_tag_list)
|
self.l7rules_path).json.get(self.root_tag_list)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertIsInstance(rules, list)
|
self.assertIsInstance(rules, list)
|
||||||
self.assertEqual(2, len(rules))
|
self.assertEqual(2, len(rules))
|
||||||
rule_id_types = [(r.get('id'), r.get('type')) for r in rules]
|
rule_id_types = [(r.get('id'), r.get('type')) for r in rules]
|
||||||
@ -203,13 +203,13 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
key='some-cookie').get(self.root_tag)
|
key='some-cookie').get(self.root_tag)
|
||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
rules = self.get(self.l7rules_path, status=401)
|
rules = self.get(self.l7rules_path, status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, rules.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, rules.json)
|
||||||
|
|
||||||
def test_get_all_sorted(self):
|
def test_get_all_sorted(self):
|
||||||
@ -367,8 +367,8 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_rule_authorized(self):
|
def test_create_rule_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
@ -392,7 +392,7 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
self.l7policy_id, constants.L7RULE_TYPE_HOST_NAME,
|
self.l7policy_id, constants.L7RULE_TYPE_HOST_NAME,
|
||||||
constants.L7RULE_COMPARE_TYPE_EQUAL_TO,
|
constants.L7RULE_COMPARE_TYPE_EQUAL_TO,
|
||||||
'www.example.com').get(self.root_tag)
|
'www.example.com').get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(constants.L7RULE_TYPE_HOST_NAME,
|
self.assertEqual(constants.L7RULE_TYPE_HOST_NAME,
|
||||||
api_l7rule.get('type'))
|
api_l7rule.get('type'))
|
||||||
self.assertEqual(constants.L7RULE_COMPARE_TYPE_EQUAL_TO,
|
self.assertEqual(constants.L7RULE_COMPARE_TYPE_EQUAL_TO,
|
||||||
@ -411,8 +411,8 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_rule_not_authorized(self):
|
def test_create_rule_not_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
@ -420,7 +420,7 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
self.l7policy_id, constants.L7RULE_TYPE_HOST_NAME,
|
self.l7policy_id, constants.L7RULE_TYPE_HOST_NAME,
|
||||||
constants.L7RULE_COMPARE_TYPE_EQUAL_TO,
|
constants.L7RULE_COMPARE_TYPE_EQUAL_TO,
|
||||||
'www.example.com', status=401)
|
'www.example.com', status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_l7rule)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_l7rule)
|
||||||
|
|
||||||
def test_create_path_rule(self):
|
def test_create_path_rule(self):
|
||||||
@ -589,8 +589,8 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
new_l7rule = {'value': '/images'}
|
new_l7rule = {'value': '/images'}
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -612,7 +612,7 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
response = self.put(self.l7rule_path.format(
|
response = self.put(self.l7rule_path.format(
|
||||||
l7rule_id=api_l7rule.get('id')),
|
l7rule_id=api_l7rule.get('id')),
|
||||||
self._build_body(new_l7rule)).json.get(self.root_tag)
|
self._build_body(new_l7rule)).json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual('/api', response.get('value'))
|
self.assertEqual('/api', response.get('value'))
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -631,14 +631,14 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
new_l7rule = {'value': '/images'}
|
new_l7rule = {'value': '/images'}
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
response = self.put(self.l7rule_path.format(
|
response = self.put(self.l7rule_path.format(
|
||||||
l7rule_id=api_l7rule.get('id')),
|
l7rule_id=api_l7rule.get('id')),
|
||||||
self._build_body(new_l7rule), status=401)
|
self._build_body(new_l7rule), status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -731,8 +731,8 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
self.assertEqual(api_l7rule, response)
|
self.assertEqual(api_l7rule, response)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -754,7 +754,7 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
|
|
||||||
self.delete(
|
self.delete(
|
||||||
self.l7rule_path.format(l7rule_id=api_l7rule.get('id')))
|
self.l7rule_path.format(l7rule_id=api_l7rule.get('id')))
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
l7policy_id=self.l7policy_id, l7rule_id=api_l7rule.get('id'),
|
l7policy_id=self.l7policy_id, l7rule_id=api_l7rule.get('id'),
|
||||||
@ -781,14 +781,14 @@ class TestL7Rule(base.BaseAPITest):
|
|||||||
self.assertEqual(api_l7rule, response)
|
self.assertEqual(api_l7rule, response)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
self.delete(
|
self.delete(
|
||||||
self.l7rule_path.format(l7rule_id=api_l7rule.get('id')),
|
self.l7rule_path.format(l7rule_id=api_l7rule.get('id')),
|
||||||
status=401)
|
status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
l7policy_id=self.l7policy_id, l7rule_id=api_l7rule.get('id'),
|
l7policy_id=self.l7policy_id, l7rule_id=api_l7rule.get('id'),
|
||||||
|
@ -86,8 +86,9 @@ class TestListener(base.BaseAPITest):
|
|||||||
self.lb_id).get(self.root_tag)
|
self.lb_id).get(self.root_tag)
|
||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
listener3['project_id']):
|
listener3['project_id']):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -108,7 +109,7 @@ class TestListener(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
listeners = self.get(
|
listeners = self.get(
|
||||||
self.LISTENERS_PATH).json.get(self.root_tag_list)
|
self.LISTENERS_PATH).json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(1, len(listeners))
|
self.assertEqual(1, len(listeners))
|
||||||
listener_id_ports = [(l.get('id'), l.get('protocol_port'))
|
listener_id_ports = [(l.get('id'), l.get('protocol_port'))
|
||||||
@ -132,8 +133,9 @@ class TestListener(base.BaseAPITest):
|
|||||||
constants.PROTOCOL_HTTP, 82, lb1_id).get(self.root_tag)
|
constants.PROTOCOL_HTTP, 82, lb1_id).get(self.root_tag)
|
||||||
self.set_lb_status(lb1_id)
|
self.set_lb_status(lb1_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -154,7 +156,7 @@ class TestListener(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
listeners = self.get(self.LISTENERS_PATH)
|
listeners = self.get(self.LISTENERS_PATH)
|
||||||
listeners = listeners.json.get(self.root_tag_list)
|
listeners = listeners.json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(3, len(listeners))
|
self.assertEqual(3, len(listeners))
|
||||||
listener_id_ports = [(l.get('id'), l.get('protocol_port'))
|
listener_id_ports = [(l.get('id'), l.get('protocol_port'))
|
||||||
@ -182,12 +184,13 @@ class TestListener(base.BaseAPITest):
|
|||||||
self.lb_id).get(self.root_tag)
|
self.lb_id).get(self.root_tag)
|
||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
listeners = self.get(self.LISTENERS_PATH, status=401).json
|
listeners = self.get(self.LISTENERS_PATH, status=401).json
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, listeners)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, listeners)
|
||||||
|
|
||||||
def test_get_all_by_project_id(self):
|
def test_get_all_by_project_id(self):
|
||||||
@ -360,8 +363,9 @@ class TestListener(base.BaseAPITest):
|
|||||||
constants.PROTOCOL_HTTP, 80, self.lb_id).get(self.root_tag)
|
constants.PROTOCOL_HTTP, 80, self.lb_id).get(self.root_tag)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -385,20 +389,21 @@ class TestListener(base.BaseAPITest):
|
|||||||
listener_id=listener['id']))
|
listener_id=listener['id']))
|
||||||
api_listener = response.json.get(self.root_tag)
|
api_listener = response.json.get(self.root_tag)
|
||||||
self.assertEqual(listener, api_listener)
|
self.assertEqual(listener, api_listener)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
def test_get_not_authorized(self):
|
def test_get_not_authorized(self):
|
||||||
listener = self.create_listener(
|
listener = self.create_listener(
|
||||||
constants.PROTOCOL_HTTP, 80, self.lb_id).get(self.root_tag)
|
constants.PROTOCOL_HTTP, 80, self.lb_id).get(self.root_tag)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.listener_path.format(
|
response = self.get(self.listener_path.format(
|
||||||
listener_id=listener['id']), status=401)
|
listener_id=listener['id']), status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_get_hides_deleted(self):
|
def test_get_hides_deleted(self):
|
||||||
@ -576,8 +581,9 @@ class TestListener(base.BaseAPITest):
|
|||||||
body = self._build_body(lb_listener)
|
body = self._build_body(lb_listener)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
@ -598,7 +604,7 @@ class TestListener(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.post(self.LISTENERS_PATH, body)
|
response = self.post(self.LISTENERS_PATH, body)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
listener_api = response.json['listener']
|
listener_api = response.json['listener']
|
||||||
extra_expects = {'provisioning_status': constants.PENDING_CREATE,
|
extra_expects = {'provisioning_status': constants.PENDING_CREATE,
|
||||||
@ -638,13 +644,14 @@ class TestListener(base.BaseAPITest):
|
|||||||
body = self._build_body(lb_listener)
|
body = self._build_body(lb_listener)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.post(self.LISTENERS_PATH, body, status=401)
|
response = self.post(self.LISTENERS_PATH, body, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_update_with_bad_handler(self):
|
def test_update_with_bad_handler(self):
|
||||||
@ -750,8 +757,9 @@ class TestListener(base.BaseAPITest):
|
|||||||
listener_id=listener['id'])
|
listener_id=listener['id'])
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -772,7 +780,7 @@ class TestListener(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
api_listener = self.put(listener_path, body)
|
api_listener = self.put(listener_path, body)
|
||||||
api_listener = api_listener.json.get(self.root_tag)
|
api_listener = api_listener.json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
update_expect = {'name': 'listener2', 'admin_state_up': True,
|
update_expect = {'name': 'listener2', 'admin_state_up': True,
|
||||||
'default_pool_id': self.pool_id,
|
'default_pool_id': self.pool_id,
|
||||||
@ -803,12 +811,13 @@ class TestListener(base.BaseAPITest):
|
|||||||
listener_id=listener['id'])
|
listener_id=listener['id'])
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
api_listener = self.put(listener_path, body, status=401)
|
api_listener = self.put(listener_path, body, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_listener.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_listener.json)
|
||||||
self.assert_correct_lb_status(self.lb_id, constants.ONLINE,
|
self.assert_correct_lb_status(self.lb_id, constants.ONLINE,
|
||||||
constants.ACTIVE)
|
constants.ACTIVE)
|
||||||
@ -856,8 +865,9 @@ class TestListener(base.BaseAPITest):
|
|||||||
listener_id=listener['listener']['id'])
|
listener_id=listener['listener']['id'])
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -878,7 +888,7 @@ class TestListener(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
|
|
||||||
self.delete(listener_path)
|
self.delete(listener_path)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
response = self.get(listener_path)
|
response = self.get(listener_path)
|
||||||
api_listener = response.json['listener']
|
api_listener = response.json['listener']
|
||||||
@ -905,12 +915,12 @@ class TestListener(base.BaseAPITest):
|
|||||||
listener_id=listener['listener']['id'])
|
listener_id=listener['listener']['id'])
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
self.delete(listener_path, status=401)
|
self.delete(listener_path, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assert_correct_lb_status(self.lb_id, constants.ONLINE,
|
self.assert_correct_lb_status(self.lb_id, constants.ONLINE,
|
||||||
constants.ACTIVE)
|
constants.ACTIVE)
|
||||||
|
|
||||||
|
@ -347,8 +347,8 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_authorized(self, **optionals):
|
def test_create_authorized(self, **optionals):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
lb_json = {'name': 'test1',
|
lb_json = {'name': 'test1',
|
||||||
'vip_subnet_id': uuidutils.generate_uuid(),
|
'vip_subnet_id': uuidutils.generate_uuid(),
|
||||||
@ -376,13 +376,13 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.post(self.LBS_PATH, body)
|
response = self.post(self.LBS_PATH, body)
|
||||||
api_lb = response.json.get(self.root_tag)
|
api_lb = response.json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self._assert_request_matches_response(lb_json, api_lb)
|
self._assert_request_matches_response(lb_json, api_lb)
|
||||||
|
|
||||||
def test_create_not_authorized(self, **optionals):
|
def test_create_not_authorized(self, **optionals):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
lb_json = {'name': 'test1',
|
lb_json = {'name': 'test1',
|
||||||
'vip_subnet_id': uuidutils.generate_uuid(),
|
'vip_subnet_id': uuidutils.generate_uuid(),
|
||||||
'project_id': uuidutils.generate_uuid()
|
'project_id': uuidutils.generate_uuid()
|
||||||
@ -393,7 +393,7 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.post(self.LBS_PATH, body, status=401)
|
response = self.post(self.LBS_PATH, body, status=401)
|
||||||
api_lb = response.json
|
api_lb = response.json
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_lb)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_lb)
|
||||||
|
|
||||||
def test_create_provider_octavia(self, **optionals):
|
def test_create_provider_octavia(self, **optionals):
|
||||||
@ -464,8 +464,9 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
name='lb3', project_id=self.project_id)
|
name='lb3', project_id=self.project_id)
|
||||||
lb3 = lb3.get(self.root_tag)
|
lb3 = lb3.get(self.root_tag)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -485,7 +486,7 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.get(self.LBS_PATH)
|
response = self.get(self.LBS_PATH)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
lbs = response.json.get(self.root_tag_list)
|
lbs = response.json.get(self.root_tag_list)
|
||||||
self.assertEqual(1, len(lbs))
|
self.assertEqual(1, len(lbs))
|
||||||
@ -504,8 +505,9 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
lb2 = lb2.get(self.root_tag)
|
lb2 = lb2.get(self.root_tag)
|
||||||
lb3 = lb3.get(self.root_tag)
|
lb3 = lb3.get(self.root_tag)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -525,7 +527,7 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.get(self.LBS_PATH)
|
response = self.get(self.LBS_PATH)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
lbs = response.json.get(self.root_tag_list)
|
lbs = response.json.get(self.root_tag_list)
|
||||||
self.assertEqual(3, len(lbs))
|
self.assertEqual(3, len(lbs))
|
||||||
@ -543,14 +545,14 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
self.create_load_balancer(uuidutils.generate_uuid(),
|
self.create_load_balancer(uuidutils.generate_uuid(),
|
||||||
name='lb3', project_id=project_id)
|
name='lb3', project_id=project_id)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
LB_PROJECT_PATH = '{}?project_id={}'.format(self.LBS_PATH, project_id)
|
LB_PROJECT_PATH = '{}?project_id={}'.format(self.LBS_PATH, project_id)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
response = self.get(LB_PROJECT_PATH, status=401)
|
response = self.get(LB_PROJECT_PATH, status=401)
|
||||||
api_lb = response.json
|
api_lb = response.json
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_lb)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_lb)
|
||||||
|
|
||||||
def test_get_all_by_project_id(self):
|
def test_get_all_by_project_id(self):
|
||||||
@ -762,8 +764,8 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
admin_state_up=False)
|
admin_state_up=False)
|
||||||
lb_dict = lb.get(self.root_tag)
|
lb_dict = lb.get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project_id):
|
project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -792,7 +794,7 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
self.assertEqual(subnet.id, response.get('vip_subnet_id'))
|
self.assertEqual(subnet.id, response.get('vip_subnet_id'))
|
||||||
self.assertEqual(network.id, response.get('vip_network_id'))
|
self.assertEqual(network.id, response.get('vip_network_id'))
|
||||||
self.assertEqual(port.id, response.get('vip_port_id'))
|
self.assertEqual(port.id, response.get('vip_port_id'))
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
def test_get_not_authorized(self):
|
def test_get_not_authorized(self):
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
@ -819,14 +821,14 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
admin_state_up=False)
|
admin_state_up=False)
|
||||||
lb_dict = lb.get(self.root_tag)
|
lb_dict = lb.get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.LB_PATH.format(lb_id=lb_dict.get('id')),
|
response = self.get(self.LB_PATH.format(lb_id=lb_dict.get('id')),
|
||||||
status=401)
|
status=401)
|
||||||
api_lb = response.json
|
api_lb = response.json
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_lb)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_lb)
|
||||||
|
|
||||||
def test_create_over_quota(self):
|
def test_create_over_quota(self):
|
||||||
@ -901,8 +903,8 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
lb = self.set_lb_status(lb_dict.get('id'))
|
lb = self.set_lb_status(lb_dict.get('id'))
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project_id):
|
project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -924,7 +926,7 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
response = self.put(
|
response = self.put(
|
||||||
self.LB_PATH.format(lb_id=lb_dict.get('id')), lb_json)
|
self.LB_PATH.format(lb_id=lb_dict.get('id')), lb_json)
|
||||||
api_lb = response.json.get(self.root_tag)
|
api_lb = response.json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertIsNotNone(api_lb.get('vip_subnet_id'))
|
self.assertIsNotNone(api_lb.get('vip_subnet_id'))
|
||||||
self.assertEqual('lb1', api_lb.get('name'))
|
self.assertEqual('lb1', api_lb.get('name'))
|
||||||
self.assertEqual(project_id, api_lb.get('project_id'))
|
self.assertEqual(project_id, api_lb.get('project_id'))
|
||||||
@ -947,14 +949,14 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
lb = self.set_lb_status(lb_dict.get('id'))
|
lb = self.set_lb_status(lb_dict.get('id'))
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.put(self.LB_PATH.format(lb_id=lb_dict.get('id')),
|
response = self.put(self.LB_PATH.format(lb_id=lb_dict.get('id')),
|
||||||
lb_json, status=401)
|
lb_json, status=401)
|
||||||
api_lb = response.json
|
api_lb = response.json
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_lb)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_lb)
|
||||||
self.assert_correct_lb_status(lb_dict.get('id'), constants.ONLINE,
|
self.assert_correct_lb_status(lb_dict.get('id'), constants.ONLINE,
|
||||||
constants.ACTIVE)
|
constants.ACTIVE)
|
||||||
@ -1061,8 +1063,8 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
lb_dict = lb.get(self.root_tag)
|
lb_dict = lb.get(self.root_tag)
|
||||||
lb = self.set_lb_status(lb_dict.get('id'))
|
lb = self.set_lb_status(lb_dict.get('id'))
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project_id):
|
project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -1082,7 +1084,7 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
self.delete(self.LB_PATH.format(lb_id=lb_dict.get('id')))
|
self.delete(self.LB_PATH.format(lb_id=lb_dict.get('id')))
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
response = self.get(self.LB_PATH.format(lb_id=lb_dict.get('id')))
|
response = self.get(self.LB_PATH.format(lb_id=lb_dict.get('id')))
|
||||||
api_lb = response.json.get(self.root_tag)
|
api_lb = response.json.get(self.root_tag)
|
||||||
self.assertEqual('lb1', api_lb.get('name'))
|
self.assertEqual('lb1', api_lb.get('name'))
|
||||||
@ -1104,13 +1106,13 @@ class TestLoadBalancer(base.BaseAPITest):
|
|||||||
lb_dict = lb.get(self.root_tag)
|
lb_dict = lb.get(self.root_tag)
|
||||||
lb = self.set_lb_status(lb_dict.get('id'))
|
lb = self.set_lb_status(lb_dict.get('id'))
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
self.delete(self.LB_PATH.format(lb_id=lb_dict.get('id')),
|
self.delete(self.LB_PATH.format(lb_id=lb_dict.get('id')),
|
||||||
status=401)
|
status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
response = self.get(self.LB_PATH.format(lb_id=lb_dict.get('id')))
|
response = self.get(self.LB_PATH.format(lb_id=lb_dict.get('id')))
|
||||||
api_lb = response.json.get(self.root_tag)
|
api_lb = response.json.get(self.root_tag)
|
||||||
|
@ -73,8 +73,8 @@ class TestMember(base.BaseAPITest):
|
|||||||
api_member = self.create_member(
|
api_member = self.create_member(
|
||||||
self.pool_id, '10.0.0.1', 80).get(self.root_tag)
|
self.pool_id, '10.0.0.1', 80).get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -95,7 +95,7 @@ class TestMember(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.get(self.member_path.format(
|
response = self.get(self.member_path.format(
|
||||||
member_id=api_member.get('id'))).json.get(self.root_tag)
|
member_id=api_member.get('id'))).json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(api_member, response)
|
self.assertEqual(api_member, response)
|
||||||
self.assertEqual(api_member.get('name'), '')
|
self.assertEqual(api_member.get('name'), '')
|
||||||
|
|
||||||
@ -103,13 +103,13 @@ class TestMember(base.BaseAPITest):
|
|||||||
api_member = self.create_member(
|
api_member = self.create_member(
|
||||||
self.pool_id, '10.0.0.1', 80).get(self.root_tag)
|
self.pool_id, '10.0.0.1', 80).get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.member_path.format(
|
response = self.get(self.member_path.format(
|
||||||
member_id=api_member.get('id')), status=401).json
|
member_id=api_member.get('id')), status=401).json
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response)
|
||||||
|
|
||||||
def test_get_hides_deleted(self):
|
def test_get_hides_deleted(self):
|
||||||
@ -165,8 +165,8 @@ class TestMember(base.BaseAPITest):
|
|||||||
m.pop('updated_at')
|
m.pop('updated_at')
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -187,7 +187,7 @@ class TestMember(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.get(self.members_path)
|
response = self.get(self.members_path)
|
||||||
response = response.json.get(self.root_tag_list)
|
response = response.json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertIsInstance(response, list)
|
self.assertIsInstance(response, list)
|
||||||
self.assertEqual(2, len(response))
|
self.assertEqual(2, len(response))
|
||||||
@ -211,12 +211,12 @@ class TestMember(base.BaseAPITest):
|
|||||||
m.pop('updated_at')
|
m.pop('updated_at')
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.members_path, status=401)
|
response = self.get(self.members_path, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_get_all_sorted(self):
|
def test_get_all_sorted(self):
|
||||||
@ -346,8 +346,8 @@ class TestMember(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_authorized(self):
|
def test_create_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
@ -370,7 +370,7 @@ class TestMember(base.BaseAPITest):
|
|||||||
|
|
||||||
api_member = self.create_member(
|
api_member = self.create_member(
|
||||||
self.pool_id, '10.0.0.1', 80).get(self.root_tag)
|
self.pool_id, '10.0.0.1', 80).get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual('10.0.0.1', api_member['address'])
|
self.assertEqual('10.0.0.1', api_member['address'])
|
||||||
self.assertEqual(80, api_member['protocol_port'])
|
self.assertEqual(80, api_member['protocol_port'])
|
||||||
@ -392,14 +392,14 @@ class TestMember(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_not_authorized(self):
|
def test_create_not_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
api_member = self.create_member(
|
api_member = self.create_member(
|
||||||
self.pool_id, '10.0.0.1', 80, status=401)
|
self.pool_id, '10.0.0.1', 80, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_member)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_member)
|
||||||
|
|
||||||
# TODO(rm_work) Remove after deprecation of project_id in POST (R series)
|
# TODO(rm_work) Remove after deprecation of project_id in POST (R series)
|
||||||
@ -567,8 +567,8 @@ class TestMember(base.BaseAPITest):
|
|||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
new_member = {'name': new_name}
|
new_member = {'name': new_name}
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -593,7 +593,7 @@ class TestMember(base.BaseAPITest):
|
|||||||
member_path,
|
member_path,
|
||||||
self._build_body(new_member)).json.get(self.root_tag)
|
self._build_body(new_member)).json.get(self.root_tag)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -619,8 +619,8 @@ class TestMember(base.BaseAPITest):
|
|||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
new_member = {'name': new_name}
|
new_member = {'name': new_name}
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
member_path = self.member_path_listener.format(
|
member_path = self.member_path_listener.format(
|
||||||
@ -629,7 +629,7 @@ class TestMember(base.BaseAPITest):
|
|||||||
member_path,
|
member_path,
|
||||||
self._build_body(new_member), status=401)
|
self._build_body(new_member), status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
@ -730,8 +730,8 @@ class TestMember(base.BaseAPITest):
|
|||||||
self.assertEqual(api_member, member)
|
self.assertEqual(api_member, member)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -752,7 +752,7 @@ class TestMember(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
self.delete(self.member_path_listener.format(
|
self.delete(self.member_path_listener.format(
|
||||||
member_id=api_member.get('id')))
|
member_id=api_member.get('id')))
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -784,13 +784,13 @@ class TestMember(base.BaseAPITest):
|
|||||||
self.assertEqual(api_member, member)
|
self.assertEqual(api_member, member)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
self.delete(self.member_path_listener.format(
|
self.delete(self.member_path_listener.format(
|
||||||
member_id=api_member.get('id')), status=401)
|
member_id=api_member.get('id')), status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
|
@ -78,8 +78,8 @@ class TestPool(base.BaseAPITest):
|
|||||||
self.set_lb_status(lb_id=self.lb_id)
|
self.set_lb_status(lb_id=self.lb_id)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -102,7 +102,7 @@ class TestPool(base.BaseAPITest):
|
|||||||
pool_id=api_pool.get('id'))).json.get(self.root_tag)
|
pool_id=api_pool.get('id'))).json.get(self.root_tag)
|
||||||
response.pop('updated_at')
|
response.pop('updated_at')
|
||||||
self.assertEqual(api_pool, response)
|
self.assertEqual(api_pool, response)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
def test_get_not_authorized(self):
|
def test_get_not_authorized(self):
|
||||||
api_pool = self.create_pool(
|
api_pool = self.create_pool(
|
||||||
@ -117,13 +117,13 @@ class TestPool(base.BaseAPITest):
|
|||||||
self.set_lb_status(lb_id=self.lb_id)
|
self.set_lb_status(lb_id=self.lb_id)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.POOL_PATH.format(
|
response = self.get(self.POOL_PATH.format(
|
||||||
pool_id=api_pool.get('id')), status=401)
|
pool_id=api_pool.get('id')), status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_get_hides_deleted(self):
|
def test_get_hides_deleted(self):
|
||||||
@ -205,8 +205,9 @@ class TestPool(base.BaseAPITest):
|
|||||||
constants.LB_ALGORITHM_ROUND_ROBIN).get(self.root_tag)
|
constants.LB_ALGORITHM_ROUND_ROBIN).get(self.root_tag)
|
||||||
self.set_lb_status(self.lb_id)
|
self.set_lb_status(self.lb_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
pool3['project_id']):
|
pool3['project_id']):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -226,7 +227,7 @@ class TestPool(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
pools = self.get(self.POOLS_PATH).json.get(self.root_tag_list)
|
pools = self.get(self.POOLS_PATH).json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(1, len(pools))
|
self.assertEqual(1, len(pools))
|
||||||
pool_id_protocols = [(p.get('id'), p.get('protocol')) for p in pools]
|
pool_id_protocols = [(p.get('id'), p.get('protocol')) for p in pools]
|
||||||
@ -252,8 +253,8 @@ class TestPool(base.BaseAPITest):
|
|||||||
constants.LB_ALGORITHM_ROUND_ROBIN).get(self.root_tag)
|
constants.LB_ALGORITHM_ROUND_ROBIN).get(self.root_tag)
|
||||||
self.set_lb_status(lb1_id)
|
self.set_lb_status(lb1_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -273,7 +274,7 @@ class TestPool(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
pools = self.get(self.POOLS_PATH).json.get(self.root_tag_list)
|
pools = self.get(self.POOLS_PATH).json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(3, len(pools))
|
self.assertEqual(3, len(pools))
|
||||||
pool_id_protocols = [(p.get('id'), p.get('protocol')) for p in pools]
|
pool_id_protocols = [(p.get('id'), p.get('protocol')) for p in pools]
|
||||||
@ -303,13 +304,13 @@ class TestPool(base.BaseAPITest):
|
|||||||
constants.LB_ALGORITHM_ROUND_ROBIN).get(self.root_tag)
|
constants.LB_ALGORITHM_ROUND_ROBIN).get(self.root_tag)
|
||||||
self.set_lb_status(lb1_id)
|
self.set_lb_status(lb1_id)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
pools = self.get(self.POOLS_PATH, status=401).json
|
pools = self.get(self.POOLS_PATH, status=401).json
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, pools)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, pools)
|
||||||
|
|
||||||
def test_get_by_project_id(self):
|
def test_get_by_project_id(self):
|
||||||
@ -533,8 +534,8 @@ class TestPool(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_authorized(self):
|
def test_create_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
@ -561,7 +562,7 @@ class TestPool(base.BaseAPITest):
|
|||||||
constants.LB_ALGORITHM_ROUND_ROBIN,
|
constants.LB_ALGORITHM_ROUND_ROBIN,
|
||||||
listener_id=self.listener_id).get(self.root_tag)
|
listener_id=self.listener_id).get(self.root_tag)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -582,8 +583,8 @@ class TestPool(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_create_not_authorized(self):
|
def test_create_not_authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
@ -593,7 +594,7 @@ class TestPool(base.BaseAPITest):
|
|||||||
constants.LB_ALGORITHM_ROUND_ROBIN,
|
constants.LB_ALGORITHM_ROUND_ROBIN,
|
||||||
listener_id=self.listener_id, status=401)
|
listener_id=self.listener_id, status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_pool)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_pool)
|
||||||
|
|
||||||
def test_create_with_proxy_protocol(self):
|
def test_create_with_proxy_protocol(self):
|
||||||
@ -775,8 +776,8 @@ class TestPool(base.BaseAPITest):
|
|||||||
new_pool = {'name': 'new_name'}
|
new_pool = {'name': 'new_name'}
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -799,7 +800,7 @@ class TestPool(base.BaseAPITest):
|
|||||||
self.put(self.POOL_PATH.format(pool_id=api_pool.get('id')),
|
self.put(self.POOL_PATH.format(pool_id=api_pool.get('id')),
|
||||||
self._build_body(new_pool))
|
self._build_body(new_pool))
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -827,15 +828,15 @@ class TestPool(base.BaseAPITest):
|
|||||||
new_pool = {'name': 'new_name'}
|
new_pool = {'name': 'new_name'}
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
api_pool = self.put(
|
api_pool = self.put(
|
||||||
self.POOL_PATH.format(pool_id=api_pool.get('id')),
|
self.POOL_PATH.format(pool_id=api_pool.get('id')),
|
||||||
self._build_body(new_pool), status=401)
|
self._build_body(new_pool), status=401)
|
||||||
|
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_pool.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, api_pool.json)
|
||||||
self.assert_correct_lb_status(self.lb_id, constants.ONLINE,
|
self.assert_correct_lb_status(self.lb_id, constants.ONLINE,
|
||||||
constants.ACTIVE)
|
constants.ACTIVE)
|
||||||
@ -913,8 +914,8 @@ class TestPool(base.BaseAPITest):
|
|||||||
self.assertEqual(api_pool, response)
|
self.assertEqual(api_pool, response)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -934,7 +935,7 @@ class TestPool(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
self.delete(self.POOL_PATH.format(pool_id=api_pool.get('id')))
|
self.delete(self.POOL_PATH.format(pool_id=api_pool.get('id')))
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
@ -961,13 +962,13 @@ class TestPool(base.BaseAPITest):
|
|||||||
self.assertEqual(api_pool, response)
|
self.assertEqual(api_pool, response)
|
||||||
|
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
self.delete(self.POOL_PATH.format(pool_id=api_pool.get('id')),
|
self.delete(self.POOL_PATH.format(pool_id=api_pool.get('id')),
|
||||||
status=401)
|
status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assert_correct_status(
|
self.assert_correct_status(
|
||||||
lb_id=self.lb_id, listener_id=self.listener_id,
|
lb_id=self.lb_id, listener_id=self.listener_id,
|
||||||
|
@ -114,12 +114,12 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
body2 = {'quota': quota2}
|
body2 = {'quota': quota2}
|
||||||
self.put(quota_path2, body2, status=202)
|
self.put(quota_path2, body2, status=202)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.QUOTAS_PATH, status=401)
|
response = self.get(self.QUOTAS_PATH, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_get_all_not_Authorized_no_role(self):
|
def test_get_all_not_Authorized_no_role(self):
|
||||||
@ -130,8 +130,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
body1 = {'quota': quota1}
|
body1 = {'quota': quota1}
|
||||||
self.put(quota_path1, body1, status=202)
|
self.put(quota_path1, body1, status=202)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project_id1):
|
project_id1):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -151,7 +151,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.get(self.QUOTAS_PATH, status=401)
|
response = self.get(self.QUOTAS_PATH, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_get_all_not_Authorized_bogus_role(self):
|
def test_get_all_not_Authorized_bogus_role(self):
|
||||||
@ -168,8 +168,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
body2 = {'quota': quota2}
|
body2 = {'quota': quota2}
|
||||||
self.put(quota_path2, body2, status=202)
|
self.put(quota_path2, body2, status=202)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -189,7 +189,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.get(self.QUOTAS_PATH, status=401)
|
response = self.get(self.QUOTAS_PATH, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_get_all_admin(self):
|
def test_get_all_admin(self):
|
||||||
@ -229,8 +229,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
quota3 = self.create_quota(
|
quota3 = self.create_quota(
|
||||||
project_id=project_id3, lb_quota=3, member_quota=3
|
project_id=project_id3, lb_quota=3, member_quota=3
|
||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -251,7 +251,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
quotas = self.get(self.QUOTAS_PATH)
|
quotas = self.get(self.QUOTAS_PATH)
|
||||||
quotas = quotas.json.get(self.root_tag_list)
|
quotas = quotas.json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(3, len(quotas))
|
self.assertEqual(3, len(quotas))
|
||||||
quota_lb_member_quotas = [(l.get('load_balancer'), l.get('member'))
|
quota_lb_member_quotas = [(l.get('load_balancer'), l.get('member'))
|
||||||
for l in quotas]
|
for l in quotas]
|
||||||
@ -275,8 +275,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
quota3 = self.create_quota(
|
quota3 = self.create_quota(
|
||||||
project_id=project_id3, lb_quota=3, member_quota=3
|
project_id=project_id3, lb_quota=3, member_quota=3
|
||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -297,7 +297,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
quotas = self.get(self.QUOTAS_PATH)
|
quotas = self.get(self.QUOTAS_PATH)
|
||||||
quotas = quotas.json.get(self.root_tag_list)
|
quotas = quotas.json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(3, len(quotas))
|
self.assertEqual(3, len(quotas))
|
||||||
quota_lb_member_quotas = [(l.get('load_balancer'), l.get('member'))
|
quota_lb_member_quotas = [(l.get('load_balancer'), l.get('member'))
|
||||||
for l in quotas]
|
for l in quotas]
|
||||||
@ -322,8 +322,9 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
project_id=project3_id, lb_quota=3, member_quota=3
|
project_id=project3_id, lb_quota=3, member_quota=3
|
||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project3_id):
|
project3_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -344,7 +345,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
quotas = self.get(self.QUOTAS_PATH)
|
quotas = self.get(self.QUOTAS_PATH)
|
||||||
quotas = quotas.json.get(self.root_tag_list)
|
quotas = quotas.json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(1, len(quotas))
|
self.assertEqual(1, len(quotas))
|
||||||
quota_lb_member_quotas = [(l.get('load_balancer'), l.get('member'))
|
quota_lb_member_quotas = [(l.get('load_balancer'), l.get('member'))
|
||||||
@ -366,8 +367,9 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
project_id=project3_id, lb_quota=3, member_quota=3
|
project_id=project3_id, lb_quota=3, member_quota=3
|
||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.KEYSTONE)
|
self.conf.config(group='api_settings',
|
||||||
|
auth_strategy=constants.KEYSTONE)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project3_id):
|
project3_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -388,7 +390,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
quotas = self.get(self.QUOTAS_PATH)
|
quotas = self.get(self.QUOTAS_PATH)
|
||||||
quotas = quotas.json.get(self.root_tag_list)
|
quotas = quotas.json.get(self.root_tag_list)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
self.assertEqual(1, len(quotas))
|
self.assertEqual(1, len(quotas))
|
||||||
quota_lb_member_quotas = [(l.get('load_balancer'), l.get('member'))
|
quota_lb_member_quotas = [(l.get('load_balancer'), l.get('member'))
|
||||||
@ -434,8 +436,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project1_id):
|
project1_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -457,7 +459,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
quotas = self.get(
|
quotas = self.get(
|
||||||
self.QUOTA_PATH.format(project_id=project1_id)
|
self.QUOTA_PATH.format(project_id=project1_id)
|
||||||
).json.get(self.root_tag)
|
).json.get(self.root_tag)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self._assert_quotas_equal(quotas, quota1)
|
self._assert_quotas_equal(quotas, quota1)
|
||||||
|
|
||||||
def test_get_not_Authorized(self):
|
def test_get_not_Authorized(self):
|
||||||
@ -467,13 +469,13 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
quotas = self.get(self.QUOTA_PATH.format(project_id=project1_id),
|
quotas = self.get(self.QUOTA_PATH.format(project_id=project1_id),
|
||||||
status=401)
|
status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, quotas.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, quotas.json)
|
||||||
|
|
||||||
def test_get_not_Authorized_bogus_role(self):
|
def test_get_not_Authorized_bogus_role(self):
|
||||||
@ -483,8 +485,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project1_id):
|
project1_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -506,7 +508,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
quotas = self.get(
|
quotas = self.get(
|
||||||
self.QUOTA_PATH.format(project_id=project1_id),
|
self.QUOTA_PATH.format(project_id=project1_id),
|
||||||
status=401)
|
status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, quotas.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, quotas.json)
|
||||||
|
|
||||||
def test_get_not_Authorized_no_role(self):
|
def test_get_not_Authorized_no_role(self):
|
||||||
@ -516,8 +518,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
).get(self.root_tag)
|
).get(self.root_tag)
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
|
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
project1_id):
|
project1_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -539,7 +541,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
quotas = self.get(
|
quotas = self.get(
|
||||||
self.QUOTA_PATH.format(project_id=project1_id),
|
self.QUOTA_PATH.format(project_id=project1_id),
|
||||||
status=401)
|
status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, quotas.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, quotas.json)
|
||||||
|
|
||||||
def test_get_all_sorted(self):
|
def test_get_all_sorted(self):
|
||||||
@ -624,8 +626,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
|
|
||||||
def test_get_default_quotas_Authorized(self):
|
def test_get_default_quotas_Authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -648,18 +650,18 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
project_id=self.project_id))
|
project_id=self.project_id))
|
||||||
quota_dict = response.json
|
quota_dict = response.json
|
||||||
self._assert_quotas_equal(quota_dict['quota'])
|
self._assert_quotas_equal(quota_dict['quota'])
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
def test_get_default_quotas_not_Authorized(self):
|
def test_get_default_quotas_not_Authorized(self):
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
uuidutils.generate_uuid()):
|
uuidutils.generate_uuid()):
|
||||||
response = self.get(self.QUOTA_DEFAULT_PATH.format(
|
response = self.get(self.QUOTA_DEFAULT_PATH.format(
|
||||||
project_id=self.project_id), status=401)
|
project_id=self.project_id), status=401)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
|
|
||||||
def test_custom_quotas(self):
|
def test_custom_quotas(self):
|
||||||
quota_path = self.QUOTA_PATH.format(project_id=self.project_id)
|
quota_path = self.QUOTA_PATH.format(project_id=self.project_id)
|
||||||
@ -675,8 +677,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
body = {'quota': {'load_balancer': 30, 'listener': 30, 'pool': 30,
|
body = {'quota': {'load_balancer': 30, 'listener': 30, 'pool': 30,
|
||||||
'health_monitor': 30, 'member': 30}}
|
'health_monitor': 30, 'member': 30}}
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -696,7 +698,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
self.put(quota_path, body, status=202)
|
self.put(quota_path, body, status=202)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
response = self.get(quota_path)
|
response = self.get(quota_path)
|
||||||
quota_dict = response.json
|
quota_dict = response.json
|
||||||
self._assert_quotas_equal(quota_dict['quota'], expected=body['quota'])
|
self._assert_quotas_equal(quota_dict['quota'], expected=body['quota'])
|
||||||
@ -706,8 +708,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
body = {'quota': {'load_balancer': 30, 'listener': 30, 'pool': 30,
|
body = {'quota': {'load_balancer': 30, 'listener': 30, 'pool': 30,
|
||||||
'health_monitor': 30, 'member': 30}}
|
'health_monitor': 30, 'member': 30}}
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -727,7 +729,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
response = self.put(quota_path, body, status=401)
|
response = self.put(quota_path, body, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
self.assertEqual(self.NOT_AUTHORIZED_BODY, response.json)
|
||||||
|
|
||||||
def test_custom_partial_quotas(self):
|
def test_custom_partial_quotas(self):
|
||||||
@ -780,8 +782,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
quota_dict = response.json
|
quota_dict = response.json
|
||||||
self._assert_quotas_equal(quota_dict['quota'], expected=body['quota'])
|
self._assert_quotas_equal(quota_dict['quota'], expected=body['quota'])
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -801,7 +803,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
self.delete(quota_path, status=202)
|
self.delete(quota_path, status=202)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
response = self.get(quota_path)
|
response = self.get(quota_path)
|
||||||
quota_dict = response.json
|
quota_dict = response.json
|
||||||
self._assert_quotas_equal(quota_dict['quota'])
|
self._assert_quotas_equal(quota_dict['quota'])
|
||||||
@ -815,8 +817,8 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
quota_dict = response.json
|
quota_dict = response.json
|
||||||
self._assert_quotas_equal(quota_dict['quota'], expected=body['quota'])
|
self._assert_quotas_equal(quota_dict['quota'], expected=body['quota'])
|
||||||
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
auth_strategy = self.conf.conf.get('auth_strategy')
|
auth_strategy = self.conf.conf.api_settings.get('auth_strategy')
|
||||||
self.conf.config(auth_strategy=constants.TESTING)
|
self.conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
with mock.patch.object(octavia.common.context.Context, 'project_id',
|
||||||
self.project_id):
|
self.project_id):
|
||||||
override_credentials = {
|
override_credentials = {
|
||||||
@ -836,7 +838,7 @@ class TestQuotas(base.BaseAPITest):
|
|||||||
"oslo_context.context.RequestContext.to_policy_values",
|
"oslo_context.context.RequestContext.to_policy_values",
|
||||||
return_value=override_credentials):
|
return_value=override_credentials):
|
||||||
self.delete(quota_path, status=401)
|
self.delete(quota_path, status=401)
|
||||||
self.conf.config(auth_strategy=auth_strategy)
|
self.conf.config(group='api_settings', auth_strategy=auth_strategy)
|
||||||
response = self.get(quota_path)
|
response = self.get(quota_path)
|
||||||
quota_dict = response.json
|
quota_dict = response.json
|
||||||
self._assert_quotas_equal(quota_dict['quota'], expected=body['quota'])
|
self._assert_quotas_equal(quota_dict['quota'], expected=body['quota'])
|
||||||
|
@ -464,7 +464,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
self.skipTest("PySqlite transaction handling is broken. We can unskip"
|
self.skipTest("PySqlite transaction handling is broken. We can unskip"
|
||||||
"this when `test_sqlite_transactions_broken` fails.")
|
"this when `test_sqlite_transactions_broken` fails.")
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
member = {'project_id': project_id, 'ip_address': '11.0.0.1',
|
member = {'project_id': project_id, 'ip_address': '11.0.0.1',
|
||||||
'protocol_port': 80, 'enabled': True,
|
'protocol_port': 80, 'enabled': True,
|
||||||
@ -813,12 +813,12 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
|
|
||||||
# Test auth_strategy == NOAUTH
|
# Test auth_strategy == NOAUTH
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
self.assertFalse(self.repos.check_quota_met(self.session,
|
self.assertFalse(self.repos.check_quota_met(self.session,
|
||||||
self.session,
|
self.session,
|
||||||
models.LoadBalancer,
|
models.LoadBalancer,
|
||||||
project_id))
|
project_id))
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# Test check for missing project_id
|
# Test check for missing project_id
|
||||||
self.assertRaises(exceptions.MissingProjectID,
|
self.assertRaises(exceptions.MissingProjectID,
|
||||||
@ -1560,13 +1560,13 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on non-existent quota with noauth
|
# Test decrement on non-existent quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
models.LoadBalancer,
|
models.LoadBalancer,
|
||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.count(self.session,
|
self.assertEqual(0, self.repos.quotas.count(self.session,
|
||||||
project_id=project_id))
|
project_id=project_id))
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# Test decrement on non-existent quota
|
# Test decrement on non-existent quota
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
@ -1600,7 +1600,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on zero in use quota with noauth
|
# Test decrement on zero in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_load_balancer': 0}
|
quota = {'in_use_load_balancer': 0}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1608,7 +1608,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_load_balancer)
|
self.session, project_id=project_id).in_use_load_balancer)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# Test decrement on in use quota
|
# Test decrement on in use quota
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
@ -1623,7 +1623,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on in use quota with noauth
|
# Test decrement on in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_load_balancer': 1}
|
quota = {'in_use_load_balancer': 1}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1631,7 +1631,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_load_balancer)
|
self.session, project_id=project_id).in_use_load_balancer)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# ### Test listner quota
|
# ### Test listner quota
|
||||||
# Test decrement on zero in use quota
|
# Test decrement on zero in use quota
|
||||||
@ -1647,7 +1647,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on zero in use quota with noauth
|
# Test decrement on zero in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_listener': 0}
|
quota = {'in_use_listener': 0}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1655,7 +1655,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_listener)
|
self.session, project_id=project_id).in_use_listener)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# Test decrement on in use quota
|
# Test decrement on in use quota
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
@ -1670,7 +1670,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on in use quota with noauth
|
# Test decrement on in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_listener': 1}
|
quota = {'in_use_listener': 1}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1678,7 +1678,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_listener)
|
self.session, project_id=project_id).in_use_listener)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# ### Test pool quota
|
# ### Test pool quota
|
||||||
# Test decrement on zero in use quota
|
# Test decrement on zero in use quota
|
||||||
@ -1694,7 +1694,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on zero in use quota with noauth
|
# Test decrement on zero in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_pool': 0}
|
quota = {'in_use_pool': 0}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1702,7 +1702,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_pool)
|
self.session, project_id=project_id).in_use_pool)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# Test decrement on in use quota
|
# Test decrement on in use quota
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
@ -1717,7 +1717,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on in use quota with noauth
|
# Test decrement on in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_pool': 1}
|
quota = {'in_use_pool': 1}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1725,7 +1725,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_pool)
|
self.session, project_id=project_id).in_use_pool)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# ### Test health monitor quota
|
# ### Test health monitor quota
|
||||||
# Test decrement on zero in use quota
|
# Test decrement on zero in use quota
|
||||||
@ -1741,7 +1741,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on zero in use quota with noauth
|
# Test decrement on zero in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_health_monitor': 0}
|
quota = {'in_use_health_monitor': 0}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1749,7 +1749,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_health_monitor)
|
self.session, project_id=project_id).in_use_health_monitor)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# Test decrement on in use quota
|
# Test decrement on in use quota
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
@ -1764,7 +1764,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on in use quota with noauth
|
# Test decrement on in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_health_monitor': 1}
|
quota = {'in_use_health_monitor': 1}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1772,7 +1772,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_health_monitor)
|
self.session, project_id=project_id).in_use_health_monitor)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# ### Test member quota
|
# ### Test member quota
|
||||||
# Test decrement on zero in use quota
|
# Test decrement on zero in use quota
|
||||||
@ -1788,7 +1788,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on zero in use quota with noauth
|
# Test decrement on zero in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_member': 0}
|
quota = {'in_use_member': 0}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1796,7 +1796,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_member)
|
self.session, project_id=project_id).in_use_member)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
# Test decrement on in use quota
|
# Test decrement on in use quota
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
@ -1811,7 +1811,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
# Test decrement on in use quota with noauth
|
# Test decrement on in use quota with noauth
|
||||||
project_id = uuidutils.generate_uuid()
|
project_id = uuidutils.generate_uuid()
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(auth_strategy=constants.NOAUTH)
|
conf.config(group='api_settings', auth_strategy=constants.NOAUTH)
|
||||||
quota = {'in_use_member': 1}
|
quota = {'in_use_member': 1}
|
||||||
self.repos.quotas.update(self.session, project_id, quota=quota)
|
self.repos.quotas.update(self.session, project_id, quota=quota)
|
||||||
self.repos.decrement_quota(self.session,
|
self.repos.decrement_quota(self.session,
|
||||||
@ -1819,7 +1819,7 @@ class AllRepositoriesTest(base.OctaviaDBTestBase):
|
|||||||
project_id)
|
project_id)
|
||||||
self.assertEqual(0, self.repos.quotas.get(
|
self.assertEqual(0, self.repos.quotas.get(
|
||||||
self.session, project_id=project_id).in_use_member)
|
self.session, project_id=project_id).in_use_member)
|
||||||
conf.config(auth_strategy=constants.TESTING)
|
conf.config(group='api_settings', auth_strategy=constants.TESTING)
|
||||||
|
|
||||||
|
|
||||||
class PoolRepositoryTest(BaseRepositoryTest):
|
class PoolRepositoryTest(BaseRepositoryTest):
|
||||||
|
@ -174,7 +174,7 @@ class TestPaginationHelper(base.TestCase):
|
|||||||
request_mock.path_url = "http://localhost" + request_mock.path
|
request_mock.path_url = "http://localhost" + request_mock.path
|
||||||
api_base_uri = "https://127.0.0.1"
|
api_base_uri = "https://127.0.0.1"
|
||||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||||
conf.config(api_base_uri=api_base_uri)
|
conf.config(group='api_settings', api_base_uri=api_base_uri)
|
||||||
member1 = models.Member()
|
member1 = models.Member()
|
||||||
member1.id = uuidutils.generate_uuid()
|
member1.id = uuidutils.generate_uuid()
|
||||||
model_list = [member1]
|
model_list = [member1]
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add config variables to allow disabling either API version (v1 or v2.0).
|
11
releasenotes/notes/moving-api-config-variables-into-new-section-e1c20b77aaf5ea15.yaml
Normal file
11
releasenotes/notes/moving-api-config-variables-into-new-section-e1c20b77aaf5ea15.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
Several API related variables are moving to their own section `api_settings`.
|
||||||
|
bind_host
|
||||||
|
bind_port
|
||||||
|
api_handler
|
||||||
|
allow_pagination
|
||||||
|
allow_sorting
|
||||||
|
pagination_max_limit
|
||||||
|
api_base_uri
|
Loading…
x
Reference in New Issue
Block a user