mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-13 16:46:59 +00:00
Fixes Issue 20189: REST connector checks updated (#20736)
This commit is contained in:
parent
b59a37d244
commit
b14f83940a
@ -30,8 +30,6 @@ from metadata.ingestion.connections.test_connections import test_connection_step
|
|||||||
from metadata.ingestion.ometa.ometa_api import OpenMetadata
|
from metadata.ingestion.ometa.ometa_api import OpenMetadata
|
||||||
from metadata.utils.constants import THREE_MIN
|
from metadata.utils.constants import THREE_MIN
|
||||||
|
|
||||||
ACCEPTED_CONTENT_TYPES = ["application/json", "application/vnd.oai.openapi+json"]
|
|
||||||
|
|
||||||
|
|
||||||
class SchemaURLError(Exception):
|
class SchemaURLError(Exception):
|
||||||
"""
|
"""
|
||||||
@ -68,18 +66,22 @@ def test_connection(
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def custom_url_exec():
|
def custom_url_exec():
|
||||||
if client.status_code == 200 and any(
|
if client.status_code == 200:
|
||||||
content_type in client.headers.get("content-type")
|
|
||||||
for content_type in ACCEPTED_CONTENT_TYPES
|
|
||||||
):
|
|
||||||
return []
|
return []
|
||||||
raise SchemaURLError(
|
raise SchemaURLError(
|
||||||
"Failed to parse JSON schema url. Please check if provided url is valid JSON schema."
|
"Failed to connect to the JSON schema url. Please check the url and credentials. Status Code was: "
|
||||||
|
+ str(client.status_code)
|
||||||
)
|
)
|
||||||
|
|
||||||
def custom_schema_exec():
|
def custom_schema_exec():
|
||||||
if client.json().get("openapi") is not None:
|
try:
|
||||||
|
if client.json() is not None and client.json().get("openapi") is not None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
raise InvalidOpenAPISchemaError(
|
||||||
|
"Provided schema is not valid OpenAPI JSON schema"
|
||||||
|
)
|
||||||
|
except:
|
||||||
raise InvalidOpenAPISchemaError(
|
raise InvalidOpenAPISchemaError(
|
||||||
"Provided schema is not valid OpenAPI JSON schema"
|
"Provided schema is not valid OpenAPI JSON schema"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -169,11 +169,6 @@ class RESTTest(TestCase):
|
|||||||
)
|
)
|
||||||
assert collection_request == EXPECTED_COLLECTION_REQUEST
|
assert collection_request == EXPECTED_COLLECTION_REQUEST
|
||||||
|
|
||||||
def test_json_schema(self):
|
|
||||||
"""test json schema"""
|
|
||||||
schema_content_type = self.rest_source.connection.headers.get("content-type")
|
|
||||||
assert "application/json" in schema_content_type
|
|
||||||
|
|
||||||
def test_all_collections(self):
|
def test_all_collections(self):
|
||||||
with patch.object(
|
with patch.object(
|
||||||
self.rest_source.connection, "json", return_value=MOCK_JSON_RESPONSE
|
self.rest_source.connection, "json", return_value=MOCK_JSON_RESPONSE
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user