|
38 | 38 | #include "../capi_frontend/capi_dag_utils.hpp" |
39 | 39 | #include "../capi_frontend/servablemetadata.hpp" |
40 | 40 | #include "../dags/pipelinedefinitionstatus.hpp" |
| 41 | +#include "../filesystem/filesystem.hpp" |
41 | 42 | #include "src/metrics/metric_module.hpp" |
42 | 43 | #include "../ovms.h" |
43 | 44 | #include "../servablemanagermodule.hpp" |
@@ -183,7 +184,7 @@ TEST(CAPIConfigTest, MultiModelConfiguration) { |
183 | 184 | EXPECT_EQ(serverSettings->logLevel, "TRACE"); |
184 | 185 | EXPECT_EQ(serverSettings->logPath, getGenericFullPathForTmp("/tmp/logs")); |
185 | 186 | ASSERT_TRUE(serverSettings->allowedLocalMediaPath.has_value()); |
186 | | - EXPECT_EQ(serverSettings->allowedLocalMediaPath.value(), getGenericFullPathForTmp("/tmp/path")); |
| 187 | + EXPECT_EQ(serverSettings->allowedLocalMediaPath.value(), ovms::FileSystem::normalizeConfiguredPath(getGenericFullPathForTmp("/tmp/path"))); |
187 | 188 | ASSERT_TRUE(serverSettings->allowedMediaDomains.has_value()); |
188 | 189 | EXPECT_EQ(serverSettings->allowedMediaDomains.value().size(), 3); |
189 | 190 | EXPECT_EQ(serverSettings->allowedMediaDomains.value()[0], "raw.githubusercontent.com"); |
@@ -258,6 +259,22 @@ TEST(CAPIConfigTest, SingleModelConfiguration) { |
258 | 259 | GTEST_SKIP() << "Use C-API to initialize in next stages, currently not supported"; |
259 | 260 | } |
260 | 261 |
|
| 262 | +TEST(CAPIConfigTest, AllowedLocalMediaPathRelativeIsNormalized) { |
| 263 | + OVMS_ServerSettings* serverSettingsRaw = nullptr; |
| 264 | + ASSERT_CAPI_STATUS_NULL(OVMS_ServerSettingsNew(&serverSettingsRaw)); |
| 265 | + ASSERT_NE(serverSettingsRaw, nullptr); |
| 266 | + ServerSettingsImpl* serverSettings = reinterpret_cast<ServerSettingsImpl*>(serverSettingsRaw); |
| 267 | + |
| 268 | + ASSERT_CAPI_STATUS_NULL(OVMS_ServerSettingsSetAllowedLocalMediaPath(serverSettingsRaw, "src/test")); |
| 269 | + ASSERT_TRUE(serverSettings->allowedLocalMediaPath.has_value()); |
| 270 | + |
| 271 | + const auto configuredPath = std::filesystem::path(serverSettings->allowedLocalMediaPath.value()); |
| 272 | + const auto expectedPath = std::filesystem::path(ovms::FileSystem::normalizeConfiguredPath("src/test")); |
| 273 | + EXPECT_EQ(configuredPath.lexically_normal(), expectedPath.lexically_normal()); |
| 274 | + |
| 275 | + OVMS_ServerSettingsDelete(serverSettingsRaw); |
| 276 | +} |
| 277 | + |
261 | 278 | TEST(CAPIStartTest, InitializingMultipleServers) { |
262 | 279 | OVMS_Server* srv1 = nullptr; |
263 | 280 | OVMS_Server* srv2 = nullptr; |
|
0 commit comments