Skip to content

Remove deprecated check for server compatibility via the list of endpoints #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions mergin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
46 changes: 0 additions & 46 deletions mergin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions mergin/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Loading