Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
// SPDX-License-Identifier: MPL-2.0
|
|
//
|
|
// Tests purs des URL du Studio et de l'encodage pourcentage.
|
|
#include "sequa/studio/host/urls.hpp"
|
|
|
|
#include <doctest/doctest.h>
|
|
|
|
#include <string>
|
|
|
|
using namespace sequa::studio::host;
|
|
|
|
TEST_CASE("Web : build_core_ws_url")
|
|
{
|
|
CHECK(build_core_ws_url("127.0.0.1", 9100, "ab12cd") == "ws://127.0.0.1:9100/?token=ab12cd");
|
|
CHECK(build_core_ws_url("localhost", 19400, "") == "ws://localhost:19400/?token=");
|
|
}
|
|
|
|
TEST_CASE("Web : build_ui_url encode l'URL du Core")
|
|
{
|
|
const std::string url = build_ui_url("http://127.0.0.1:9080", "ws://127.0.0.1:9100/?token=ab12");
|
|
CHECK(url == "http://127.0.0.1:9080/?core=ws%3A%2F%2F127.0.0.1%3A9100%2F%3Ftoken%3Dab12");
|
|
}
|
|
|
|
TEST_CASE("Web : percent_encode respecte les non-reserves RFC 3986")
|
|
{
|
|
CHECK(percent_encode("AZaz09-._~") == "AZaz09-._~");
|
|
CHECK(percent_encode("a b/c?d=e&f") == "a%20b%2Fc%3Fd%3De%26f");
|
|
CHECK(percent_encode("") == "");
|
|
// Octets UTF-8 de « é » (C3 A9).
|
|
CHECK(percent_encode("\xC3\xA9") == "%C3%A9");
|
|
// Les octets bruts ne doivent pas passer.
|
|
CHECK(percent_encode(std::string("\x00\x7F\x80", 3)) == "%00%7F%80");
|
|
}
|