-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix IMAP identifiers not encoding correctly (#383)
IMAP identifiers sometimes have characters that do not work well in the URL, including slashes, that would make the request fail. For these endpoints we ensure that we are encoding these IDs properly.
- Loading branch information
1 parent
6955356
commit 9c8cead
Showing
7 changed files
with
206 additions
and
10 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
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 |
---|---|---|
|
@@ -106,6 +106,23 @@ def test_find_draft(self, http_client_response): | |
overrides=None, | ||
) | ||
|
||
def test_find_draft_encoded_id(self, http_client_response): | ||
drafts = Drafts(http_client_response) | ||
|
||
drafts.find( | ||
identifier="abc-123", | ||
draft_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
) | ||
|
||
http_client_response._execute.assert_called_once_with( | ||
"GET", | ||
"/v3/grants/abc-123/drafts/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
None, | ||
overrides=None, | ||
) | ||
|
||
def test_create_draft(self, http_client_response): | ||
drafts = Drafts(http_client_response) | ||
request_body = { | ||
|
@@ -206,6 +223,30 @@ def test_update_draft(self, http_client_response): | |
overrides=None, | ||
) | ||
|
||
def test_update_draft_encoded_id(self, http_client_response): | ||
drafts = Drafts(http_client_response) | ||
request_body = { | ||
"subject": "Hello from Nylas!", | ||
"to": [{"name": "Jon Snow", "email": "[email protected]"}], | ||
"cc": [{"name": "Arya Stark", "email": "[email protected]"}], | ||
"body": "This is the body of my draft message.", | ||
} | ||
|
||
drafts.update( | ||
identifier="abc-123", | ||
draft_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
request_body=request_body, | ||
) | ||
|
||
http_client_response._execute.assert_called_once_with( | ||
"PUT", | ||
"/v3/grants/abc-123/drafts/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
request_body, | ||
overrides=None, | ||
) | ||
|
||
def test_update_draft_small_attachment(self, http_client_response): | ||
drafts = Drafts(http_client_response) | ||
request_body = { | ||
|
@@ -282,6 +323,23 @@ def test_destroy_draft(self, http_client_delete_response): | |
overrides=None, | ||
) | ||
|
||
def test_destroy_draft_encoded_id(self, http_client_delete_response): | ||
drafts = Drafts(http_client_delete_response) | ||
|
||
drafts.destroy( | ||
identifier="abc-123", | ||
draft_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
) | ||
|
||
http_client_delete_response._execute.assert_called_once_with( | ||
"DELETE", | ||
"/v3/grants/abc-123/drafts/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
None, | ||
overrides=None, | ||
) | ||
|
||
def test_send_draft(self, http_client_response): | ||
drafts = Drafts(http_client_response) | ||
|
||
|
@@ -290,3 +348,17 @@ def test_send_draft(self, http_client_response): | |
http_client_response._execute.assert_called_once_with( | ||
method="POST", path="/v3/grants/abc-123/drafts/draft-123", overrides=None | ||
) | ||
|
||
def test_send_draft_encoded_id(self, http_client_response): | ||
drafts = Drafts(http_client_response) | ||
|
||
drafts.send( | ||
identifier="abc-123", | ||
draft_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
) | ||
|
||
http_client_response._execute.assert_called_once_with( | ||
method="POST", | ||
path="/v3/grants/abc-123/drafts/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
overrides=None, | ||
) |
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 |
---|---|---|
|
@@ -109,6 +109,23 @@ def test_find_message(self, http_client_response): | |
overrides=None, | ||
) | ||
|
||
def test_find_message_encoded_id(self, http_client_response): | ||
messages = Messages(http_client_response) | ||
|
||
messages.find( | ||
identifier="abc-123", | ||
message_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
) | ||
|
||
http_client_response._execute.assert_called_once_with( | ||
"GET", | ||
"/v3/grants/abc-123/messages/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
None, | ||
overrides=None, | ||
) | ||
|
||
def test_find_message_with_query_params(self, http_client_response): | ||
messages = Messages(http_client_response) | ||
|
||
|
@@ -151,6 +168,30 @@ def test_update_message(self, http_client_response): | |
overrides=None, | ||
) | ||
|
||
def test_update_message_encoded_id(self, http_client_response): | ||
messages = Messages(http_client_response) | ||
request_body = { | ||
"starred": True, | ||
"unread": False, | ||
"folders": ["folder-123"], | ||
"metadata": {"foo": "bar"}, | ||
} | ||
|
||
messages.update( | ||
identifier="abc-123", | ||
message_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
request_body=request_body, | ||
) | ||
|
||
http_client_response._execute.assert_called_once_with( | ||
"PUT", | ||
"/v3/grants/abc-123/messages/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
request_body, | ||
overrides=None, | ||
) | ||
|
||
def test_destroy_message(self, http_client_delete_response): | ||
messages = Messages(http_client_delete_response) | ||
|
||
|
@@ -165,6 +206,23 @@ def test_destroy_message(self, http_client_delete_response): | |
overrides=None, | ||
) | ||
|
||
def test_destroy_message_encoded_id(self, http_client_delete_response): | ||
messages = Messages(http_client_delete_response) | ||
|
||
messages.destroy( | ||
identifier="abc-123", | ||
message_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
) | ||
|
||
http_client_delete_response._execute.assert_called_once_with( | ||
"DELETE", | ||
"/v3/grants/abc-123/messages/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
None, | ||
overrides=None, | ||
) | ||
|
||
def test_send_message(self, http_client_response): | ||
messages = Messages(http_client_response) | ||
request_body = { | ||
|
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 |
---|---|---|
|
@@ -161,6 +161,23 @@ def test_find_thread(self, http_client_response): | |
overrides=None, | ||
) | ||
|
||
def test_find_thread_encoded_id(self, http_client_response): | ||
threads = Threads(http_client_response) | ||
|
||
threads.find( | ||
identifier="abc-123", | ||
thread_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
) | ||
|
||
http_client_response._execute.assert_called_once_with( | ||
"GET", | ||
"/v3/grants/abc-123/threads/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
None, | ||
overrides=None, | ||
) | ||
|
||
def test_update_thread(self, http_client_response): | ||
threads = Threads(http_client_response) | ||
request_body = { | ||
|
@@ -182,6 +199,29 @@ def test_update_thread(self, http_client_response): | |
overrides=None, | ||
) | ||
|
||
def test_update_thread_encoded_id(self, http_client_response): | ||
threads = Threads(http_client_response) | ||
request_body = { | ||
"starred": True, | ||
"unread": False, | ||
"folders": ["folder-123"], | ||
} | ||
|
||
threads.update( | ||
identifier="abc-123", | ||
thread_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
request_body=request_body, | ||
) | ||
|
||
http_client_response._execute.assert_called_once_with( | ||
"PUT", | ||
"/v3/grants/abc-123/threads/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
request_body, | ||
overrides=None, | ||
) | ||
|
||
def test_destroy_thread(self, http_client_delete_response): | ||
threads = Threads(http_client_delete_response) | ||
|
||
|
@@ -195,3 +235,20 @@ def test_destroy_thread(self, http_client_delete_response): | |
None, | ||
overrides=None, | ||
) | ||
|
||
def test_destroy_thread_encode_id(self, http_client_delete_response): | ||
threads = Threads(http_client_delete_response) | ||
|
||
threads.destroy( | ||
identifier="abc-123", | ||
thread_id="<!&!AAAAAAAAAAAuAAAAAAAAABQ/wHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ/T4N/[email protected]>", | ||
) | ||
|
||
http_client_delete_response._execute.assert_called_once_with( | ||
"DELETE", | ||
"/v3/grants/abc-123/threads/%3C%21%26%21AAAAAAAAAAAuAAAAAAAAABQ%2FwHZyqaNCptfKg5rnNAoBAMO2jhD3dRHOtM0AqgC7tuYAAAAAAA4AABAAAACTn3BxdTQ%2FT4N%2F0BgqPmf%2BAQAAAAA%3D%40example.com%3E", | ||
None, | ||
None, | ||
None, | ||
overrides=None, | ||
) |