summaryrefslogtreecommitdiffstats
path: root/PRESUBMIT_test.py
diff options
context:
space:
mode:
authorreillyi <reillyi@amazon.com>2015-11-16 10:27:33 -0800
committerCommit bot <commit-bot@chromium.org>2015-11-16 18:28:18 +0000
commit3896573612b050f3e065b1188098f68bdae0b696 (patch)
treeb497bfd998683dfe4ff96f4aa0c72d1ea4f60cce /PRESUBMIT_test.py
parentf12a8fd20f4f1b14a75f6f944dc2a1cd5aa847a7 (diff)
downloadchromium_src-3896573612b050f3e065b1188098f68bdae0b696.zip
chromium_src-3896573612b050f3e065b1188098f68bdae0b696.tar.gz
chromium_src-3896573612b050f3e065b1188098f68bdae0b696.tar.bz2
Add additional hosts to hard-coded service URL presubmit check
This adds additional domains to the root PRESUBMIT check, "_CheckHardcodedGoogleHostsInLowerLayers", based on hostnames currently used in Chromium. Previously, this check only validated that "google.com" was not hard-coded, but did not catch other common hostnames: - gstatic.com - googleapis.com - googlezip.net - googledrive.com - appspot.com Note that this check is non-blocking, only prompting the user with a warning before continuing the submit operation. BUG=164568 TEST=PRESUBMIT_test.py Review URL: https://codereview.chromium.org/1403673003 Cr-Commit-Position: refs/heads/master@{#359869}
Diffstat (limited to 'PRESUBMIT_test.py')
-rwxr-xr-xPRESUBMIT_test.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 5aed7ee..e488c94 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -986,6 +986,35 @@ class LogUsageTest(unittest.TestCase):
self.assertTrue('HasDottedTag.java' in msgs[4].items)
self.assertTrue('HasOldTag.java' in msgs[4].items)
+class HardcodedGoogleHostsTest(unittest.TestCase):
+
+ def testWarnOnAssignedLiterals(self):
+ input_api = MockInputApi()
+ input_api.files = [
+ MockFile('content/file.cc',
+ ['char* host = "https://www.google.com";']),
+ MockFile('content/file.cc',
+ ['char* host = "https://www.googleapis.com";']),
+ MockFile('content/file.cc',
+ ['char* host = "https://clients1.google.com";']),
+ ]
+
+ warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers(
+ input_api, MockOutputApi())
+ self.assertEqual(1, len(warnings))
+ self.assertEqual(3, len(warnings[0].items))
+
+ def testAllowInComment(self):
+ input_api = MockInputApi()
+ input_api.files = [
+ MockFile('content/file.cc',
+ ['char* host = "https://www.aol.com"; // google.com'])
+ ]
+
+ warnings = PRESUBMIT._CheckHardcodedGoogleHostsInLowerLayers(
+ input_api, MockOutputApi())
+ self.assertEqual(0, len(warnings))
+
if __name__ == '__main__':
unittest.main()