-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2062267
commit 1598054
Showing
4 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,7 @@ def test_2sa_required_email_notification(self): | |
"[email protected]", "password1" | ||
) | ||
smtp_instance.sendmail.assert_called_once_with( | ||
"[email protected]", | ||
"iCloud Photos Downloader <[email protected]>", | ||
"[email protected]", | ||
"From: iCloud Photos Downloader <[email protected]>\n" | ||
"To: [email protected]\n" | ||
|
@@ -98,7 +98,7 @@ def test_2sa_notification_without_smtp_login_and_tls(self): | |
smtp_instance.sendmail.assert_called_once_with( | ||
"[email protected]", | ||
"[email protected]", | ||
"From: iCloud Photos Downloader <[email protected]>\n" | ||
"From: [email protected]\n" | ||
"To: [email protected]\n" | ||
"Subject: icloud_photos_downloader: Two step authentication has expired\n" | ||
"Date: 01/01/2018 00:00\n\nHello,\n\n" | ||
|
@@ -136,3 +136,56 @@ def test_2sa_required_notification_script(self): | |
print(result.output) | ||
assert result.exit_code == 1 | ||
subprocess_patched.assert_called_once_with(["./test_script.sh"]) | ||
|
||
@freeze_time("2018-01-01") | ||
def test_2sa_required_email_notification_from(self): | ||
base_dir = os.path.normpath(f"tests/fixtures/Photos/{inspect.stack()[0][3]}") | ||
if os.path.exists(base_dir): | ||
shutil.rmtree(base_dir) | ||
os.makedirs(base_dir) | ||
|
||
with vcr.use_cassette("tests/vcr_cassettes/auth_requires_2sa.yml"): | ||
with patch("smtplib.SMTP") as smtp: | ||
# Pass fixed client ID via environment variable | ||
runner = CliRunner(env={ | ||
"CLIENT_ID": "EC5646DE-9423-11E8-BF21-14109FE0B321" | ||
}) | ||
result = runner.invoke( | ||
main, | ||
[ | ||
"--username", | ||
"[email protected]", | ||
"--password", | ||
"password1", | ||
"--smtp-username", | ||
"[email protected]", | ||
"--smtp-password", | ||
"password1", | ||
"--notification-email", | ||
"JD <[email protected]>", | ||
"--notification-email-from", | ||
"JD <[email protected]>", | ||
"-d", | ||
base_dir, | ||
], | ||
) | ||
print(result.output) | ||
assert result.exit_code == 1 | ||
smtp_instance = smtp() | ||
smtp_instance.connect.assert_called_once() | ||
smtp_instance.starttls.assert_called_once() | ||
smtp_instance.login.assert_called_once_with( | ||
"[email protected]", "password1" | ||
) | ||
smtp_instance.sendmail.assert_called_once_with( | ||
"JD <[email protected]>", | ||
"JD <[email protected]>", | ||
"From: JD <[email protected]>\n" | ||
"To: JD <[email protected]>\n" | ||
"Subject: icloud_photos_downloader: Two step authentication has expired\n" | ||
"Date: 01/01/2018 00:00\n\nHello,\n\n" | ||
"Two-step authentication has expired for the icloud_photos_downloader script.\n" | ||
"Please log in to your server and run the script manually to update two-step " | ||
"authentication.", | ||
) | ||
|