Skip to content

Commit

Permalink
Add an argument to the signaling server to support symlinked files in… (
Browse files Browse the repository at this point in the history
#144)

* 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
  • Loading branch information
philippewarren authored Jul 11, 2024
1 parent fa6d0fe commit 162a2e0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.1
1.2.2
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class Args:
password: str
ice_servers: Path
static_folder: Path
follow_symlinks: bool
certificate: Path
key: Path
log_level: int
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 162a2e0

Please sign in to comment.