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

Side by Side Diff: third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp

Issue 2896833002: Added validation of the policy specified in the 'csp' attribute (Closed)
Patch Set: Fixed issue with the renaming of the embedding-csp header Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/csp/CSPDirectiveList.h" 5 #include "core/frame/csp/CSPDirectiveList.h"
6 6
7 #include "core/frame/SubresourceIntegrity.h" 7 #include "core/frame/SubresourceIntegrity.h"
8 #include "core/frame/csp/ContentSecurityPolicy.h" 8 #include "core/frame/csp/ContentSecurityPolicy.h"
9 #include "core/frame/csp/SourceListDirective.h" 9 #include "core/frame/csp/SourceListDirective.h"
10 #include "platform/loader/fetch/ResourceRequest.h" 10 #include "platform/loader/fetch/ResourceRequest.h"
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 CSPDirectiveList::GetSourceVector(test.directive, policy_vector).size(), 1133 CSPDirectiveList::GetSourceVector(test.directive, policy_vector).size(),
1134 udpated_total); 1134 udpated_total);
1135 EXPECT_EQ( 1135 EXPECT_EQ(
1136 CSPDirectiveList::GetSourceVector( 1136 CSPDirectiveList::GetSourceVector(
1137 ContentSecurityPolicy::DirectiveType::kChildSrc, policy_vector) 1137 ContentSecurityPolicy::DirectiveType::kChildSrc, policy_vector)
1138 .size(), 1138 .size(),
1139 expected_child_src); 1139 expected_child_src);
1140 } 1140 }
1141 } 1141 }
1142 1142
1143 TEST_F(CSPDirectiveListTest, IsValidTest) {
1144 // Empty string is invalid
1145 EXPECT_EQ(CSPDirectiveList::IsValid(""), false);
1146
1147 // Policy with single directive
1148 EXPECT_EQ(CSPDirectiveList::IsValid("base-uri http://example.com"), true);
1149 EXPECT_EQ(CSPDirectiveList::IsValid("invalid-policy-name http://example.com"),
1150 false);
1151
1152 // Policy with multiple directives
1153 EXPECT_EQ(CSPDirectiveList::IsValid("base-uri http://example.com 'self'; "
1154 "child-src http://example.com; "
1155 "default-src http://example.com"),
1156 true);
1157 EXPECT_EQ(CSPDirectiveList::IsValid("default-src http://example.com; "
1158 "invalid-policy-name http://example.com"),
1159 false);
Mike West 2017/05/23 19:21:36 It would be nice to get a little more coverage her
andypaicu 2017/05/26 14:41:09 Done. I'll do the WPT tests separately for now. Ra
1160 }
1161
1143 } // namespace blink 1162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698