예제 #1
0
 def test_subset_with_extras_callback_header_finders(self):
     headers = get_header_finders(self.subset_with_extras_callback)
     assert headers == {
         "callback_url_header": "test_callback_url",
         "callback_method_header": "test_callback_method",
         "custom_callback_key_header": "Asymmetric-Custom-Callback-Key",
     }
예제 #2
0
 def test_superset_callback_header_finders(self):
     headers = get_header_finders(self.superset_callback)
     assert headers == {
         "callback_url_header": "test_callback_url",
         "callback_method_header": "test_callback_method",
         "custom_callback_key_header": "test_custom_callback_key",
     }
예제 #3
0
 def __prepare_and_validate_finders(
         callback: Union[Dict[str, Any], bool]) -> Dict[str, str]:
     """
     Collects and returns the callback data finders and validates
     that they are correct on decoration-time.
     """
     try:
         validate_callback_data(callback)
         return get_header_finders(callback)
     except InvalidCallbackObjectError as error:
         log(str(error), level="critical")
         raise InvalidCallbackObjectError(error) from error
예제 #4
0
def get_openapi_endpoint_headers_schema(endpoint: Endpoint) -> List[Dict[str, Any]]:
    """Assembles the OpenAPI schema for the endpoint headers."""
    if not endpoint.callback:
        return []
    header_data = get_header_finders(endpoint.callback)
    return [
        {
            "in": "header",
            "name": header,
            "schema": {
                "type": "string",
            },
            "required": CALLBACK_OBJECT_METADATA[key]["required"],
            "description": CALLBACK_OBJECT_METADATA[key]["description"],
        }
        for key, header in header_data.items()
    ]
예제 #5
0
 def test_empty_callback_header_finders(self):
     headers = get_header_finders(self.empty_callback)
     assert headers == CALLBACK_OBJECT_DEFAULTS
예제 #6
0
 def test_booleans_header_finders(self):
     true_headers = get_header_finders(True)
     false_headers = get_header_finders(False)
     assert true_headers == CALLBACK_OBJECT_DEFAULTS
     assert false_headers == CALLBACK_OBJECT_DEFAULTS