File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -146,20 +146,15 @@ def __init__(
146
146
self .opener = urllib .request .build_opener (* handlers , https_handler )
147
147
urllib .request .install_opener (self .opener )
148
148
149
- if login or password :
150
- if login and not password :
151
- raise ClientError ("Unable to log in: no password provided for '{}'" .format (login ))
152
- if password and not login :
153
- raise ClientError ("Unable to log in: password provided but no username/email" )
149
+ if login and not password :
150
+ raise ClientError ("Unable to log in: no password provided for '{}'" .format (login ))
151
+ if password and not login :
152
+ raise ClientError ("Unable to log in: password provided but no username/email" )
154
153
155
- if login and password :
156
- self ._auth_params = {"login" : login , "password" : password }
157
- if not self ._auth_session :
158
- self .login (login , password )
159
-
160
- else :
154
+ if login and password :
155
+ self ._auth_params = {"login" : login , "password" : password }
161
156
if not self ._auth_session :
162
- raise ClientError ( "Unable to log in: no auth token provided for login" )
157
+ self . login ( login , password )
163
158
164
159
def setup_logging (self ):
165
160
"""Setup Mergin Maps client logging."""
Original file line number Diff line number Diff line change @@ -2871,3 +2871,18 @@ def server_config(self):
2871
2871
2872
2872
with pytest .raises (ClientError , match = "The requested URL was not found on the server" ):
2873
2873
mc .send_logs (logs_path )
2874
+
2875
+
2876
+ def test_mc_without_login ():
2877
+
2878
+ # client without login should be able to access server config
2879
+ mc = MerginClient (SERVER_URL )
2880
+ config = mc .server_config ()
2881
+ assert config
2882
+ assert isinstance (config , dict )
2883
+ assert "server_configured" in config
2884
+ assert config ["server_configured" ]
2885
+
2886
+ # without login should not be able to access workspaces
2887
+ with pytest .raises (ClientError , match = "Authentication information is missing or invalid." ):
2888
+ mc .workspaces_list ()
You can’t perform that action at this time.
0 commit comments