Browse Source

Fix description comment of _generate_auth_url()

CURA-7427
Kostas Karmas 4 years ago
parent
commit
32efb8d7bb
2 changed files with 11 additions and 8 deletions
  1. 8 5
      cura/OAuth2/AuthorizationService.py
  2. 3 3
      tests/TestOAuth2.py

+ 8 - 5
cura/OAuth2/AuthorizationService.py

@@ -24,7 +24,7 @@ if TYPE_CHECKING:
     from cura.OAuth2.Models import UserProfile, OAuth2Settings
     from UM.Preferences import Preferences
 
-MYCLOUD_LOGOFF = "https://mycloud.ultimaker.com/logoff"
+MYCLOUD_LOGOFF_URL = "https://mycloud.ultimaker.com/logoff"
 
 ##  The authorization service is responsible for handling the login flow,
 #   storing user credentials and providing account information.
@@ -184,14 +184,17 @@ class AuthorizationService:
         If there is a request to force logging out of mycloud in the browser, the link to logoff from mycloud is
         prepended in order to force the browser to logoff from mycloud and then redirect to the authentication url to
         login again. This case is used to sync the accounts between Cura and the browser.
-        :param query_parameters_dict:
-        :param force_browser_logout:
-        :return:
+
+        :param query_parameters_dict: A dictionary with the query parameters to be url encoded and added to the
+                                      authentication link
+        :param force_browser_logout: If True, Cura will prepend the MYCLOUD_LOGOFF_URL link before the authentication
+                                     link to force the a browser logout from mycloud.ultimaker.com
+        :return: The authentication URL, properly formatted and encoded
         """
         auth_url = "{}?{}".format(self._auth_url, urlencode(query_parameters_dict))
         if force_browser_logout:
             # The url after '?next=' should be urlencoded
-            auth_url = "{}?next={}".format(MYCLOUD_LOGOFF, quote_plus(auth_url))
+            auth_url = "{}?next={}".format(MYCLOUD_LOGOFF_URL, quote_plus(auth_url))
         return auth_url
 
     ##  Callback method for the authentication flow.

+ 3 - 3
tests/TestOAuth2.py

@@ -7,7 +7,7 @@ from PyQt5.QtGui import QDesktopServices
 
 from UM.Preferences import Preferences
 from cura.OAuth2.AuthorizationHelpers import AuthorizationHelpers, TOKEN_TIMESTAMP_FORMAT
-from cura.OAuth2.AuthorizationService import AuthorizationService, MYCLOUD_LOGOFF
+from cura.OAuth2.AuthorizationService import AuthorizationService, MYCLOUD_LOGOFF_URL
 from cura.OAuth2.LocalAuthorizationServer import LocalAuthorizationServer
 from cura.OAuth2.Models import OAuth2Settings, AuthenticationResponse, UserProfile
 
@@ -238,7 +238,7 @@ def test__generate_auth_url() -> None:
         "response_type": "code"
     }
     auth_url = authorization_service._generate_auth_url(query_parameters_dict, force_browser_logout = False)
-    assert MYCLOUD_LOGOFF + "?next=" not in auth_url
+    assert MYCLOUD_LOGOFF_URL + "?next=" not in auth_url
 
     auth_url = authorization_service._generate_auth_url(query_parameters_dict, force_browser_logout = True)
-    assert MYCLOUD_LOGOFF + "?next=" in auth_url
+    assert MYCLOUD_LOGOFF_URL + "?next=" in auth_url