aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRichard Walters <rwalters@digitalstirling.com>2018-07-01 00:18:30 -0700
committerRichard Walters <rwalters@digitalstirling.com>2018-07-01 00:18:30 -0700
commit6c79c19334b53560ea9d2036da279994b8f83be4 (patch)
treea96feb5c21a6d2f1d35b269f5c54a20a2d1dba83 /test
parentedcdec855e90b01dafc6248a79b1275da8069c38 (diff)
Handle bad characters in UserInfo
Diffstat (limited to 'test')
-rw-r--r--test/src/UriTests.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/src/UriTests.cpp b/test/src/UriTests.cpp
index b4be2d5..d246a4d 100644
--- a/test/src/UriTests.cpp
+++ b/test/src/UriTests.cpp
@@ -274,3 +274,39 @@ TEST(UriTests, ParseFromStringSchemeBarelyLegal) {
++index;
}
}
+
+TEST(UriTests, ParseFromStringUserInfoIllegalCharacters) {
+ const std::vector< std::string > testVectors{
+ {"//%X@www.example.com/"},
+ {"//{@www.example.com/"},
+ };
+ size_t index = 0;
+ for (const auto& testVector : testVectors) {
+ Uri::Uri uri;
+ ASSERT_FALSE(uri.ParseFromString(testVector)) << index;
+ ++index;
+ }
+}
+
+TEST(UriTests, ParseFromStringUserInfoBarelyLegal) {
+ struct TestVector {
+ std::string uriString;
+ std::string userInfo;
+ };
+ const std::vector< TestVector > testVectors{
+ {"//%41@www.example.com/", "A"},
+ {"//@www.example.com/", ""},
+ {"//!@www.example.com/", "!"},
+ {"//'@www.example.com/", "'"},
+ {"//(@www.example.com/", "("},
+ {"//;@www.example.com/", ";"},
+ {"http://:@www.example.com/", ":"},
+ };
+ size_t index = 0;
+ for (const auto& testVector : testVectors) {
+ Uri::Uri uri;
+ ASSERT_TRUE(uri.ParseFromString(testVector.uriString)) << index;
+ ASSERT_EQ(testVector.userInfo, uri.GetUserInfo());
+ ++index;
+ }
+}