/src/mozilla-central/netwerk/test/gtest/TestHttpAuthUtils.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | #include "gtest/gtest.h" |
2 | | |
3 | | #include "mozilla/net/HttpAuthUtils.h" |
4 | | #include "mozilla/Preferences.h" |
5 | | #include "nsNetUtil.h" |
6 | | |
7 | | namespace mozilla { |
8 | | namespace net { |
9 | | |
10 | | #define TEST_PREF "network.http_test.auth_utils" |
11 | | |
12 | 0 | TEST(TestHttpAuthUtils, Bug1351301) { |
13 | 0 | nsCOMPtr<nsIURI> url; |
14 | 0 | nsAutoCString spec; |
15 | 0 |
|
16 | 0 | ASSERT_EQ(Preferences::SetCString(TEST_PREF, "bar.com"), NS_OK); |
17 | 0 | spec = "http://bar.com"; |
18 | 0 | ASSERT_EQ(NS_NewURI(getter_AddRefs(url), spec), NS_OK); |
19 | 0 | ASSERT_EQ(auth::URIMatchesPrefPattern(url,TEST_PREF), true); |
20 | 0 |
|
21 | 0 | spec = "http://foo.bar.com"; |
22 | 0 | ASSERT_EQ(NS_NewURI(getter_AddRefs(url), spec), NS_OK); |
23 | 0 | ASSERT_EQ(auth::URIMatchesPrefPattern(url,TEST_PREF), true); |
24 | 0 |
|
25 | 0 | spec = "http://foobar.com"; |
26 | 0 | ASSERT_EQ(NS_NewURI(getter_AddRefs(url), spec), NS_OK); |
27 | 0 | ASSERT_EQ(auth::URIMatchesPrefPattern(url,TEST_PREF), false); |
28 | 0 |
|
29 | 0 | ASSERT_EQ(Preferences::SetCString(TEST_PREF, ".bar.com"), NS_OK); |
30 | 0 | spec = "http://foo.bar.com"; |
31 | 0 | ASSERT_EQ(NS_NewURI(getter_AddRefs(url), spec), NS_OK); |
32 | 0 | ASSERT_EQ(auth::URIMatchesPrefPattern(url,TEST_PREF), true); |
33 | 0 |
|
34 | 0 | spec = "http://bar.com"; |
35 | 0 | ASSERT_EQ(NS_NewURI(getter_AddRefs(url), spec), NS_OK); |
36 | 0 | ASSERT_EQ(auth::URIMatchesPrefPattern(url,TEST_PREF), false); |
37 | 0 |
|
38 | 0 | ASSERT_EQ(Preferences::ClearUser(TEST_PREF), NS_OK); |
39 | 0 | } |
40 | | |
41 | | } // namespace net |
42 | | } // namespace mozila |