/src/mozilla-central/netwerk/test/gtest/TestHeaders.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | #include "gtest/gtest.h" |
2 | | |
3 | | #include "nsHttpHeaderArray.h" |
4 | | |
5 | | |
6 | 0 | TEST(TestHeaders, DuplicateHSTS) { |
7 | 0 | // When the Strict-Transport-Security header is sent multiple times, its |
8 | 0 | // effective value is the value of the first item. It is not merged as other |
9 | 0 | // headers are. |
10 | 0 | mozilla::net::nsHttpHeaderArray headers; |
11 | 0 | nsresult rv = headers.SetHeaderFromNet( |
12 | 0 | mozilla::net::nsHttp::Strict_Transport_Security, |
13 | 0 | NS_LITERAL_CSTRING("Strict_Transport_Security"), |
14 | 0 | NS_LITERAL_CSTRING("max-age=360"), true); |
15 | 0 | ASSERT_EQ(rv, NS_OK); |
16 | 0 |
|
17 | 0 | nsAutoCString h; |
18 | 0 | rv = headers.GetHeader(mozilla::net::nsHttp::Strict_Transport_Security, h); |
19 | 0 | ASSERT_EQ(rv, NS_OK); |
20 | 0 | ASSERT_EQ(h.get(), "max-age=360"); |
21 | 0 |
|
22 | 0 | rv = headers.SetHeaderFromNet( |
23 | 0 | mozilla::net::nsHttp::Strict_Transport_Security, |
24 | 0 | NS_LITERAL_CSTRING("Strict_Transport_Security"), |
25 | 0 | NS_LITERAL_CSTRING("max-age=720"), true); |
26 | 0 | ASSERT_EQ(rv, NS_OK); |
27 | 0 |
|
28 | 0 | rv = headers.GetHeader(mozilla::net::nsHttp::Strict_Transport_Security, h); |
29 | 0 | ASSERT_EQ(rv, NS_OK); |
30 | 0 | ASSERT_EQ(h.get(), "max-age=360"); |
31 | 0 | } |