gokulakrishnansvm commented on code in PR #7651: URL: https://github.com/apache/trafficcontrol/pull/7651#discussion_r1266498536
########## traffic_ops/testing/api_contract/v4/test_delivery_services_sslkeys.py: ########## @@ -0,0 +1,80 @@ +# +# 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. +# + +"""API Contract Test Case for delivery_service_sslkeys_generate endpoint.""" +import logging +from typing import Union +import pytest +import requests +from jsonschema import validate + +from trafficops.tosession import TOSession + +# Create and configure logger +logger = logging.getLogger() + +Primitive = Union[bool, int, float, str, None] + + +def test_delivery_service_sslkeys_contract(to_session: TOSession, + response_template_data: dict[str, Union[Primitive, list[Union[Primitive, + dict[str, object], list[object]]], dict[object, object]]], + delivery_service_sslkeys_post_data: dict[str, object] +) -> None: + """ + Test step to validate keys, values and data types from delivery_service_sslkeys endpoint + response. + :param to_session: Fixture to get Traffic Ops session. + :param response_template_data: Fixture to get response template data from a prerequisites file. + :param delivery_service_sslkeys_post_data: Fixture to get delivery services sslkeys data. + """ + # validate delivery_service_sslkeys keys from api get response + logger.info("Accessing /delivery_service_sslkeys endpoint through Traffic ops session.") + + delivery_service_sslkeys_xml_id = delivery_service_sslkeys_post_data["key"] + if not isinstance(delivery_service_sslkeys_xml_id, str): + raise TypeError("malformed API response; 'xmlId' property not a string") + + delivery_service_sslkeys_get_response: tuple[ + Union[dict[str, object], list[Union[dict[str, object], list[object], Primitive]], Primitive], + requests.Response + ] = to_session.get_deliveryservice_ssl_keys_by_xml_id(xml_id=delivery_service_sslkeys_xml_id) + try: + # delivery_service_sslkeys_data = delivery_service_sslkeys_get_response[0] Review Comment: Removed it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
