Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Unified Diff: chrome/browser/extensions/webstore_inline_installer_unittest.cc

Issue 9269020: Handle paths and ports in verified domains in inline install. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/webstore_inline_installer_unittest.cc
diff --git a/chrome/browser/extensions/webstore_inline_installer_unittest.cc b/chrome/browser/extensions/webstore_inline_installer_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e5616bf0008962f66afc506b024677bd6c7c58eb
--- /dev/null
+++ b/chrome/browser/extensions/webstore_inline_installer_unittest.cc
@@ -0,0 +1,71 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/webstore_inline_installer.h"
+#include "googleurl/src/gurl.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// A macro, so that the IsRequestorURLInVerifiedSite calls are inside of the
+// the test, which is marked as a friend of WebstoreInlineInstaller.
+#define IsVerified(requestor_url, verified_site) \
+ WebstoreInlineInstaller::IsRequestorURLInVerifiedSite( \
+ GURL(requestor_url), verified_site)
+
+TEST(WebstoreInlineInstallerTest, DomainVerification) {
+ // Exact domain match.
+ EXPECT_TRUE(IsVerified("http://example.com", "example.com"));
+
+ // The HTTPS scheme is allowed.
+ EXPECT_TRUE(IsVerified("https://example.com", "example.com"));
+
+ // The file: scheme is not allowed.
+ EXPECT_FALSE(IsVerified("file:///example.com", "example.com"));
+
+ // Trailing slash in URL.
+ EXPECT_TRUE(IsVerified("http://example.com/", "example.com"));
+
+ // Page on the domain.
+ EXPECT_TRUE(IsVerified("http://example.com/page.html", "example.com"));
+
+ // Page on a subdomain.
+ EXPECT_TRUE(IsVerified("http://sub.example.com/page.html", "example.com"));
+
+ // Root domain when only a subdomain is verified.
+ EXPECT_FALSE(IsVerified("http://example.com/", "sub.example.com"));
+
+ // Different subdomain when only a subdomain is verified.
+ EXPECT_FALSE(IsVerified("http://www.example.com/", "sub.example.com"));
+
+ // Port matches.
+ EXPECT_TRUE(IsVerified("http://example.com:123/", "example.com:123"));
+
+ // Port doesn't match.
+ EXPECT_FALSE(IsVerified("http://example.com:456/", "example.com:123"));
+
+ // Port is missing in the requestor URL.
+ EXPECT_FALSE(IsVerified("http://example.com/", "example.com:123"));
+
+ // Port is missing in the verified site (any port matches).
+ EXPECT_TRUE(IsVerified("http://example.com:123/", "example.com"));
+
+ // Path matches.
+ EXPECT_TRUE(IsVerified("http://example.com/path", "example.com/path"));
+
+ // Path doesn't match.
+ EXPECT_FALSE(IsVerified("http://example.com/foo", "example.com/path"));
+
+ // Path is missing.
+ EXPECT_FALSE(IsVerified("http://example.com", "example.com/path"));
+
+ // Path matches (with trailing slash).
+ EXPECT_TRUE(IsVerified("http://example.com/path/", "example.com/path"));
+
+ // Path matches (is a file under the path).
+ EXPECT_TRUE(IsVerified(
+ "http://example.com/path/page.html", "example.com/path"));
+
+ // Path and port match.
+ EXPECT_TRUE(IsVerified(
+ "http://example.com:123/path/page.html", "example.com:123/path"));
+}
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698