From 162a2e05d1f181275fb5b9970afb18762584c893 Mon Sep 17 00:00:00 2001 From: philippewarren <55722645+philippewarren@users.noreply.github.com> Date: Thu, 11 Jul 2024 14:05:59 -0400 Subject: [PATCH] =?UTF-8?q?Add=20an=20argument=20to=20the=20signaling=20se?= =?UTF-8?q?rver=20to=20support=20symlinked=20files=20in=E2=80=A6=20(#144)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add an argument to the signaling server to support symlinked files in static folder, to support symlink installs in ROS2/colcon * Bump version * Add an alternative endpoint in http tests to reduce test flakiness --- VERSION | 2 +- .../test/src/Utils/HttpTests.cpp | 28 ++++++++++++++++--- .../signaling_server/signaling_server.py | 4 ++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 6085e946..23aa8390 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.1 +1.2.2 diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Utils/HttpTests.cpp b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Utils/HttpTests.cpp index 59071e81..e733ffa8 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Utils/HttpTests.cpp +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Utils/HttpTests.cpp @@ -11,15 +11,35 @@ using ::testing::HasSubstr; TEST(HttpTests, get_http_shouldReturnTrueAndSetResponse) { string response; - EXPECT_TRUE(Http::get("http://www.perdus.com", response, {})); - EXPECT_THAT(response, HasSubstr("Vous Etes Perdus ?")); + if (Http::get("http://www.perdu.com", response, {})) + { + EXPECT_THAT(response, HasSubstr("Vous Etes Perdu ?")); + } + else if (Http::get("http://www.perdus.com", response, {})) + { + EXPECT_THAT(response, HasSubstr("Vous Etes Perdus ?")); + } + else + { + FAIL() << "Neither 'http://www.perdus.com' nor 'http://www.perdu.com' could be reached."; + } } TEST(HttpTests, get_https_shouldReturnTrueAndSetResponse) { string response; - EXPECT_TRUE(Http::get("https://www.perdus.com", response, {})); - EXPECT_THAT(response, HasSubstr("Vous Etes Perdus ?")); + if (Http::get("https://www.perdu.com", response, {})) + { + EXPECT_THAT(response, HasSubstr("Vous Etes Perdu ?")); + } + else if (Http::get("https://www.perdus.com", response, {})) + { + EXPECT_THAT(response, HasSubstr("Vous Etes Perdus ?")); + } + else + { + FAIL() << "Neither 'https://www.perdu.com' nor 'https://www.perdus.com' could be reached."; + } } TEST(HttpTests, get_invalidUrl_shouldReturnFalse) diff --git a/signaling-server/opentera_webrtc/signaling_server/signaling_server.py b/signaling-server/opentera_webrtc/signaling_server/signaling_server.py index 08a0ad14..a7bfc689 100755 --- a/signaling-server/opentera_webrtc/signaling_server/signaling_server.py +++ b/signaling-server/opentera_webrtc/signaling_server/signaling_server.py @@ -252,6 +252,7 @@ class Args: password: str ice_servers: Path static_folder: Path + follow_symlinks: bool certificate: Path key: Path log_level: int @@ -266,6 +267,7 @@ def main(other_routes=None): parser.add_argument('--password', type=str, help='Choose the password', default=None) parser.add_argument('--ice_servers', type=ExpandUserPath, help='Choose the ice servers json file', default=None) parser.add_argument('--static_folder', type=ExpandUserPath, help='Choose the static folder', default=None) + parser.add_argument('--follow_symlinks', action="store_true", help='Follow symlinks for static folder, SECURITY RISK') parser.add_argument('--certificate', type=ExpandUserPath, help='TLS certificate path', default=None) parser.add_argument('--key', type=ExpandUserPath, help='TLS private key path', default=None) parser.add_argument('--log_level', type=int, choices=[logging.CRITICAL, logging.ERROR, @@ -306,7 +308,7 @@ def main(other_routes=None): # Create static route if required if args.static_folder is not None: - app.add_routes([web.static('/', args.static_folder)]) + app.add_routes([web.static('/', args.static_folder, follow_symlinks=args.follow_symlinks)]) # Run app if using_tls: