Bug 1384509 - Test replacing *_API_KEY variables in URLs using the URL formatter and test trimming sensitive URLs. r=mossop
authorMarco Castelluccio <mcastelluccio@mozilla.com>
Fri, 28 Jul 2017 10:14:57 +0200
changeset 420410 9a61373374162e4698536f95c2245834a1c7b098
parent 420409 0a8da9b73bc8da062fdf28b632ee0bd71db773d9
child 420411 e956fb49c3019b5ea1c1dd628d891bd374c9da88
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1384509
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1384509 - Test replacing *_API_KEY variables in URLs using the URL formatter and test trimming sensitive URLs. r=mossop
toolkit/components/urlformatter/tests/unit/test_urlformatter.js
--- a/toolkit/components/urlformatter/tests/unit/test_urlformatter.js
+++ b/toolkit/components/urlformatter/tests/unit/test_urlformatter.js
@@ -52,9 +52,17 @@ function run_test() {
   do_check_eq(formatter.formatURLPref(pref), ulUrlRef);
   // Keys must be uppercase
   do_check_neq(formatter.formatURL(lowerUrlRaw), ulUrlRef);
   do_check_eq(formatter.formatURL(multiUrl), multiUrlRef);
   // Encoded strings must be kept as is (Bug 427304)
   do_check_eq(formatter.formatURL(encodedUrl), encodedUrlRef);
 
   do_check_eq(formatter.formatURL(advancedUrl), advancedUrlRef);
+
+  for (let val of ["MOZILLA_API_KEY", "GOOGLE_API_KEY", "BING_API_CLIENTID", "BING_API_KEY"]) {
+    let url = "http://test.mozilla.com/?val=%" + val + "%";
+    do_check_neq(formatter.formatURL(url), url);
+  }
+
+  let url = "http://test.mozilla.com/%GOOGLE_API_KEY%/?val=%GOOGLE_API_KEY%";
+  do_check_eq(formatter.trimSensitiveURLs(formatter.formatURL(url)), "http://test.mozilla.com/[trimmed-google-api-key]/?val=[trimmed-google-api-key]");
 }