Skip to content
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

fix listing tests to use stored auth #973

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
6 changes: 5 additions & 1 deletion tests/test_listing_albums.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import glob
import inspect
import os
import shutil
from unittest import TestCase

import pytest
Expand All @@ -25,10 +26,13 @@ def test_listing_albums(self) -> None:
base_dir = os.path.join(self.fixtures_path, inspect.stack()[0][3])
cookie_dir = os.path.join(base_dir, "cookie")
data_dir = os.path.join(base_dir, "data")
cookie_master_path = os.path.join(self.root_path, "cookie")

for dir in [base_dir, cookie_dir, data_dir]:
for dir in [base_dir, data_dir]:
recreate_path(dir)

shutil.copytree(cookie_master_path, cookie_dir)

with vcr.use_cassette(os.path.join(self.vcr_path, "listing_albums.yml")):
# Pass fixed client ID via environment variable
runner = CliRunner(env={"CLIENT_ID": "DE309E26-942E-11E8-92F5-14109FE0B321"})
Expand Down
11 changes: 9 additions & 2 deletions tests/test_listing_libraries.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import inspect
import os
import shutil
from unittest import TestCase

import pytest
Expand All @@ -23,10 +24,13 @@ def inject_fixtures(self, caplog: pytest.LogCaptureFixture) -> None:
def test_listing_library(self) -> None:
base_dir = os.path.join(self.fixtures_path, inspect.stack()[0][3])
cookie_dir = os.path.join(base_dir, "cookie")
cookie_master_path = os.path.join(self.root_path, "cookie")

for dir in [base_dir, cookie_dir]:
for dir in [base_dir]:
recreate_path(dir)

shutil.copytree(cookie_master_path, cookie_dir)

with vcr.use_cassette(os.path.join(self.vcr_path, "listing_albums.yml")):
# Pass fixed client ID via environment variable
runner = CliRunner(env={"CLIENT_ID": "DE309E26-942E-11E8-92F5-14109FE0B321"})
Expand Down Expand Up @@ -56,10 +60,13 @@ def test_listing_library_error(self) -> None:
base_dir = os.path.join(self.fixtures_path, inspect.stack()[0][3])
cookie_dir = os.path.join(base_dir, "cookie")
data_dir = os.path.join(base_dir, "data")
cookie_master_path = os.path.join(self.root_path, "cookie")

for dir in [base_dir, cookie_dir, data_dir]:
for dir in [base_dir, data_dir]:
recreate_path(dir)

shutil.copytree(cookie_master_path, cookie_dir)

with vcr.use_cassette(os.path.join(self.vcr_path, "listing_albums.yml")):
# Pass fixed client ID via environment variable
runner = CliRunner(env={"CLIENT_ID": "DE309E26-942E-11E8-92F5-14109FE0B321"})
Expand Down
90 changes: 22 additions & 68 deletions tests/vcr_cassettes/listing_albums.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,34 @@
interactions:
- request:
body: !!python/unicode '{"accountName": "[email protected]", "password": "password1",
"rememberMe": true, "trustTokens": []}'
body: 'null'
headers:
Accept: ['*/*']
Accept-Encoding: ['gzip, deflate']
Connection: ['keep-alive']
Content-Length: ['111']
Content-Type: ['application/json']
Origin: ['https://www.icloud.com']
Referer: ['https://www.icloud.com/']
User-Agent: ['Opera/9.52 (X11; Linux i686; U; en)']
X-Apple-OAuth-Client-Id: ['d39ba9916b7251055b22c7f910e2ea796ee65e98b2ddecea8f5dde8d9d1a815d']
X-Apple-OAuth-Client-Type: ['firstPartyAuth']
X-Apple-OAuth-Redirect-URI: ['https://www.icloud.com']
X-Apple-OAuth-Require-Grant-Code: ['true']
X-Apple-OAuth-Response-Mode: ['web_message']
X-Apple-OAuth-Response-Type: ['code']
X-Apple-OAuth-State: ['DE309E26-942E-11E8-92F5-14109FE0B321']
X-Apple-Widget-Key: ['d39ba9916b7251055b22c7f910e2ea796ee65e98b2ddecea8f5dde8d9d1a815d']
method: POST
uri: https://idmsa.apple.com/appleauth/auth/signin?isRememberMeEnabled=true
response:
body:
string: !!python/unicode '{}'
headers:
Cache-Control:
- 'no-cache'
- 'no-store'
Connection: ['keep-alive']
Content-Type: ['text/html;charset=UTF-8']
Date: ['Wed, 13 Dec 2023 05:06:31 GMT']
Location: ['/auth']
Pragma: ['no-cache']
Referrer-Policy: ['origin']
Server: ['Apple']
Strict-Transport-Security: ['max-age=31536000; includeSubDomains; preload']
Transfer-Encoding: ['chunked']
X-Apple-Auth-Attributes: ['123456789abcdefg']
X-Apple-I-Request-ID: ['12345678-1234-1234-1234-123456789012']
X-Apple-I-Rscd: ['409']
X-Apple-ID-Account-Country: ['USA']
X-Apple-ID-Session-Id: ['sess-1234567890']
X-Apple-Session-Token: ['token-1234567890']
X-Apple-TwoSV-Trust-Eligible: ['true']
X-BuildVersion: ['R4_1']
content-length: ['23705']
scnt: ['scnt-1234567890']
vary: ['accept-encoding']
status:
code: 200
message: ''
- request:
body: !!python/unicode '{"accountCountryCode": "USA", "dsWebAuthToken": "token-1234567890", "extended_login": true, "trustToken": ""}'
headers:
Accept:
- '*/*'
Accept-Encoding: ['gzip, deflate']
Connection: ['keep-alive']
Content-Length: ['1157']
Content-Length: ['4']
Cookie:
- X-APPLE-UNIQUE-CLIENT-ID="EQ=="; X-APPLE-WEBAUTH-VALIDATE="v=1:t=EQ==BST_IAAAAAAABL-1234567890~";
X-APPLE-WEBAUTH-USER="v=1:s=1:d=12345678901"; X_APPLE_WEB_KB-A0OXAM_WG97BH5FBDJFP8-DKXTW="v=1:t=EQ==BST_IAAAAAAABL-1234567890~";
X-APPLE-DS-WEB-SESSION-TOKEN="websessiontoken-1234567890=";
X-APPLE-WEBAUTH-TOKEN="v=2:t=EQ==BST_IAAAAAAABL-1234567890~";
X-APPLE-WEBAUTH-HSA-TRUST-A0OXAM_WG97BH5FBDJFP8-DKXTW="v=1:t=EQ==BST_IAAAAAAABL-1234567890~";
X-APPLE-WEBAUTH-PCS-Documents="pcsdocs-1234567890=";
X-APPLE-WEBAUTH-PCS-News="pcsnews-1234567890=";
X-APPLE-WEBAUTH-PCS-Notes="pcsnotes-1234567890=";
X-APPLE-WEBAUTH-PCS-Sharing="pcssharing-1234567890=";
Origin: ['https://www.icloud.com']
Referer: ['https://www.icloud.com/']
User-Agent: ['Opera/9.52 (X11; Linux i686; U; en)']
method: POST
uri: https://setup.icloud.com/setup/ws/1/accountLogin
uri: https://setup.icloud.com/setup/ws/1/validate
response:
body:
string: !!python/unicode '{"dsInfo": {"lastName":"Doe","iCDPEnabled":false,"tantorMigrated":false,"dsid":"12345678901","hsaEnabled":true,
"ironcadeMigrated":true,"locale":"en-us_US","brZoneConsolidated":false,"ICDRSCapableDeviceList":"","isManagedAppleID":false,
"isCustomDomainsFeatureAvailable":true,"isHideMyEmailFeatureAvailable":true,"ContinueOnDeviceEligibleDeviceInfo":[],"gilligan-invited":true,
"appleIdAliases":[],"hsaVersion":2,"ubiquityEOLEnabled":true,"isPaidDeveloper":false,"countryCode":"USA","notificationId":"12341234-1234-12341234-1234",
"appleIdAliases":[],"hsaVersion":1,"ubiquityEOLEnabled":true,"isPaidDeveloper":false,"countryCode":"USA","notificationId":"12341234-1234-12341234-1234",
"primaryEmailVerified":true,"aDsID":"123456-12-12345678-1234-1234-1234-123456789012","locked":false,"ICDRSCapableDeviceCount":0,
"hasICloudQualifyingDevice":true,"primaryEmail":"[email protected]","appleIdEntries": [{"isPrimary":true,"type":"EMAIL","value":"[email protected]"}],
"hasICloudQualifyingDevice":false,"primaryEmail":"[email protected]","appleIdEntries": [{"isPrimary":true,"type":"EMAIL","value":"[email protected]"}],
"gilligan-enabled":true,"isWebAccessAllowed":true,"fullName":"John Doe","mailFlags":{"isThreadingAvailable":false,"isSearchV2Provisioned":false,
"rawBits":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
"isCKMail":false,"isMppSupportedInCurrentCountry":true},"languageCode":"en-us","appleId":"[email protected]","analyticsOptInStatus":false,
Expand Down Expand Up @@ -118,16 +75,13 @@ interactions:
Date: ['Wed, 13 Dec 2023 05:06:31 GMT']
Server: ['AppleHttpServer/78689afb4479']
Set-Cookie:
- 'X-APPLE-UNIQUE-CLIENT-ID="Cw==";Path=/;Domain=.icloud.com;Secure'
- 'X-APPLE-WEBAUTH-LOGIN="v=1:t=Cw==BST_IAAAAAAABLw1234~~";Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-WEBAUTH-VALIDATE="v=1:t=Cw==BST_IAAAAAAABLw5678~~";Path=/;Domain=.icloud.com;Secure'
- 'X-APPLE-WEBAUTH-HSA-LOGIN="v=2:t=Cw==BST_IAAAAAAABLw9012~~";Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-WEBAUTH-USER="v=1:s=1:d=12345678901";Expires=Fri, 12-Jan-2024 05:06:31
GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X_APPLE_WEB_KB-ONHCNAXFAIPPFDMR5UZVNO6NIMY="v=1:t=Cw==BST_IAAAAAAABLw3456~~";Expires=Sun,
11-Feb-2024 05:06:31 GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-DS-WEB-SESSION-TOKEN="websessiontoken1234567890=";Expires=Fri,
12-Jan-2024 05:06:31 GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-WEBAUTH-PCS-Documents="pcsdocs-1234567890=";Expires=Tue,16-Jan-2024 02:07:19 GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-WEBAUTH-PCS-News="pcsnews-1234567890=";Expires=Tue,16-Jan-2024 02:07:19 GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-WEBAUTH-PCS-Notes="pcsnotes-1234567890=";Expires=Tue,16-Jan-2024 02:07:19 GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-WEBAUTH-PCS-Sharing="pcssharing-1234567890=";Expires=Tue,16-Jan-2024 02:07:19 GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-WEBAUTH-VALIDATE="v=1:t=EQ==BST_IAAAAAAABL-1234567890~~";Path=/;Domain=.icloud.com;Secure'
- 'X-APPLE-WEBAUTH-TOKEN="v=2:t=EQ==BST_IAAAAAAABL-1234567890~~";Expires=Tue,16-Jan-2024 02:07:19 GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
- 'X-APPLE-DS-WEB-SESSION-TOKEN="websessiontoken-1234567890=";Expires=Tue,16-Jan-2024 02:07:19 GMT;Path=/;Domain=.icloud.com;Secure;HttpOnly'
Strict-Transport-Security: ['max-age=31536000; includeSubDomains']
X-Apple-Edge-Response-Time: ['501']
X-Apple-Request-UUID: ['12345678-1234-1234-1234-123456789012']
Expand Down
Loading