summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-03 23:45:31 +0300
committerEd Tanous <ed@tanous.net>2024-05-08 18:25:51 +0300
commite5cf777eb93bc434e86483ac210e7a55a509a245 (patch)
tree7288c224a595c1894ae28e01f2e3e548f5d3fd5a /test
parent17c472452c9a3518aeac636d01b8e2f01c4fa21f (diff)
downloadbmcweb-e5cf777eb93bc434e86483ac210e7a55a509a245.tar.xz
Add https parsing
This is yet another step in parsing HTTP requests. Tested: ''' curl -vvvv -k --user "root:0penBmc" -H "Content-Type: application/json" \ -X POST https://192.168.7.2/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate \ -d '{ \ "TransferProtocol":"TFTP", \ "ImageURI":"https://192.168.7.1/myfile.bin" \ }' ''' Returns ActionParameterNotSupported TransferProtocol: Omitted ImageURI: https://192.168.7.1/myfile.bin Returns ActionParameterNotSupported TransferProtocol: Omitted ImageURI: 192.168.7.1/myfile.bin Returns ActionParameterValueTypeError TransferProtocol: Bad ImageURI: https:/192.168.7.1/myfile.bin Returns: ActionParameterNotSupported No changes to GET requests, so Redfish Service Validator not necessary. Change-Id: Ibf4b69877031f3b8617412c06d40f2d0d0827ac3 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'test')
-rw-r--r--test/redfish-core/lib/update_service_test.cpp59
1 files changed, 58 insertions, 1 deletions
diff --git a/test/redfish-core/lib/update_service_test.cpp b/test/redfish-core/lib/update_service_test.cpp
index 87af3f116a..11b4479a3d 100644
--- a/test/redfish-core/lib/update_service_test.cpp
+++ b/test/redfish-core/lib/update_service_test.cpp
@@ -43,7 +43,7 @@ TEST(UpdateService, ParseTFTPPostitive)
EXPECT_EQ(ret->scheme(), "tftp");
}
{
- // Both protocl and schema on url
+ // Both protocol and schema on url
std::optional<boost::urls::url> ret =
parseSimpleUpdateUrl("tftp://1.1.1.1/path", "TFTP", res);
ASSERT_TRUE(ret);
@@ -57,6 +57,63 @@ TEST(UpdateService, ParseTFTPPostitive)
}
}
+TEST(UpdateService, ParseHTTPSPostitive)
+{
+ crow::Response res;
+ {
+ // No protocol, schema on url
+ std::optional<boost::urls::url> ret =
+ parseSimpleUpdateUrl("https://1.1.1.1/path", std::nullopt, res);
+ ASSERT_TRUE(ret);
+ if (!ret)
+ {
+ return;
+ }
+ EXPECT_EQ(ret->encoded_host_and_port(), "1.1.1.1");
+ EXPECT_EQ(ret->encoded_path(), "/path");
+ EXPECT_EQ(ret->scheme(), "https");
+ }
+ {
+ // Protocol, no schema on url
+ std::optional<boost::urls::url> ret =
+ parseSimpleUpdateUrl("1.1.1.1/path", "HTTPS", res);
+ ASSERT_TRUE(ret);
+ if (!ret)
+ {
+ return;
+ }
+ EXPECT_EQ(ret->encoded_host_and_port(), "1.1.1.1");
+ EXPECT_EQ(ret->encoded_path(), "/path");
+ EXPECT_EQ(ret->scheme(), "https");
+ }
+ {
+ // Both protocol and schema on url with path
+ std::optional<boost::urls::url> ret =
+ parseSimpleUpdateUrl("https://1.1.1.1/path", "HTTPS", res);
+ ASSERT_TRUE(ret);
+ if (!ret)
+ {
+ return;
+ }
+ EXPECT_EQ(ret->encoded_host_and_port(), "1.1.1.1");
+ EXPECT_EQ(ret->encoded_path(), "/path");
+ EXPECT_EQ(ret->scheme(), "https");
+ }
+ {
+ // Both protocol and schema on url without path
+ std::optional<boost::urls::url> ret =
+ parseSimpleUpdateUrl("https://1.1.1.1", "HTTPS", res);
+ ASSERT_TRUE(ret);
+ if (!ret)
+ {
+ return;
+ }
+ EXPECT_EQ(ret->encoded_host_and_port(), "1.1.1.1");
+ EXPECT_EQ(ret->encoded_path(), "/");
+ EXPECT_EQ(ret->scheme(), "https");
+ }
+}
+
TEST(UpdateService, ParseTFTPNegative)
{
crow::Response res;