From 242696141293af1be2b6f6eccf8987131b9bce4f Mon Sep 17 00:00:00 2001 From: Tomas Mizera Date: Fri, 29 Nov 2024 14:28:33 +0100 Subject: [PATCH] Remove deprecated check for server compatibility via the list of endpoints --- mergin/cli.py | 4 +--- mergin/client.py | 46 -------------------------------------- mergin/test/test_client.py | 5 ----- 3 files changed, 1 insertion(+), 54 deletions(-) diff --git a/mergin/cli.py b/mergin/cli.py index deaadb71..e479b886 100755 --- a/mergin/cli.py +++ b/mergin/cli.py @@ -95,9 +95,7 @@ def pretty_summary(summary): def get_token(url, username, password): """Get authorization token for given user and password.""" mc = MerginClient(url) - if not mc.is_server_compatible(): - click.secho(str("This client version is incompatible with server, try to upgrade"), fg="red") - return None + try: session = mc.login(username, password) except LoginError as e: diff --git a/mergin/client.py b/mergin/client.py index 4cd7ef39..efe43fa2 100644 --- a/mergin/client.py +++ b/mergin/client.py @@ -244,52 +244,6 @@ def patch(self, path, data=None, headers={}): request = urllib.request.Request(url, data, headers, method="PATCH") return self._do_request(request) - def is_server_compatible(self): - """ - Test whether version of the server meets the required set of endpoints. - - :returns: client compatible with server - rtype: Boolean - """ - resp = self.get("/ping") - data = json.load(resp) - if "endpoints" not in data: - return False - endpoints = data["endpoints"] - - client_endpoints = { - "data_sync": { - "GET": ["/project/raw/{namespace}/{project_name}"], - "POST": [ - "/project/push/cancel/{transaction_id}", - "/project/push/finish/{transaction_id}", - "/project/push/{namespace}/{project_name}", - # "/project/push/chunk/{transaction_id}/{chunk_id}" # issue in server - ], - }, - "project": { - "DELETE": ["/project/{namespace}/{project_name}"], - "GET": [ - "/project", - "/project/{namespace}/{project_name}", - "/project/version/{namespace}/{project_name}", - ], - "POST": ["/project/{namespace}"], - }, - "user": {"POST": ["/auth/login"]}, - } - - for k, v in client_endpoints.items(): - if k not in endpoints: - return False - for method, url_list in v.items(): - if method not in endpoints[k]: - return False - for url in url_list: - if url not in endpoints[k][method]: - return False - return True - def login(self, login, password): """ Authenticate login credentials and store session token diff --git a/mergin/test/test_client.py b/mergin/test/test_client.py index 6e35c6e5..2ac4b9a0 100644 --- a/mergin/test/test_client.py +++ b/mergin/test/test_client.py @@ -1058,11 +1058,6 @@ def test_logging(mc): del os.environ["MERGIN_CLIENT_LOG"] -def test_server_compatibility(mc): - """Test server compatibility.""" - assert mc.is_server_compatible() - - def create_versioned_project(mc, project_name, project_dir, updated_file, remove=True, overwrite=False): project = API_USER + "/" + project_name cleanup(mc, project, [project_dir])