summaryrefslogtreecommitdiffstats
path: root/netwerk/test/gtest/TestHttpAuthUtils.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:44:51 +0000
commit9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /netwerk/test/gtest/TestHttpAuthUtils.cpp
parentInitial commit. (diff)
downloadthunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz
thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/gtest/TestHttpAuthUtils.cpp')
-rw-r--r--netwerk/test/gtest/TestHttpAuthUtils.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/netwerk/test/gtest/TestHttpAuthUtils.cpp b/netwerk/test/gtest/TestHttpAuthUtils.cpp
new file mode 100644
index 0000000000..78fb40d4d0
--- /dev/null
+++ b/netwerk/test/gtest/TestHttpAuthUtils.cpp
@@ -0,0 +1,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