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