#   BAREOS® - Backup Archiving REcovery Open Sourced
#
#   Copyright (C) 2026-2026 Bareos GmbH & Co. KG
#
#   This program is Free Software; you can redistribute it and/or
#   modify it under the terms of version three of the GNU Affero General Public
#   License as published by the Free Software Foundation and included
#   in the file LICENSE.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#   Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#   02110-1301, USA.

# Exercise main's implicit config selection without touching the host's /etc.
add_executable(
  bareos-webui-proxy-startup ../main.cc ../proxy_server.cc
                             $<TARGET_OBJECTS:webui-proxy-objects>
)
target_compile_definitions(
  bareos-webui-proxy-startup
  PRIVATE
    WEBUI_PROXY_DEFAULT_CONFIG_PATH="${CMAKE_BINARY_DIR}/systemtests/tests/webui-proxy/config/default.ini"
)
target_link_libraries(
  bareos-webui-proxy-startup
  PRIVATE Bareos::Lib OpenSSL::SSL OpenSSL::Crypto Jansson::Jansson
          Threads::Threads CLI11::CLI11
)

if(GTest_FOUND)
  include(GoogleTest)

  add_executable(
    test_webui_proxy
    test_bareos_base64.cc
    test_director_connection.cc
    test_http_protocol.cc
    test_proxy_auth_session.cc
    test_proxy_config.cc
    test_proxy_log.cc
    test_proxy_session.cc
    test_ws_codec.cc
    $<TARGET_OBJECTS:webui-proxy-objects>
  )
  target_link_libraries(
    test_webui_proxy
    PRIVATE Bareos::Lib OpenSSL::SSL OpenSSL::Crypto Jansson::Jansson
            GTest::gtest GTest::gtest_main Threads::Threads
  )
  gtest_discover_tests(test_webui_proxy)
endif()
