Commit 709a4845 authored by Domenic Denicola's avatar Domenic Denicola Committed by Commit Bot

Origin policy: add more header parsing unit tests

Now that https://crbug.com/1060740 is fixed, we can add a test that
parameters are ignored in the allowed=() inner list.

Also this adds an additional failure case test that I came up with while
working on
https://chromium-review.googlesource.com/c/chromium/src/+/2106417.

Bug: 1042036
Change-Id: I89ee5423aaafc9a48646e44a605f5bd326256306
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2106556Reviewed-by: default avatarDaniel Vogelheim <vogelheim@chromium.org>
Commit-Queue: Domenic Denicola <domenic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751335}
parent 76edf81a
......@@ -88,6 +88,12 @@ TEST(OriginPolicyParsedHeader, AllowedEmpty) {
ASSERT_FALSE(parsed.has_value());
}
TEST(OriginPolicyParsedHeader, AllowedEmptyString) {
auto parsed = OriginPolicyParsedHeader::FromString("allowed=(\"\")");
ASSERT_FALSE(parsed.has_value());
}
TEST(OriginPolicyParsedHeader, AllowedValid) {
auto parsed =
OriginPolicyParsedHeader::FromString("allowed=(\"1\" null \"2\" latest)");
......@@ -275,10 +281,8 @@ TEST(OriginPolicyParsedHeader, CombinedValidExtraDictionaryEntriesIgnored) {
}
TEST(OriginPolicyParsedHeader, CombinedValidParametersIgnored) {
// TODO(domenic): after https://crbug.com/1060740 is fixed we can add
// ;param-a=1;param-b=?0 after "1" and make sure that too gets ignored.
auto parsed = OriginPolicyParsedHeader::FromString(
"allowed=(\"1\" \"2\" latest);param-c=\"x\", "
"allowed=(\"1\";param-a=1;param-b=?0 \"2\" latest);param-c=\"x\", "
"preferred=latest-from-network;param-d=y");
ASSERT_TRUE(parsed.has_value());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment