Make sure default credentials exists in openstack unit tests
Change-Id: Ib55a217d2524b9a83eefe1ca499151d47b8d87f5
This commit is contained in:
parent
0329e30896
commit
5f2c92a02e
|
@ -0,0 +1,33 @@
|
||||||
|
# Copyright (c) 2019 Red Hat
|
||||||
|
# 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 __future__ import absolute_import
|
||||||
|
|
||||||
|
from tobiko.config import CONF
|
||||||
|
from tobiko.openstack import keystone
|
||||||
|
from tobiko.tests import unit
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT_CREDENTIALS = keystone.keystone_credentials(
|
||||||
|
auth_url='http://127.0.0.1:5000/identiy/v3',
|
||||||
|
username='default',
|
||||||
|
project_name='default',
|
||||||
|
password='this is a secret')
|
||||||
|
|
||||||
|
|
||||||
|
class OpenstackTest(unit.TobikoUnitTest):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(OpenstackTest, self).setUp()
|
||||||
|
self.patch_object(CONF.tobiko, 'keystone', DEFAULT_CREDENTIALS)
|
|
@ -16,10 +16,9 @@ from __future__ import absolute_import
|
||||||
|
|
||||||
import tobiko
|
import tobiko
|
||||||
from tobiko import config
|
from tobiko import config
|
||||||
from tobiko.tests import unit
|
|
||||||
from tobiko.openstack import keystone
|
from tobiko.openstack import keystone
|
||||||
from tobiko.openstack.keystone import credentials as _credentials
|
from tobiko.openstack.keystone import credentials as _credentials
|
||||||
|
from tobiko.tests.openstack import base
|
||||||
|
|
||||||
V2_PARAMS = {
|
V2_PARAMS = {
|
||||||
'api_version': 2,
|
'api_version': 2,
|
||||||
|
@ -69,7 +68,7 @@ def make_credentials(params, **kwargs):
|
||||||
return keystone.keystone_credentials(**params)
|
return keystone.keystone_credentials(**params)
|
||||||
|
|
||||||
|
|
||||||
class KeystoneCredentialsTest(unit.TobikoUnitTest):
|
class KeystoneCredentialsTest(base.OpenstackTest):
|
||||||
|
|
||||||
def test_validate_from_params_v2(self):
|
def test_validate_from_params_v2(self):
|
||||||
credentials = make_credentials(V2_PARAMS)
|
credentials = make_credentials(V2_PARAMS)
|
||||||
|
@ -113,7 +112,7 @@ class KeystoneCredentialsTest(unit.TobikoUnitTest):
|
||||||
credentials.validate)
|
credentials.validate)
|
||||||
|
|
||||||
|
|
||||||
class EnvironKeystoneCredentialsFixtureTest(unit.TobikoUnitTest):
|
class EnvironKeystoneCredentialsFixtureTest(base.OpenstackTest):
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
fixture = _credentials.EnvironKeystoneCredentialsFixture()
|
fixture = _credentials.EnvironKeystoneCredentialsFixture()
|
||||||
|
@ -155,7 +154,7 @@ class EnvironKeystoneCredentialsFixtureTest(unit.TobikoUnitTest):
|
||||||
self.assertEqual(V3_PARAMS, fixture.credentials.to_dict())
|
self.assertEqual(V3_PARAMS, fixture.credentials.to_dict())
|
||||||
|
|
||||||
|
|
||||||
class ConfigKeystoneCredentialsFixtureTest(unit.TobikoUnitTest):
|
class ConfigKeystoneCredentialsFixtureTest(base.OpenstackTest):
|
||||||
|
|
||||||
def patch_config(self, params, **kwargs):
|
def patch_config(self, params, **kwargs):
|
||||||
credentials = make_credentials(params, **kwargs)
|
credentials = make_credentials(params, **kwargs)
|
||||||
|
@ -194,7 +193,7 @@ class ConfigKeystoneCredentialsFixtureTest(unit.TobikoUnitTest):
|
||||||
self.assertEqual(V3_PARAMS, fixture.credentials.to_dict())
|
self.assertEqual(V3_PARAMS, fixture.credentials.to_dict())
|
||||||
|
|
||||||
|
|
||||||
class DefaultKeystoneCredentialsFixtureTest(unit.TobikoUnitTest):
|
class DefaultKeystoneCredentialsFixtureTest(base.OpenstackTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DefaultKeystoneCredentialsFixtureTest, self).setUp()
|
super(DefaultKeystoneCredentialsFixtureTest, self).setUp()
|
||||||
|
|
|
@ -20,7 +20,7 @@ import mock
|
||||||
|
|
||||||
import tobiko
|
import tobiko
|
||||||
from tobiko.openstack import keystone
|
from tobiko.openstack import keystone
|
||||||
from tobiko.tests import unit
|
from tobiko.tests.openstack import base
|
||||||
|
|
||||||
|
|
||||||
CREDENTIALS = keystone.keystone_credentials(
|
CREDENTIALS = keystone.keystone_credentials(
|
||||||
|
@ -73,7 +73,7 @@ class CheckSessionCredentialsMixin(object):
|
||||||
|
|
||||||
|
|
||||||
class KeystoneSessionFixtureTest(CheckSessionCredentialsMixin,
|
class KeystoneSessionFixtureTest(CheckSessionCredentialsMixin,
|
||||||
unit.TobikoUnitTest):
|
base.OpenstackTest):
|
||||||
|
|
||||||
default_credentials_fixture = (
|
default_credentials_fixture = (
|
||||||
'tobiko.openstack.keystone.credentials.'
|
'tobiko.openstack.keystone.credentials.'
|
||||||
|
@ -123,7 +123,7 @@ class KeystoneSessionFixtureTest(CheckSessionCredentialsMixin,
|
||||||
|
|
||||||
|
|
||||||
class KeystoneSessionManagerTest(CheckSessionCredentialsMixin,
|
class KeystoneSessionManagerTest(CheckSessionCredentialsMixin,
|
||||||
unit.TobikoUnitTest):
|
base.OpenstackTest):
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
manager = keystone.KeystoneSessionManager()
|
manager = keystone.KeystoneSessionManager()
|
||||||
|
|
Loading…
Reference in New Issue