| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 Platform::shutdown(); | 94 Platform::shutdown(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 TEST(OriginAccessEntryTest, AllowSubdomainsTest) | 97 TEST(OriginAccessEntryTest, AllowSubdomainsTest) |
| 98 { | 98 { |
| 99 struct TestCase { | 99 struct TestCase { |
| 100 const char* protocol; | 100 const char* protocol; |
| 101 const char* host; | 101 const char* host; |
| 102 const char* origin; | 102 const char* origin; |
| 103 OriginAccessEntry::MatchResult expected; | 103 OriginAccessEntry::MatchResult expectedOrigin; |
| 104 OriginAccessEntry::MatchResult expectedDomain; |
| 104 } inputs[] = { | 105 } inputs[] = { |
| 105 { "http", "example.com", "http://example.com/", OriginAccessEntry::Match
esOrigin }, | 106 { "http", "example.com", "http://example.com/", OriginAccessEntry::Match
esOrigin, OriginAccessEntry::MatchesOrigin }, |
| 106 { "http", "example.com", "http://www.example.com/", OriginAccessEntry::M
atchesOrigin }, | 107 { "http", "example.com", "http://www.example.com/", OriginAccessEntry::M
atchesOrigin, OriginAccessEntry::MatchesOrigin }, |
| 107 { "http", "example.com", "http://www.www.example.com/", OriginAccessEntr
y::MatchesOrigin }, | 108 { "http", "example.com", "http://www.www.example.com/", OriginAccessEntr
y::MatchesOrigin, OriginAccessEntry::MatchesOrigin }, |
| 108 { "http", "www.example.com", "http://example.com/", OriginAccessEntry::D
oesNotMatchOrigin }, | 109 { "http", "www.example.com", "http://example.com/", OriginAccessEntry::D
oesNotMatchOrigin, OriginAccessEntry::DoesNotMatchOrigin }, |
| 109 { "http", "www.example.com", "http://www.example.com/", OriginAccessEntr
y::MatchesOrigin }, | 110 { "http", "www.example.com", "http://www.example.com/", OriginAccessEntr
y::MatchesOrigin, OriginAccessEntry::MatchesOrigin }, |
| 110 { "http", "www.example.com", "http://www.www.example.com/", OriginAccess
Entry::MatchesOrigin }, | 111 { "http", "www.example.com", "http://www.www.example.com/", OriginAccess
Entry::MatchesOrigin, OriginAccessEntry::MatchesOrigin }, |
| 111 { "http", "com", "http://example.com/", OriginAccessEntry::MatchesOrigin
ButIsPublicSuffix }, | 112 { "http", "com", "http://example.com/", OriginAccessEntry::MatchesOrigin
ButIsPublicSuffix, OriginAccessEntry::MatchesOriginButIsPublicSuffix }, |
| 112 { "http", "com", "http://www.example.com/", OriginAccessEntry::MatchesOr
iginButIsPublicSuffix }, | 113 { "http", "com", "http://www.example.com/", OriginAccessEntry::MatchesOr
iginButIsPublicSuffix, OriginAccessEntry::MatchesOriginButIsPublicSuffix }, |
| 113 { "http", "com", "http://www.www.example.com/", OriginAccessEntry::Match
esOriginButIsPublicSuffix }, | 114 { "http", "com", "http://www.www.example.com/", OriginAccessEntry::Match
esOriginButIsPublicSuffix, OriginAccessEntry::MatchesOriginButIsPublicSuffix }, |
| 114 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin }, | 115 { "https", "example.com", "http://example.com/", OriginAccessEntry::Does
NotMatchOrigin, OriginAccessEntry::MatchesOrigin }, |
| 115 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin }, | 116 { "https", "example.com", "http://www.example.com/", OriginAccessEntry::
DoesNotMatchOrigin, OriginAccessEntry::MatchesOrigin }, |
| 116 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin }, | 117 { "https", "example.com", "http://www.www.example.com/", OriginAccessEnt
ry::DoesNotMatchOrigin, OriginAccessEntry::MatchesOrigin }, |
| 117 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin }, | 118 { "http", "example.com", "http://beispiel.de/", OriginAccessEntry::DoesN
otMatchOrigin, OriginAccessEntry::DoesNotMatchOrigin }, |
| 118 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin }, | 119 { "http", "example.com", "https://beispiel.de/", OriginAccessEntry::Does
NotMatchOrigin, OriginAccessEntry::DoesNotMatchOrigin }, |
| 119 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin }, | 120 { "http", "", "http://example.com/", OriginAccessEntry::MatchesOrigin, O
riginAccessEntry::MatchesOrigin }, |
| 120 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin }, | 121 { "http", "", "http://beispiel.de/", OriginAccessEntry::MatchesOrigin, O
riginAccessEntry::MatchesOrigin }, |
| 122 { "https", "", "http://beispiel.de/", OriginAccessEntry::DoesNotMatchOri
gin, OriginAccessEntry::MatchesOrigin }, |
| 121 }; | 123 }; |
| 122 | 124 |
| 123 OriginAccessEntryTestPlatform platform; | 125 OriginAccessEntryTestPlatform platform; |
| 124 platform.setPublicSuffix("com"); | 126 platform.setPublicSuffix("com"); |
| 125 Platform::initialize(&platform); | 127 Platform::initialize(&platform); |
| 126 | 128 |
| 127 for (const auto& test : inputs) { | 129 for (const auto& test : inputs) { |
| 128 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); | 130 SCOPED_TRACE(testing::Message() << "Host: " << test.host << ", Origin: "
<< test.origin); |
| 129 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); | 131 RefPtr<SecurityOrigin> originToTest = SecurityOrigin::createFromString(t
est.origin); |
| 130 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); | 132 OriginAccessEntry entry1(test.protocol, test.host, OriginAccessEntry::Al
lowSubdomains); |
| 131 EXPECT_EQ(test.expected, entry1.matchesOrigin(*originToTest)); | 133 EXPECT_EQ(test.expectedOrigin, entry1.matchesOrigin(*originToTest)); |
| 134 EXPECT_EQ(test.expectedDomain, entry1.matchesDomain(*originToTest)); |
| 132 } | 135 } |
| 133 | 136 |
| 134 Platform::shutdown(); | 137 Platform::shutdown(); |
| 135 } | 138 } |
| 136 | 139 |
| 137 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTest) | 140 TEST(OriginAccessEntryTest, AllowRegisterableDomainsTest) |
| 138 { | 141 { |
| 139 struct TestCase { | 142 struct TestCase { |
| 140 const char* protocol; | 143 const char* protocol; |
| 141 const char* host; | 144 const char* host; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 313 |
| 311 OriginAccessEntry entry2(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); | 314 OriginAccessEntry entry2(test.protocol, test.host, OriginAccessEntry::Di
sallowSubdomains); |
| 312 EXPECT_EQ(test.expected, entry2.matchesOrigin(*originToTest)); | 315 EXPECT_EQ(test.expected, entry2.matchesOrigin(*originToTest)); |
| 313 } | 316 } |
| 314 | 317 |
| 315 Platform::shutdown(); | 318 Platform::shutdown(); |
| 316 } | 319 } |
| 317 | 320 |
| 318 } // namespace blink | 321 } // namespace blink |
| 319 | 322 |
| OLD | NEW |