Skip to content

Commit

Permalink
cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
matin committed Aug 5, 2023
1 parent 23e9c55 commit 40f7b9a
Show file tree
Hide file tree
Showing 8 changed files with 199 additions and 196 deletions.
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@
"editor.insertSpaces": true,
"editor.detectIndentation": false
},
"python.analysis.typeCheckingMode": "basic"
"python.analysis.typeCheckingMode": "basic",
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
8 changes: 4 additions & 4 deletions garth/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def configure(
self.sess.mount("https://", adapter)

@property
def username(self) -> str | None:
def username(self):
if not self._username:
self._username = self.connectapi(
"/userprofile-service/socialProfile"
Expand All @@ -97,7 +97,7 @@ def request(
referrer: str | bool = False,
headers: dict = {},
**kwargs,
):
) -> Response:
url = f"https://{subdomain}.{self.domain}{path}"
if referrer is True and self.last_resp:
headers["referer"] = self.last_resp.url
Expand All @@ -113,10 +113,10 @@ def request(
self.last_resp.raise_for_status()
return self.last_resp

def get(self, *args, **kwargs):
def get(self, *args, **kwargs) -> Response:
return self.request("GET", *args, **kwargs)

def post(self, *args, **kwargs):
def post(self, *args, **kwargs) -> Response:
return self.request("POST", *args, **kwargs)

def login(self, *args):
Expand Down
7 changes: 3 additions & 4 deletions garth/sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ def login(
embedWidget="true",
gauthHost=SSO,
)
SIGNIN_PARAMS = dict(
id="gauth-widget",
SIGNIN_PARAMS = SSO_EMBED_PARAMS | dict(
gauthHost=SSO_EMBED,
service=SSO_EMBED,
source=SSO_EMBED,
redirectAfterAccountLoginUrl=SSO_EMBED,
redirectAfterAccountCreationUrl=SSO_EMBED,
gauthHost=SSO_EMBED,
)

# Set cookies
Expand Down Expand Up @@ -132,7 +131,7 @@ def handle_mfa(client: "http.Client", signin_params: dict) -> None:
client.post(
"sso",
"/sso/verifyMFA/loginEnterMfaCode",
params=signin_params | dict(embedWidget="true"),
params=signin_params,
referrer=True,
data={
"mfa-code": mfa_code,
Expand Down
2 changes: 1 addition & 1 deletion garth/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.2"
__version__ = "0.4.3"
86 changes: 43 additions & 43 deletions tests/cassettes/test_login_email_password_fail.yaml

Large diffs are not rendered by default.

105 changes: 52 additions & 53 deletions tests/cassettes/test_login_success.yaml

Large diffs are not rendered by default.

178 changes: 89 additions & 89 deletions tests/cassettes/test_login_success_mfa.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/test_sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_login_success(client: Client):
@pytest.mark.vcr
def test_login_success_mfa(monkeypatch, client: Client):
def mock_input(_):
return "327751"
return "671091"

monkeypatch.setattr("builtins.input", mock_input)
oauth1, oauth2 = sso.login(
Expand Down

0 comments on commit 40f7b9a

Please sign in to comment.