-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate before calling approve. some test changes
- Loading branch information
1 parent
ccdc050
commit d03889a
Showing
5 changed files
with
63 additions
and
56 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 |
---|---|---|
|
@@ -73,10 +73,10 @@ describe('assertValidSender', () => { | |
expect(() => assertValidSender(unparseableOrigin)).toThrow('Invalid URL'); | ||
}); | ||
|
||
it('throws if sender origin contains unexpanded unicode', () => { | ||
it("throws if sender origin can't roundtrip", () => { | ||
const invalidOrigin: chrome.runtime.MessageSender = { | ||
...mockValid, | ||
// cyrillic 'а' instead of latin 'a' in origin | ||
// cyrillic lookalike for latin 'a' in hostname | ||
origin: 'https://exаmple.com', | ||
}; | ||
expect(() => assertValidSender(invalidOrigin)).toThrow('Sender origin is invalid'); | ||
|
@@ -85,7 +85,7 @@ describe('assertValidSender', () => { | |
it('throws if sender origin contains path', () => { | ||
const invalidOrigin: chrome.runtime.MessageSender = { | ||
...mockValid, | ||
// trailing slash is path, not origin | ||
// trailing slash is a path, not part of an origin | ||
origin: 'https://example.com/', | ||
}; | ||
expect(() => assertValidSender(invalidOrigin)).toThrow('Sender origin is invalid'); | ||
|
@@ -107,28 +107,39 @@ describe('assertValidSender', () => { | |
expect(() => assertValidSender(urlless)).toThrow('Sender has no URL'); | ||
}); | ||
|
||
it('throws if sender URL contains unencoded special characters', () => { | ||
it("throws if sender URL can't roundtrip", () => { | ||
const invalidUrl: chrome.runtime.MessageSender = { | ||
...mockValid, | ||
url: 'https://example.com/some/p th', | ||
// unicode RTL override in URL | ||
origin: 'https://example.invalid', | ||
url: 'https://sdrawkcab%[email protected]/', | ||
}; | ||
expect(() => assertValidSender(invalidUrl)).toThrow('Sender URL is invalid'); | ||
}); | ||
|
||
it('throws if sender URL contains unexpanded unicode', () => { | ||
const invalidUrl: chrome.runtime.MessageSender = { | ||
it('throws if sender URL has unexpected host', () => { | ||
const different: chrome.runtime.MessageSender = { | ||
...mockValid, | ||
// cyrillic 'а' instead of latin 'a' in path | ||
url: 'https://example.com/some/pаth', | ||
origin: 'https://example.com', | ||
url: 'https://example.net/some/path', | ||
}; | ||
expect(() => assertValidSender(invalidUrl)).toThrow('Sender URL is invalid'); | ||
expect(() => assertValidSender(different)).toThrow('Sender URL has unexpected origin'); | ||
}); | ||
|
||
it('throws if sender URL has unexpected origin', () => { | ||
it('throws if sender URL has unexpected port', () => { | ||
const different: chrome.runtime.MessageSender = { | ||
...mockValid, | ||
origin: 'https://example.com', | ||
url: 'https://example.net/some/path', | ||
url: 'https://example.com:123/some/path', | ||
}; | ||
expect(() => assertValidSender(different)).toThrow('Sender URL has unexpected origin'); | ||
}); | ||
|
||
it('throws if sender URL is missing expected port', () => { | ||
const different: chrome.runtime.MessageSender = { | ||
...mockValid, | ||
origin: 'https://example.com:999', | ||
url: 'https://example.com/some/path', | ||
}; | ||
expect(() => assertValidSender(different)).toThrow('Sender URL has unexpected origin'); | ||
}); | ||
|
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