api: Add response body schemas for for console auth token APIs (v2.99)

These were not added in change I1e701cbabc0e2c435685e31465159eec09e3b1a0
as they should have been. In addition, said change regressed some unit
tests by reverting changes for that should be UUIDs back to non-UUIDs.

A future change, Ia5e4c6cadb6c88ccdf7e89566573f1f89087fbe5, will prevent
this happening again.

Change-Id: I2a50750848f8571df7cdbaf39f2168e355220c25
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2025-03-04 12:54:26 +00:00
parent 406eedb1ce
commit 401ca73c26
3 changed files with 14 additions and 5 deletions
@@ -93,11 +93,13 @@ class ConsoleAuthTokensController(wsgi.Controller):
@wsgi.Controller.api_version("2.31", "2.98") # noqa
@wsgi.expected_errors((400, 404))
@validation.query_schema(schema.show_query)
@validation.response_body_schema(schema.show_response)
def show(self, req, id): # noqa
return self._show(req, id, include_tls_port=False)
@wsgi.Controller.api_version("2.99") # noqa
@wsgi.expected_errors((400, 404))
@validation.query_schema(schema.show_query)
@validation.response_body_schema(schema.show_response_v299)
def show(self, req, id): # noqa
return self._show(req, id, include_tls_port=True)
@@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
# TODO(stephenfin): Remove additionalProperties in a future API version
show_query = {
'type': 'object',
@@ -47,3 +49,8 @@ show_response = {
'required': ['console'],
'additionalProperties': False,
}
show_response_v299 = copy.deepcopy(show_response)
show_response_v299['properties']['console']['properties'].update({
'tls_port': {'type': ['integer', 'null']},
})
@@ -35,7 +35,7 @@ class ConsoleAuthTokensExtensionTestV21(test.NoDBTestCase):
'instance_uuid': fakes.FAKE_UUID,
'host': 'fake_host',
'port': '1234',
'internal_access_path': 'fake_access_path'
'internal_access_path': fakes.FAKE_UUID,
}
}
_EXPECTED_OUTPUT_SPICE = {
@@ -53,11 +53,11 @@ class ConsoleAuthTokensExtensionTestV21(test.NoDBTestCase):
_EXPECTED_OUTPUT_DB = copy.deepcopy(_EXPECTED_OUTPUT)
_EXPECTED_OUTPUT_DB['console'].update(
{'host': 'fake_host', 'port': 1234,
'internal_access_path': 'fake_access_path'})
'internal_access_path': fakes.FAKE_UUID})
_EXPECTED_OUTPUT_DB_SPICE = copy.deepcopy(_EXPECTED_OUTPUT_SPICE)
_EXPECTED_OUTPUT_DB_SPICE['console'].update(
{'host': u'fake_host', 'port': 5900, 'tls_port': 5901})
{'host': 'fake_host', 'port': 5900, 'tls_port': 5901})
def setUp(self):
super(ConsoleAuthTokensExtensionTestV21, self).setUp()
@@ -82,7 +82,7 @@ class ConsoleAuthTokensExtensionTestV231(ConsoleAuthTokensExtensionTestV21):
@mock.patch('nova.objects.ConsoleAuthToken.validate',
return_value=objects.ConsoleAuthToken(
instance_uuid=fakes.FAKE_UUID, host='fake_host',
port='1234', internal_access_path='fake_access_path',
port='1234', internal_access_path=fakes.FAKE_UUID,
console_type='webmks',
token=fakes.FAKE_UUID))
def test_get_console_connect_info(self, mock_validate):
@@ -108,7 +108,7 @@ class ConsoleAuthTokensExtensionTestV299(ConsoleAuthTokensExtensionTestV21):
@mock.patch('nova.objects.ConsoleAuthToken.validate',
return_value=objects.ConsoleAuthToken(
instance_uuid=fakes.FAKE_UUID, host='fake_host',
port='1234', internal_access_path='fake_access_path',
port='1234', internal_access_path=fakes.FAKE_UUID,
console_type='webmks', token=fakes.FAKE_UUID))
def test_get_console_connect_info(self, mock_validate):
output = self.controller.show(self.req, fakes.FAKE_UUID)