diff --git a/tests/engine/test_falco_utils.cpp b/tests/engine/test_falco_utils.cpp index aa6c21b3..10746779 100644 --- a/tests/engine/test_falco_utils.cpp +++ b/tests/engine/test_falco_utils.cpp @@ -14,22 +14,40 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "falco_utils.h" +#include #include -TEST_CASE("Startswith shold match when checked string has prefix", "[utils]") +TEST_CASE("is_unix_scheme matches", "[utils]") { - bool res = falco::utils::starts_with("unix:///var/run/falco.sock", "unix://"); - REQUIRE(res); + SECTION("rvalue") + { + bool res = falco::utils::network::is_unix_scheme("unix:///var/run/falco.sock"); + REQUIRE(res); + } + + SECTION("std::string") + { + std::string url("unix:///var/run/falco.sock"); + bool res = falco::utils::network::is_unix_scheme(url); + REQUIRE(res); + } + + SECTION("char[]") + { + char url[] = "unix:///var/run/falco.sock"; + bool res = falco::utils::network::is_unix_scheme(url); + REQUIRE(res); + } } -TEST_CASE("Startswith shold not match when checked string does not have prefix", "[utils]") +TEST_CASE("is_unix_scheme does not match", "[utils]") { - bool res = falco::utils::starts_with("unix:///var/run/falco.sock", "something://"); + bool res = falco::utils::network::is_unix_scheme("something:///var/run/falco.sock"); REQUIRE_FALSE(res); } -TEST_CASE("Startswith shold not match when prefix is at a random position", "[utils]") +TEST_CASE("is_unix_scheme only matches scheme at the start of the string", "[utils]") { - bool res = falco::utils::starts_with("/var/run/unix:///falco.sock", "unix://"); + bool res = falco::utils::network::is_unix_scheme("/var/run/unix:///falco.sock"); REQUIRE_FALSE(res); } diff --git a/userspace/falco/grpc_server.cpp b/userspace/falco/grpc_server.cpp index 5f09b7b0..f594aff8 100644 --- a/userspace/falco/grpc_server.cpp +++ b/userspace/falco/grpc_server.cpp @@ -121,7 +121,7 @@ void falco::grpc::server::init(std::string server_addr, int threadiness, std::st m_cert_chain = cert_chain; m_root_certs = root_certs; - if(falco::utils::network::url_is_unix_scheme(m_server_addr)) + if(falco::utils::network::is_unix_scheme(m_server_addr)) { init_unix_server_builder(); return;