Merge "Adds provider API tests"
This commit is contained in:
commit
ebbe4ef969
|
@ -114,6 +114,16 @@ OctaviaGroup = [
|
|||
help='Type of RBAC tests to run. "advanced" runs the octavia '
|
||||
'default RBAC tests. "owner_or_admin" runs the legacy '
|
||||
'owner or admin tests. "none" disables the RBAC tests.'),
|
||||
cfg.DictOpt('enabled_provider_drivers',
|
||||
help=('List of enabled provider drivers and description '
|
||||
'dictionaries. Must match the driver name in the '
|
||||
'octavia.api.drivers entrypoint. Example: '
|
||||
'{\'amphora\': \'The Octavia Amphora driver.\', '
|
||||
'\'octavia\': \'Deprecated alias of the Octavia '
|
||||
'Amphora driver.\'}'),
|
||||
default={'amphora': 'The Octavia Amphora driver.',
|
||||
'octavia': 'Deprecated alias of the Octavia Amphora '
|
||||
'driver.'}),
|
||||
# Networking
|
||||
cfg.BoolOpt('test_with_ipv6',
|
||||
default=True,
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
# Copyright 2019 Rackspace US Inc. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
from tempest import config
|
||||
from tempest.lib import decorators
|
||||
from tempest.lib import exceptions
|
||||
|
||||
from octavia_tempest_plugin.common import constants as const
|
||||
from octavia_tempest_plugin.tests import test_base
|
||||
|
||||
CONF = config.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ProviderAPITest(test_base.LoadBalancerBaseTest):
|
||||
"""Test the provider object API."""
|
||||
|
||||
@decorators.idempotent_id('8b94e0cc-a24d-4c29-bc8e-53f58214dc67')
|
||||
def test_provider_list(self):
|
||||
"""Tests provider list API and field filtering.
|
||||
|
||||
* Validates that non-lb member accounts cannot list the providers.
|
||||
* List the providers and validate against the expected provider list.
|
||||
* List the providers returning one field at a time.
|
||||
"""
|
||||
# We have to do this here as the api_version and clients are not
|
||||
# setup in time to use a decorator or the skip_checks mixin
|
||||
if not self.mem_provider_client.is_version_supported(
|
||||
self.api_version, '2.1'):
|
||||
raise self.skipException('Providers are only available on '
|
||||
'Octavia API version 2.1 or newer.')
|
||||
|
||||
# Test that a user without the load balancer role cannot
|
||||
# list providers.
|
||||
if CONF.load_balancer.RBAC_test_type == const.ADVANCED:
|
||||
self.assertRaises(
|
||||
exceptions.Forbidden,
|
||||
self.os_primary.provider_client.list_providers)
|
||||
|
||||
providers = self.mem_provider_client.list_providers()
|
||||
|
||||
# Check against the expected providers from the tempest config
|
||||
enabled_providers = CONF.load_balancer.enabled_provider_drivers
|
||||
for provider in providers:
|
||||
self.assertEqual(enabled_providers[provider[const.NAME]],
|
||||
provider.get(const.DESCRIPTION, ''))
|
||||
|
||||
# Test fields
|
||||
providers = self.mem_provider_client.list_providers(
|
||||
query_params='{fields}={field}'.format(fields=const.FIELDS,
|
||||
field=const.NAME))
|
||||
for provider in providers:
|
||||
self.assertEqual(1, len(provider))
|
||||
self.assertIn(provider[const.NAME], enabled_providers.keys())
|
||||
providers = self.mem_provider_client.list_providers(
|
||||
query_params='{fields}={field}'.format(fields=const.FIELDS,
|
||||
field=const.DESCRIPTION))
|
||||
for provider in providers:
|
||||
self.assertEqual(1, len(provider))
|
||||
self.assertIn(provider[const.DESCRIPTION],
|
||||
enabled_providers.values())
|
|
@ -126,6 +126,7 @@ class LoadBalancerBaseTest(test.BaseTestCase):
|
|||
cls.os_roles_lb_admin.flavor_profile_client)
|
||||
cls.lb_admin_flavor_client = cls.os_roles_lb_admin.flavor_client
|
||||
cls.mem_flavor_client = cls.os_roles_lb_member.flavor_client
|
||||
cls.mem_provider_client = cls.os_roles_lb_member.provider_client
|
||||
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
|
|
Loading…
Reference in New Issue