Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/extensions/webstore_inline_installer.h" | |
| 6 #include "googleurl/src/gurl.h" | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 // A macro, so that the IsRequestorUrlInVerifiedSite calls are inside of the | |
| 10 // the test, which is marked as a friend of WebstoreInlineInstaller. | |
| 11 #define IsVerified(requestor_url, verified_site) \ | |
| 12 WebstoreInlineInstaller::IsRequestorUrlInVerifiedSite( \ | |
| 13 GURL(requestor_url), verified_site) | |
| 14 | |
| 15 TEST(WebstoreInlineInstallerTest, DomainVerification) { | |
| 16 // Exact domain match. | |
| 17 EXPECT_TRUE(IsVerified("http://example.com", "example.com")); | |
| 18 | |
| 19 // The HTTPS scheme is allowed. | |
| 20 EXPECT_TRUE(IsVerified("https://example.com", "example.com")); | |
| 21 | |
| 22 // The file: scheme is not allowed. | |
| 23 EXPECT_FALSE(IsVerified("file:///example.com", "example.com")); | |
| 24 | |
| 25 // Trailing slash in URL. | |
| 26 EXPECT_TRUE(IsVerified("http://example.com/", "example.com")); | |
| 27 | |
| 28 // Page on the domain. | |
| 29 EXPECT_TRUE(IsVerified("http://example.com/page.html", "example.com")); | |
| 30 | |
| 31 // Page on a subdomain. | |
| 32 EXPECT_TRUE(IsVerified("http://sub.example.com/page.html", "example.com")); | |
| 33 | |
| 34 // Root domain when only a subdomain is verified. | |
| 35 EXPECT_FALSE(IsVerified("http://example.com/", "sub.example.com")); | |
| 36 | |
| 37 // Different subdomain when only a subdomain is verified. | |
| 38 EXPECT_FALSE(IsVerified("http://www.example.com/", "sub.example.com")); | |
| 39 | |
| 40 // Port matches. | |
| 41 EXPECT_TRUE(IsVerified("http://example.com:123/", "example.com:123")); | |
| 42 | |
| 43 // Port doesn't match. | |
| 44 EXPECT_FALSE(IsVerified("http://example.com:456/", "example.com:123")); | |
| 45 | |
| 46 // Port is missing in the requestor URL. | |
| 47 EXPECT_FALSE(IsVerified("http://example.com/", "example.com:123")); | |
| 48 | |
| 49 // Port is missing in the verified site (any port matches). | |
| 50 EXPECT_TRUE(IsVerified("http://example.com:123/", "example.com")); | |
| 51 | |
| 52 // Path matches. | |
| 53 EXPECT_TRUE(IsVerified("http://example.com/path", "example.com/path")); | |
| 54 | |
| 55 // Path matches (with trailing slash). | |
| 56 EXPECT_TRUE(IsVerified("http://example.com/path/", "example.com/path")); | |
| 57 | |
| 58 // Path matches (is a file under the path). | |
| 59 EXPECT_TRUE(IsVerified( | |
| 60 "http://example.com/path/page.html", "example.com/path")); | |
| 61 | |
| 62 // Path and port match. | |
| 63 EXPECT_TRUE(IsVerified( | |
| 64 "http://example.com:123/path/page.html", "example.com:123/path")); | |
|
jstritar
2012/01/25 17:40:28
How about one more test for when there's a path th
Mihai Parparita -not on Chrome
2012/01/25 18:11:04
Done.
| |
| 65 } | |
| OLD | NEW |