diff options
author | Richard Walters <rwalters@digitalstirling.com> | 2018-07-01 00:18:30 -0700 |
---|---|---|
committer | Richard Walters <rwalters@digitalstirling.com> | 2018-07-01 00:18:30 -0700 |
commit | 6c79c19334b53560ea9d2036da279994b8f83be4 (patch) | |
tree | a96feb5c21a6d2f1d35b269f5c54a20a2d1dba83 /test | |
parent | edcdec855e90b01dafc6248a79b1275da8069c38 (diff) |
Handle bad characters in UserInfo
Diffstat (limited to 'test')
-rw-r--r-- | test/src/UriTests.cpp | 36 |
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; + } +} |