-
Notifications
You must be signed in to change notification settings - Fork 0
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
7b4631a
commit 6b899f6
Showing
4 changed files
with
130 additions
and
2 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
86 changes: 86 additions & 0 deletions
86
tests/cassettes/test_unshorten/test_resolve_to_mailto.yaml
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
interactions: | ||
- request: | ||
body: null | ||
headers: | ||
Connection: | ||
- keep-alive | ||
accept: | ||
- text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7 | ||
accept-encoding: | ||
- gzip, deflate, br | ||
accept-language: | ||
- en-US,en;q=0.9 | ||
sec-fetch-dest: | ||
- document | ||
sec-fetch-mode: | ||
- navigate | ||
sec-fetch-site: | ||
- same-origin | ||
sec-fetch-user: | ||
- ?1 | ||
upgrade-insecure-requests: | ||
- "1" | ||
user-agent: | ||
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, | ||
like Gecko) Chrome/120.0.0.0 Safari/537.36 | ||
method: HEAD | ||
uri: https://tinyurl.com/NewwAlemAndKibrom | ||
response: | ||
body: | ||
string: "" | ||
headers: | ||
Age: | ||
- "91" | ||
CF-Cache-Status: | ||
- HIT | ||
CF-RAY: | ||
- 84d7aa147efb2250-ORD | ||
Cache-Control: | ||
- max-age=0, must-revalidate, no-cache, no-store, private | ||
Connection: | ||
- keep-alive | ||
Content-Type: | ||
- text/html; charset=UTF-8 | ||
Date: | ||
- Tue, 30 Jan 2024 06:30:06 GMT | ||
Server: | ||
- cloudflare | ||
Set-Cookie: | ||
- __cf_bm=HHnO7O4fh0yGvqK8S1LWskI95._Xi27rdn44ju2bTvk-1706596206-1-AQxnL797yvOvr/S4cjrLvJTUhDfWTUvW0vnP7xTfrjtXGlH9j1J85KwbIBznkJpEPAnf5wCA9xhHwXaVPGDK//U=; | ||
path=/; expires=Tue, 30-Jan-24 07:00:06 GMT; domain=.tinyurl.com; HttpOnly; | ||
Secure; SameSite=None | ||
Strict-Transport-Security: | ||
- max-age=31536000; includeSubDomains; preload | ||
Vary: | ||
- Accept-Encoding | ||
alt-svc: | ||
- h3=":443"; ma=86400 | ||
location: | ||
- mailto:[email protected], [email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], [email protected], | ||
[email protected], [email protected], [email protected], [email protected], | ||
[email protected]?subject=URGENT%20CALL%20TO%20ACTION%3A%20Save%20Alem%20and%20Kibrom's%20lives&body=To%20Whom%20it%20May%20Concern%3A%0A%0AAlem%20Tesfay%20Abraham%20and%20Kibrom%20Adhanom%20Okbazghi%20are%20two%20Eritrean%20asylum-seekers%20who%20have%20been%20detained%20without%20charge%20in%20Egypt%20since%202012%20and%202014%2C%20respectively.%20They%20now%20are%20facing%20deportation%20to%20Eritrea%20without%20ever%20receiving%20the%20opportunity%20to%20register%20as%20refugees%20with%20UNHCR%20in%20Egypt.%20On%209%20September%2C%20they%20were%20taken%20from%20prison%20to%20a%20hospital%20in%20Cairo%20to%20take%20PCR%20tests%20and%20were%20informed%20by%20a%20prison%20official%20that%20they%20would%20be%20deported%20to%20Eritrea%20on%20the%20oncoming%20days.%0A%0AForcibly%20returning%20Alem%20and%20Kibrom%20to%20Eritrea%2C%20where%20they%20fled%20indefinite%20military%20conscription%20and%20where%20they%20would%20face%20persecution%2C%20is%20a%20grave%20breach%20of%20international%20law.%20Eritrean%20asylum-seekers%20who%20are%20forcibly%20returned%20to%20Eritrea%20risk%20arbitrary%20arrest%2C%20forced%20disappearance%20and%20indefinite%20detention%20without%20charges.%20As%20widely%20documented%20by%20many%20NGOs%20as%20well%20as%20the%20UN%20Human%20Rights%20Council%2C%20citizens%20in%20Eritrea%20are%20held%20in%20prisons%20incommunicado%2C%20in%20unsanitary%20living%20conditions%2C%20where%20torture%20and%20other%20ill%20treatments%20are%20taking%20place%20to%20present.%0A%0AForcing%20Alem%20and%20Kibrom%20back%20to%20the%20nation%20they%20are%20seeking%20asylum%20from%20violates%20the%201951%20Convention%20and%201967%20Protocol%2C%20two%20International%20Laws%20Egypt%20has%20agreed%20to.%20They%20deserve%20the%20right%20to%20be%20resettled%20by%20will%2C%20to%20a%20country%20willing%20to%20accept%20them.%20We%20urge%20you%2C%20the%20Egyptian%20authorities%2C%20and%20all%20other%20relevant%20bodies%2C%20to%20help%20stop%20the%20forced%20repatriation%20of%20Alem%20and%20Kibrom%20and%20protect%20them%20from%20persecution%20and%20grant%20them%20their%20long-awaited%20freedom.%20%0A%0A%23JusticeforAlemAndKibrom%0A%0ASincerely%2C | ||
referrer-policy: | ||
- unsafe-url | ||
x-content-type-options: | ||
- nosniff | ||
x-robots-tag: | ||
- noindex | ||
x-tinyurl-redirect: | ||
- eyJpdiI6IllkK3R1Mm5HM2dDOTNCd1VFS2lOSlE9PSIsInZhbHVlIjoia2lhdUZLVU9xY3JGQVJkKzZJTENDeG9qb0hEL1R1ODd1dU5DOFY1Y2piQU0yVFV5cG1xU2lub3NhdTZwd0lTUThhMXJlaEoxNk90aXRzVktWVGhiYkE9PSIsIm1hYyI6IjZmZTFjNzZiY2Q2ZjI3YzM5NjljYmJjNGFhOTIwOWE2OWY1M2QzZTVjZmE2NDhiNjdhOTUyMjBhYzE4Y2ZmOTkiLCJ0YWciOiIifQ== | ||
x-tinyurl-redirect-type: | ||
- redirect | ||
x-xss-protection: | ||
- 1; mode=block | ||
status: | ||
code: 301 | ||
message: Moved Permanently | ||
version: 1 |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import pytest | ||
import requests | ||
|
||
from clean_links.unshorten import unshorten_url | ||
|
||
|
@@ -52,6 +53,30 @@ def test_expired_certificate_ignore(): | |
} | ||
|
||
|
||
@pytest.mark.vcr | ||
def test_resolve_to_mailto(): | ||
url = "https://tinyurl.com/NewwAlemAndKibrom" | ||
result = unshorten_url(url) | ||
print(result) | ||
assert result["url"] == url | ||
assert ( | ||
result["resolved"] | ||
== "mailto:[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected]?subject=URGENT%20CALL%20TO%20ACTION%3A%20Save%20Alem%20and%20Kibrom's%20lives&body=To%20Whom%20it%20May%20Concern%3A%0A%0AAlem%20Tesfay%20Abraham%20and%20Kibrom%20Adhanom%20Okbazghi%20are%20two%20Eritrean%20asylum-seekers%20who%20have%20been%20detained%20without%20charge%20in%20Egypt%20since%202012%20and%202014%2C%20respectively.%20They%20now%20are%20facing%20deportation%20to%20Eritrea%20without%20ever%20receiving%20the%20opportunity%20to%20register%20as%20refugees%20with%20UNHCR%20in%20Egypt.%20On%209%20September%2C%20they%20were%20taken%20from%20prison%20to%20a%20hospital%20in%20Cairo%20to%20take%20PCR%20tests%20and%20were%20informed%20by%20a%20prison%20official%20that%20they%20would%20be%20deported%20to%20Eritrea%20on%20the%20oncoming%20days.%0A%0AForcibly%20returning%20Alem%20and%20Kibrom%20to%20Eritrea%2C%20where%20they%20fled%20indefinite%20military%20conscription%20and%20where%20they%20would%20face%20persecution%2C%20is%20a%20grave%20breach%20of%20international%20law.%20Eritrean%20asylum-seekers%20who%20are%20forcibly%20returned%20to%20Eritrea%20risk%20arbitrary%20arrest%2C%20forced%20disappearance%20and%20indefinite%20detention%20without%20charges.%20As%20widely%20documented%20by%20many%20NGOs%20as%20well%20as%20the%20UN%20Human%20Rights%20Council%2C%20citizens%20in%20Eritrea%20are%20held%20in%20prisons%20incommunicado%2C%20in%20unsanitary%20living%20conditions%2C%20where%20torture%20and%20other%20ill%20treatments%20are%20taking%20place%20to%20present.%0A%0AForcing%20Alem%20and%20Kibrom%20back%20to%20the%20nation%20they%20are%20seeking%20asylum%20from%20violates%20the%201951%20Convention%20and%201967%20Protocol%2C%20two%20International%20Laws%20Egypt%20has%20agreed%20to.%20They%20deserve%20the%20right%20to%20be%20resettled%20by%20will%2C%20to%20a%20country%20willing%20to%20accept%20them.%20We%20urge%20you%2C%20the%20Egyptian%20authorities%2C%20and%20all%20other%20relevant%20bodies%2C%20to%20help%20stop%20the%20forced%20repatriation%20of%20Alem%20and%20Kibrom%20and%20protect%20them%20from%20persecution%20and%20grant%20them%20their%20long-awaited%20freedom.%20%0A%0A%23JusticeforAlemAndKibrom%0A%0ASincerely%2C" | ||
) | ||
assert result["status"] is None | ||
assert ( | ||
result["exception"] | ||
== 'InvalidSchema: No connection adapters were found for "mailto:[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected],%[email protected]?subject=URGENT%20CALL%20TO%20ACTION%3A%20Save%20Alem%20and%20Kibrom\'s%20lives&body=To%20Whom%20it%20May%20Concern%3A%0A%0AAlem%20Tesfay%20Abraham%20and%20Kibrom%20Adhanom%20Okbazghi%20are%20two%20Eritrean%20asylum-seekers%20who%20have%20been%20detained%20without%20charge%20in%20Egypt%20since%202012%20and%202014%2C%20respectively.%20They%20now%20are%20facing%20deportation%20to%20Eritrea%20without%20ever%20receiving%20the%20opportunity%20to%20register%20as%20refugees%20with%20UNHCR%20in%20Egypt.%20On%209%20September%2C%20they%20were%20taken%20from%20prison%20to%20a%20hospital%20in%20Cairo%20to%20take%20PCR%20tests%20and%20were%20informed%20by%20a%20prison%20official%20that%20they%20would%20be%20deported%20to%20Eritrea%20on%20the%20oncoming%20days.%0A%0AForcibly%20returning%20Alem%20and%20Kibrom%20to%20Eritrea%2C%20where%20they%20fled%20indefinite%20military%20conscription%20and%20where%20they%20would%20face%20persecution%2C%20is%20a%20grave%20breach%20of%20international%20law.%20Eritrean%20asylum-seekers%20who%20are%20forcibly%20returned%20to%20Eritrea%20risk%20arbitrary%20arrest%2C%20forced%20disappearance%20and%20indefinite%20detention%20without%20charges.%20As%20widely%20documented%20by%20many%20NGOs%20as%20well%20as%20the%20UN%20Human%20Rights%20Council%2C%20citizens%20in%20Eritrea%20are%20held%20in%20prisons%20incommunicado%2C%20in%20unsanitary%20living%20conditions%2C%20where%20torture%20and%20other%20ill%20treatments%20are%20taking%20place%20to%20present.%0A%0AForcing%20Alem%20and%20Kibrom%20back%20to%20the%20nation%20they%20are%20seeking%20asylum%20from%20violates%20the%201951%20Convention%20and%201967%20Protocol%2C%20two%20International%20Laws%20Egypt%20has%20agreed%20to.%20They%20deserve%20the%20right%20to%20be%20resettled%20by%20will%2C%20to%20a%20country%20willing%20to%20accept%20them.%20We%20urge%20you%2C%20the%20Egyptian%20authorities%2C%20and%20all%20other%20relevant%20bodies%2C%20to%20help%20stop%20the%20forced%20repatriation%20of%20Alem%20and%20Kibrom%20and%20protect%20them%20from%20persecution%20and%20grant%20them%20their%20long-awaited%20freedom.%20%0A%0A%23JusticeforAlemAndKibrom%0A%0ASincerely%2C"' | ||
) | ||
|
||
|
||
# @pytest.mark.vcr | ||
def test_missing_schema(): | ||
url = "I AM NOT AN URL" | ||
with pytest.raises(requests.exceptions.MissingSchema): | ||
unshorten_url(url) | ||
|
||
|
||
# def test_expired_certificate_verify(): | ||
# url = "https://expired.badssl.com/" | ||
# result = unshorten_url(url, verify=True) | ||
|