forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1575974 - Add tests for pingsender url parsing r=gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D44706 --HG-- extra : moz-landing-system : lando
- Loading branch information
1 parent
f1f1522
commit 6ba4898
Showing
2 changed files
with
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,24 @@ add_task(async function test_pingSender() { | |
|
||
// Try to send it using the pingsender. | ||
const url = "http://localhost:" + PingServer.port + "/submit/telemetry/"; | ||
TelemetrySend.testRunPingSender(url, pingPath); | ||
TelemetrySend.testRunPingSender(url, pingPath, (_, topic, __) => { | ||
switch (topic) { | ||
case "process-finished": // finished indicates an exit code of 0 | ||
Assert.equal( | ||
true, | ||
true, | ||
"Pingsender should be able to post to localhost" | ||
); | ||
break; | ||
case "process-failed": // failed indicates an exit code != 0 | ||
Assert.equal( | ||
true, | ||
false, | ||
"Pingsender should be able to post to localhost" | ||
); | ||
break; | ||
} | ||
}); | ||
|
||
let req = await PingServer.promiseNextRequest(); | ||
let ping = decodeRequestPayload(req); | ||
|
@@ -132,6 +149,42 @@ add_task(async function test_pingSender() { | |
// Check that the PingSender removed the pending ping. | ||
await waitForPingDeletion(data.id); | ||
|
||
// Confirm we can't send a ping to another destination url | ||
let bannedUris = [ | ||
"https://example.com", | ||
"http://localhost.com", | ||
"http://localHOST.com", | ||
"http://[email protected]", | ||
"http://localhost:[email protected]", | ||
"http://localhost:[email protected]", | ||
]; | ||
for (let indx in bannedUris) { | ||
TelemetrySend.testRunPingSender( | ||
bannedUris[indx], | ||
pingPath, | ||
(_, topic, __) => { | ||
switch (topic) { | ||
case "process-finished": // finished indicates an exit code of 0 | ||
Assert.equal( | ||
false, | ||
true, | ||
"Pingsender should not be able to post to any banned urls: " + | ||
bannedUris[indx] | ||
); | ||
break; | ||
case "process-failed": // failed indicates an exit code != 0 | ||
Assert.equal( | ||
true, | ||
true, | ||
"Pingsender should not be able to post to any banned urls: " + | ||
bannedUris[indx] | ||
); | ||
break; | ||
} | ||
} | ||
); | ||
} | ||
|
||
// Shut down the failing server. We do this now, and not right after using it, | ||
// to make sure we're not interfering with the test. | ||
await new Promise(r => failingServer.stop(r)); | ||
|