Merge "Rearrange integration tests"
This commit is contained in:
commit
59404393d3
0
openstackclient/tests/integ/__init__.py
Normal file
0
openstackclient/tests/integ/__init__.py
Normal file
121
openstackclient/tests/integ/base.py
Normal file
121
openstackclient/tests/integ/base.py
Normal file
@ -0,0 +1,121 @@
|
||||
# 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 keystoneauth1 import fixture as ksa_fixture
|
||||
from requests_mock.contrib import fixture
|
||||
|
||||
from openstackclient.tests import test_shell
|
||||
from openstackclient.tests import utils
|
||||
|
||||
|
||||
HOST = "192.168.5.41"
|
||||
URL_BASE = "http://%s/identity" % HOST
|
||||
|
||||
V2_AUTH_URL = URL_BASE + "/v2.0/"
|
||||
V2_VERSION_RESP = {
|
||||
"version": {
|
||||
"status": "stable",
|
||||
"updated": "2014-04-17T00:00:00Z",
|
||||
"media-types": [
|
||||
{
|
||||
"base": "application/json",
|
||||
"type": "application/vnd.openstack.identity-v2.0+json",
|
||||
},
|
||||
],
|
||||
"id": "v2.0",
|
||||
"links": [
|
||||
{
|
||||
"href": V2_AUTH_URL,
|
||||
"rel": "self",
|
||||
},
|
||||
{
|
||||
"href": "http://docs.openstack.org/",
|
||||
"type": "text/html",
|
||||
"rel": "describedby",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
V3_AUTH_URL = URL_BASE + "/v3/"
|
||||
V3_VERSION_RESP = {
|
||||
"version": {
|
||||
"status": "stable",
|
||||
"updated": "2016-04-04T00:00:00Z",
|
||||
"media-types": [{
|
||||
"base": "application/json",
|
||||
"type": "application/vnd.openstack.identity-v3+json",
|
||||
}],
|
||||
"id": "v3.6",
|
||||
"links": [{
|
||||
"href": V3_AUTH_URL,
|
||||
"rel": "self",
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def make_v2_token(req_mock):
|
||||
"""Create an Identity v2 token and register the responses"""
|
||||
|
||||
token = ksa_fixture.V2Token(
|
||||
tenant_name=test_shell.DEFAULT_PROJECT_NAME,
|
||||
user_name=test_shell.DEFAULT_USERNAME,
|
||||
)
|
||||
|
||||
# Set up the v2 auth routes
|
||||
req_mock.register_uri(
|
||||
'GET',
|
||||
V2_AUTH_URL,
|
||||
json=V2_VERSION_RESP,
|
||||
status_code=200,
|
||||
)
|
||||
req_mock.register_uri(
|
||||
'POST',
|
||||
V2_AUTH_URL + 'tokens',
|
||||
json=token,
|
||||
status_code=200,
|
||||
)
|
||||
return token
|
||||
|
||||
|
||||
def make_v3_token(req_mock):
|
||||
"""Create an Identity v3 token and register the response"""
|
||||
|
||||
token = ksa_fixture.V3Token(
|
||||
# project_domain_id=test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
user_domain_id=test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
user_name=test_shell.DEFAULT_USERNAME,
|
||||
)
|
||||
|
||||
# Set up the v3 auth routes
|
||||
req_mock.register_uri(
|
||||
'GET',
|
||||
V3_AUTH_URL,
|
||||
json=V3_VERSION_RESP,
|
||||
status_code=200,
|
||||
)
|
||||
req_mock.register_uri(
|
||||
'POST',
|
||||
V3_AUTH_URL + 'auth/tokens',
|
||||
json=token,
|
||||
status_code=200,
|
||||
)
|
||||
return token
|
||||
|
||||
|
||||
class TestInteg(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestInteg, self).setUp()
|
||||
|
||||
self.requests_mock = self.useFixture(fixture.Fixture())
|
0
openstackclient/tests/integ/cli/__init__.py
Normal file
0
openstackclient/tests/integ/cli/__init__.py
Normal file
257
openstackclient/tests/integ/cli/test_project.py
Normal file
257
openstackclient/tests/integ/cli/test_project.py
Normal file
@ -0,0 +1,257 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
|
||||
from osc_lib.tests import utils as osc_lib_utils
|
||||
|
||||
from openstackclient import shell
|
||||
from openstackclient.tests.integ import base as test_base
|
||||
from openstackclient.tests import test_shell
|
||||
|
||||
|
||||
class TestIntegV2ProjectID(test_base.TestInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIntegV2ProjectID, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": test_base.V2_AUTH_URL,
|
||||
"OS_PROJECT_ID": test_shell.DEFAULT_PROJECT_ID,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
"OS_PASSWORD": test_shell.DEFAULT_PASSWORD,
|
||||
"OS_IDENTITY_API_VERSION": "2",
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = test_base.make_v2_token(self.requests_mock)
|
||||
|
||||
def test_project_id_env(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
_shell.run("configuration show".split())
|
||||
|
||||
# Check general calls
|
||||
self.assertEqual(len(self.requests_mock.request_history), 2)
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
test_base.V2_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
# Check auth request
|
||||
auth_req = self.requests_mock.request_history[1].json()
|
||||
|
||||
self.assertEqual(
|
||||
test_shell.DEFAULT_PROJECT_ID,
|
||||
auth_req['auth']['tenantId'],
|
||||
)
|
||||
|
||||
def test_project_id_arg(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
_shell.run("--os-project-id wsx configuration show".split())
|
||||
|
||||
# Check general calls
|
||||
self.assertEqual(len(self.requests_mock.request_history), 2)
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
test_base.V2_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
# Check auth request
|
||||
auth_req = self.requests_mock.request_history[1].json()
|
||||
|
||||
self.assertEqual(
|
||||
"wsx",
|
||||
auth_req['auth']['tenantId'],
|
||||
)
|
||||
|
||||
|
||||
class TestIntegV2ProjectName(test_base.TestInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIntegV2ProjectName, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": test_base.V2_AUTH_URL,
|
||||
"OS_PROJECT_NAME": test_shell.DEFAULT_PROJECT_NAME,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
"OS_PASSWORD": test_shell.DEFAULT_PASSWORD,
|
||||
"OS_IDENTITY_API_VERSION": "2",
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = test_base.make_v2_token(self.requests_mock)
|
||||
|
||||
def test_project_name_env(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
_shell.run("configuration show".split())
|
||||
|
||||
# Check general calls
|
||||
self.assertEqual(len(self.requests_mock.request_history), 2)
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
test_base.V2_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
# Check auth request
|
||||
auth_req = self.requests_mock.request_history[1].json()
|
||||
|
||||
self.assertEqual(
|
||||
test_shell.DEFAULT_PROJECT_NAME,
|
||||
auth_req['auth']['tenantName'],
|
||||
)
|
||||
|
||||
def test_project_name_arg(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
_shell.run("--os-project-name qaz configuration show".split())
|
||||
|
||||
# Check general calls
|
||||
self.assertEqual(len(self.requests_mock.request_history), 2)
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
test_base.V2_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
# Check auth request
|
||||
auth_req = self.requests_mock.request_history[1].json()
|
||||
|
||||
self.assertEqual(
|
||||
"qaz",
|
||||
auth_req['auth']['tenantName'],
|
||||
)
|
||||
|
||||
|
||||
class TestIntegV3ProjectID(test_base.TestInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIntegV3ProjectID, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": test_base.V3_AUTH_URL,
|
||||
"OS_PROJECT_ID": test_shell.DEFAULT_PROJECT_NAME,
|
||||
# "OS_PROJECT_DOMAIN_ID": test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
# "OS_USER_DOMAIN_ID": test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
"OS_PASSWORD": test_shell.DEFAULT_PASSWORD,
|
||||
"OS_IDENTITY_API_VERSION": "3",
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = test_base.make_v3_token(self.requests_mock)
|
||||
|
||||
def test_project_id_env(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
_shell.run("configuration show".split())
|
||||
|
||||
# Check general calls
|
||||
self.assertEqual(len(self.requests_mock.request_history), 2)
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
test_base.V3_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
# Check auth request
|
||||
auth_req = self.requests_mock.request_history[1].json()
|
||||
|
||||
self.assertIsNone(auth_req['auth'].get('tenantId', None))
|
||||
self.assertIsNone(auth_req['auth'].get('tenantName', None))
|
||||
|
||||
def test_project_id_arg(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
_shell.run("--os-project-id wsx configuration show".split())
|
||||
|
||||
# Check general calls
|
||||
self.assertEqual(len(self.requests_mock.request_history), 2)
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
test_base.V3_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
# Check auth request
|
||||
auth_req = self.requests_mock.request_history[1].json()
|
||||
|
||||
self.assertIsNone(auth_req['auth'].get('tenantId', None))
|
||||
self.assertIsNone(auth_req['auth'].get('tenantName', None))
|
||||
|
||||
|
||||
class TestIntegV3ProjectName(test_base.TestInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIntegV3ProjectName, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": test_base.V3_AUTH_URL,
|
||||
"OS_PROJECT_NAME": test_shell.DEFAULT_PROJECT_NAME,
|
||||
# "OS_PROJECT_DOMAIN_ID": test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
# "OS_USER_DOMAIN_ID": test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
"OS_PASSWORD": test_shell.DEFAULT_PASSWORD,
|
||||
"OS_IDENTITY_API_VERSION": "3",
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = test_base.make_v3_token(self.requests_mock)
|
||||
|
||||
def test_project_name_env(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
_shell.run("configuration show".split())
|
||||
|
||||
# Check general calls
|
||||
self.assertEqual(len(self.requests_mock.request_history), 2)
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
test_base.V3_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
# Check auth request
|
||||
auth_req = self.requests_mock.request_history[1].json()
|
||||
|
||||
self.assertEqual(
|
||||
test_shell.DEFAULT_PROJECT_NAME,
|
||||
auth_req['auth']['scope']['project']['name'],
|
||||
)
|
||||
|
||||
self.assertIsNone(auth_req['auth'].get('tenantId', None))
|
||||
self.assertIsNone(auth_req['auth'].get('tenantName', None))
|
||||
|
||||
def test_project_name_arg(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
_shell.run("--os-project-name wsx configuration show".split())
|
||||
|
||||
# Check general calls
|
||||
self.assertEqual(len(self.requests_mock.request_history), 2)
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
test_base.V3_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
# Check auth request
|
||||
auth_req = self.requests_mock.request_history[1].json()
|
||||
|
||||
self.assertEqual(
|
||||
"wsx",
|
||||
auth_req['auth']['scope']['project']['name'],
|
||||
)
|
||||
|
||||
self.assertIsNone(auth_req['auth'].get('tenantId', None))
|
||||
self.assertIsNone(auth_req['auth'].get('tenantName', None))
|
@ -13,75 +13,19 @@
|
||||
import copy
|
||||
import mock
|
||||
|
||||
from keystoneauth1 import fixture as ksa_fixture
|
||||
from osc_lib.tests import utils as osc_lib_utils
|
||||
from requests_mock.contrib import fixture
|
||||
|
||||
from openstackclient import shell
|
||||
from openstackclient.tests.integ import base as test_base
|
||||
from openstackclient.tests import test_shell
|
||||
from openstackclient.tests import utils
|
||||
|
||||
HOST = "192.168.5.41"
|
||||
URL_BASE = "http://%s/identity" % HOST
|
||||
|
||||
V2_AUTH_URL = URL_BASE + "/v2.0/"
|
||||
V2_VERSION_RESP = {
|
||||
"version": {
|
||||
"status": "stable",
|
||||
"updated": "2014-04-17T00:00:00Z",
|
||||
"media-types": [
|
||||
{
|
||||
"base": "application/json",
|
||||
"type": "application/vnd.openstack.identity-v2.0+json",
|
||||
},
|
||||
],
|
||||
"id": "v2.0",
|
||||
"links": [
|
||||
{
|
||||
"href": V2_AUTH_URL,
|
||||
"rel": "self",
|
||||
},
|
||||
{
|
||||
"href": "http://docs.openstack.org/",
|
||||
"type": "text/html",
|
||||
"rel": "describedby",
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
V3_AUTH_URL = URL_BASE + "/v3/"
|
||||
V3_VERSION_RESP = {
|
||||
"version": {
|
||||
"status": "stable",
|
||||
"updated": "2016-04-04T00:00:00Z",
|
||||
"media-types": [{
|
||||
"base": "application/json",
|
||||
"type": "application/vnd.openstack.identity-v3+json",
|
||||
}],
|
||||
"id": "v3.6",
|
||||
"links": [{
|
||||
"href": V3_AUTH_URL,
|
||||
"rel": "self",
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestShellInteg(utils.TestCase):
|
||||
class TestIntegShellCliV2(test_base.TestInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellInteg, self).setUp()
|
||||
|
||||
self.requests_mock = self.useFixture(fixture.Fixture())
|
||||
|
||||
|
||||
class TestShellCliV2Integ(TestShellInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellCliV2Integ, self).setUp()
|
||||
super(TestIntegShellCliV2, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": V2_AUTH_URL,
|
||||
"OS_AUTH_URL": test_base.V2_AUTH_URL,
|
||||
"OS_PROJECT_NAME": test_shell.DEFAULT_PROJECT_NAME,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
"OS_PASSWORD": test_shell.DEFAULT_PASSWORD,
|
||||
@ -89,24 +33,7 @@ class TestShellCliV2Integ(TestShellInteg):
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = ksa_fixture.V2Token(
|
||||
tenant_name=test_shell.DEFAULT_PROJECT_NAME,
|
||||
user_name=test_shell.DEFAULT_USERNAME,
|
||||
)
|
||||
|
||||
# Set up the v2 auth routes
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
V2_AUTH_URL,
|
||||
json=V2_VERSION_RESP,
|
||||
status_code=200,
|
||||
)
|
||||
self.requests_mock.register_uri(
|
||||
'POST',
|
||||
V2_AUTH_URL + 'tokens',
|
||||
json=self.token,
|
||||
status_code=200,
|
||||
)
|
||||
self.token = test_base.make_v2_token(self.requests_mock)
|
||||
|
||||
def test_shell_args_no_options(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
@ -117,7 +44,7 @@ class TestShellCliV2Integ(TestShellInteg):
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
V2_AUTH_URL,
|
||||
test_base.V2_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
@ -181,12 +108,12 @@ class TestShellCliV2Integ(TestShellInteg):
|
||||
self.assertFalse(self.requests_mock.request_history[0].verify)
|
||||
|
||||
|
||||
class TestShellCliV2IgnoreInteg(TestShellInteg):
|
||||
class TestIntegShellCliV2Ignore(test_base.TestInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellCliV2IgnoreInteg, self).setUp()
|
||||
super(TestIntegShellCliV2Ignore, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": V2_AUTH_URL,
|
||||
"OS_AUTH_URL": test_base.V2_AUTH_URL,
|
||||
"OS_PROJECT_NAME": test_shell.DEFAULT_PROJECT_NAME,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
"OS_PASSWORD": test_shell.DEFAULT_PASSWORD,
|
||||
@ -196,24 +123,7 @@ class TestShellCliV2IgnoreInteg(TestShellInteg):
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = ksa_fixture.V2Token(
|
||||
tenant_name=test_shell.DEFAULT_PROJECT_NAME,
|
||||
user_name=test_shell.DEFAULT_USERNAME,
|
||||
)
|
||||
|
||||
# Set up the v2 auth routes
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
V2_AUTH_URL,
|
||||
json=V2_VERSION_RESP,
|
||||
status_code=200,
|
||||
)
|
||||
self.requests_mock.register_uri(
|
||||
'POST',
|
||||
V2_AUTH_URL + 'tokens',
|
||||
json=self.token,
|
||||
status_code=200,
|
||||
)
|
||||
self.token = test_base.make_v2_token(self.requests_mock)
|
||||
|
||||
def test_shell_args_ignore_v3(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
@ -224,7 +134,7 @@ class TestShellCliV2IgnoreInteg(TestShellInteg):
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
V2_AUTH_URL,
|
||||
test_base.V2_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
@ -245,12 +155,12 @@ class TestShellCliV2IgnoreInteg(TestShellInteg):
|
||||
)
|
||||
|
||||
|
||||
class TestShellCliV3Integ(TestShellInteg):
|
||||
class TestIntegShellCliV3(test_base.TestInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellCliV3Integ, self).setUp()
|
||||
super(TestIntegShellCliV3, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": V3_AUTH_URL,
|
||||
"OS_AUTH_URL": test_base.V3_AUTH_URL,
|
||||
"OS_PROJECT_DOMAIN_ID": test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
"OS_USER_DOMAIN_ID": test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
@ -259,25 +169,7 @@ class TestShellCliV3Integ(TestShellInteg):
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = ksa_fixture.V3Token(
|
||||
project_domain_id=test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
user_domain_id=test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
user_name=test_shell.DEFAULT_USERNAME,
|
||||
)
|
||||
|
||||
# Set up the v3 auth routes
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
V3_AUTH_URL,
|
||||
json=V3_VERSION_RESP,
|
||||
status_code=200,
|
||||
)
|
||||
self.requests_mock.register_uri(
|
||||
'POST',
|
||||
V3_AUTH_URL + 'auth/tokens',
|
||||
json=self.token,
|
||||
status_code=200,
|
||||
)
|
||||
self.token = test_base.make_v3_token(self.requests_mock)
|
||||
|
||||
def test_shell_args_no_options(self):
|
||||
_shell = shell.OpenStackShell()
|
||||
@ -288,7 +180,7 @@ class TestShellCliV3Integ(TestShellInteg):
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
V3_AUTH_URL,
|
||||
test_base.V3_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
@ -354,12 +246,12 @@ class TestShellCliV3Integ(TestShellInteg):
|
||||
self.assertFalse(self.requests_mock.request_history[0].verify)
|
||||
|
||||
|
||||
class TestShellCliV3Prompt(TestShellInteg):
|
||||
class TestIntegShellCliV3Prompt(test_base.TestInteg):
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellCliV3Prompt, self).setUp()
|
||||
super(TestIntegShellCliV3Prompt, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": V3_AUTH_URL,
|
||||
"OS_AUTH_URL": test_base.V3_AUTH_URL,
|
||||
"OS_PROJECT_DOMAIN_ID": test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
"OS_USER_DOMAIN_ID": test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
@ -367,25 +259,7 @@ class TestShellCliV3Prompt(TestShellInteg):
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = ksa_fixture.V3Token(
|
||||
project_domain_id=test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
user_domain_id=test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
user_name=test_shell.DEFAULT_USERNAME,
|
||||
)
|
||||
|
||||
# Set up the v3 auth routes
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
V3_AUTH_URL,
|
||||
json=V3_VERSION_RESP,
|
||||
status_code=200,
|
||||
)
|
||||
self.requests_mock.register_uri(
|
||||
'POST',
|
||||
V3_AUTH_URL + 'auth/tokens',
|
||||
json=self.token,
|
||||
status_code=200,
|
||||
)
|
||||
self.token = test_base.make_v3_token(self.requests_mock)
|
||||
|
||||
@mock.patch("osc_lib.shell.prompt_for_password")
|
||||
def test_shell_callback(self, mock_prompt):
|
||||
@ -412,7 +286,7 @@ class TestShellCliV3Prompt(TestShellInteg):
|
||||
)
|
||||
|
||||
|
||||
class TestShellCliPrecedence(TestShellInteg):
|
||||
class TestIntegShellCliPrecedence(test_base.TestInteg):
|
||||
"""Validate option precedence rules without clouds.yaml
|
||||
|
||||
Global option values may be set in three places:
|
||||
@ -425,9 +299,9 @@ class TestShellCliPrecedence(TestShellInteg):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellCliPrecedence, self).setUp()
|
||||
super(TestIntegShellCliPrecedence, self).setUp()
|
||||
env = {
|
||||
"OS_AUTH_URL": V3_AUTH_URL,
|
||||
"OS_AUTH_URL": test_base.V3_AUTH_URL,
|
||||
"OS_PROJECT_DOMAIN_ID": test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
"OS_USER_DOMAIN_ID": test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
@ -435,29 +309,11 @@ class TestShellCliPrecedence(TestShellInteg):
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = ksa_fixture.V3Token(
|
||||
project_domain_id=test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
user_domain_id=test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
user_name=test_shell.DEFAULT_USERNAME,
|
||||
)
|
||||
|
||||
# Set up the v3 auth routes
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
V3_AUTH_URL,
|
||||
json=V3_VERSION_RESP,
|
||||
status_code=200,
|
||||
)
|
||||
self.requests_mock.register_uri(
|
||||
'POST',
|
||||
V3_AUTH_URL + 'auth/tokens',
|
||||
json=self.token,
|
||||
status_code=200,
|
||||
)
|
||||
self.token = test_base.make_v3_token(self.requests_mock)
|
||||
|
||||
# Patch a v3 auth URL into the o-c-c data
|
||||
test_shell.PUBLIC_1['public-clouds']['megadodo']['auth']['auth_url'] \
|
||||
= V3_AUTH_URL
|
||||
= test_base.V3_AUTH_URL
|
||||
|
||||
def test_shell_args_options(self):
|
||||
"""Verify command line options override environment variables"""
|
||||
@ -473,7 +329,7 @@ class TestShellCliPrecedence(TestShellInteg):
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
V3_AUTH_URL,
|
||||
test_base.V3_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
@ -502,7 +358,7 @@ class TestShellCliPrecedence(TestShellInteg):
|
||||
)
|
||||
|
||||
|
||||
class TestShellCliPrecedenceOCC(TestShellInteg):
|
||||
class TestIntegShellCliPrecedenceOCC(test_base.TestInteg):
|
||||
"""Validate option precedence rules with clouds.yaml
|
||||
|
||||
Global option values may be set in three places:
|
||||
@ -515,10 +371,10 @@ class TestShellCliPrecedenceOCC(TestShellInteg):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestShellCliPrecedenceOCC, self).setUp()
|
||||
super(TestIntegShellCliPrecedenceOCC, self).setUp()
|
||||
env = {
|
||||
"OS_CLOUD": "megacloud",
|
||||
"OS_AUTH_URL": V3_AUTH_URL,
|
||||
"OS_AUTH_URL": test_base.V3_AUTH_URL,
|
||||
"OS_PROJECT_DOMAIN_ID": test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
"OS_USER_DOMAIN_ID": test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
"OS_USERNAME": test_shell.DEFAULT_USERNAME,
|
||||
@ -527,29 +383,11 @@ class TestShellCliPrecedenceOCC(TestShellInteg):
|
||||
}
|
||||
self.useFixture(osc_lib_utils.EnvFixture(copy.deepcopy(env)))
|
||||
|
||||
self.token = ksa_fixture.V3Token(
|
||||
project_domain_id=test_shell.DEFAULT_PROJECT_DOMAIN_ID,
|
||||
user_domain_id=test_shell.DEFAULT_USER_DOMAIN_ID,
|
||||
user_name=test_shell.DEFAULT_USERNAME,
|
||||
)
|
||||
|
||||
# Set up the v3 auth routes
|
||||
self.requests_mock.register_uri(
|
||||
'GET',
|
||||
V3_AUTH_URL,
|
||||
json=V3_VERSION_RESP,
|
||||
status_code=200,
|
||||
)
|
||||
self.requests_mock.register_uri(
|
||||
'POST',
|
||||
V3_AUTH_URL + 'auth/tokens',
|
||||
json=self.token,
|
||||
status_code=200,
|
||||
)
|
||||
self.token = test_base.make_v3_token(self.requests_mock)
|
||||
|
||||
# Patch a v3 auth URL into the o-c-c data
|
||||
test_shell.PUBLIC_1['public-clouds']['megadodo']['auth']['auth_url'] \
|
||||
= V3_AUTH_URL
|
||||
= test_base.V3_AUTH_URL
|
||||
|
||||
@mock.patch("os_client_config.config.OpenStackConfig._load_vendor_file")
|
||||
@mock.patch("os_client_config.config.OpenStackConfig._load_config_file")
|
||||
@ -577,7 +415,7 @@ class TestShellCliPrecedenceOCC(TestShellInteg):
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
V3_AUTH_URL,
|
||||
test_base.V3_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
||||
@ -647,7 +485,7 @@ class TestShellCliPrecedenceOCC(TestShellInteg):
|
||||
|
||||
# Check discovery request
|
||||
self.assertEqual(
|
||||
V3_AUTH_URL,
|
||||
test_base.V3_AUTH_URL,
|
||||
self.requests_mock.request_history[0].url,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user