summaryrefslogtreecommitdiff
path: root/test/http
diff options
context:
space:
mode:
authorWilly Tu <wltu@google.com>2022-09-26 19:46:38 +0300
committerEd Tanous <ed@tanous.net>2023-02-23 20:53:12 +0300
commiteddfc437edfc871b469199552bdeb0d65ee2dcf3 (patch)
tree3900183f1dc64c2cdcc20eebbc6d8de84e78a557 /test/http
parent66d90c2cb505d899373f17be468e730e88fe2345 (diff)
downloadbmcweb-eddfc437edfc871b469199552bdeb0d65ee2dcf3.tar.xz
Update most resources to use urlFromPieces
Only id in event_service and account_service have not been updated due to the risk of it breaking the username/id. It will require further testing to verify. Use urlFromPieces wherever that is needed to insert a variable in the URI. Don't use urlFromPieces when it is hardcoded values. This allow us to control all resource URIs that is dynamically added and to sync with the current recommanded method for `@odata.id`. The goal is to have a common place to manage the url created from dbus-paths in order to manage/update it easily when needed. Tested: RedfishValidtor Passed for all resource including the sensors with the fragments. Change-Id: I95cdfaaee58fc7f21c95f5944e1e5c813b3215f2 Signed-off-by: Willy Tu <wltu@google.com> Signed-off-by: Ed Tanous <edtanous@google.com>
Diffstat (limited to 'test/http')
-rw-r--r--test/http/utility_test.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/http/utility_test.cpp b/test/http/utility_test.cpp
index 2e0c82e4d7..957c13d2db 100644
--- a/test/http/utility_test.cpp
+++ b/test/http/utility_test.cpp
@@ -94,6 +94,24 @@ TEST(Utility, UrlFromPieces)
url = urlFromPieces("/", "bad&tring");
EXPECT_EQ(url.buffer(), "/%2F/bad&tring");
+
+ EXPECT_EQ(std::string_view(url.data(), url.size()), "/%2F/bad&tring");
+
+ url = urlFromPieces("my-user");
+ EXPECT_EQ(std::string_view(url.data(), url.size()), "/my-user");
+
+ url = urlFromPieces("my_user");
+ EXPECT_EQ(std::string_view(url.data(), url.size()), "/my_user");
+
+ url = urlFromPieces("my_93user");
+ EXPECT_EQ(std::string_view(url.data(), url.size()), "/my_93user");
+
+ // The following characters will be converted to ASCII number
+ // `[{]}\|"<>/?#%^
+ url =
+ urlFromPieces("~1234567890-_=+qwertyuiopasdfghjklzxcvbnm;:',.!@$&*()");
+ EXPECT_EQ(std::string_view(url.data(), url.size()),
+ "/~1234567890-_=+qwertyuiopasdfghjklzxcvbnm;:',.!@$&*()");
}
TEST(Utility, readUrlSegments)