/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2024,  Regents of the University of California,
 *                           Arizona Board of Regents,
 *                           Colorado State University,
 *                           University Pierre & Marie Curie, Sorbonne University,
 *                           Washington University in St. Louis,
 *                           Beijing Institute of Technology,
 *                           The University of Memphis.
 *
 * This file is part of NFD (Named Data Networking Forwarding Daemon).
 * See AUTHORS.md for complete list of NFD authors and contributors.
 *
 * NFD is free software: you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * NFD 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "rib/readvertise/client-to-nlsr-readvertise-policy.hpp"

#include "tests/test-common.hpp"
#include "tests/daemon/global-io-fixture.hpp"

namespace nfd::tests {

using namespace nfd::rib;

BOOST_AUTO_TEST_SUITE(Rib)
BOOST_FIXTURE_TEST_SUITE(TestClientToNlsrReadvertisePolicy, GlobalIoFixture)

BOOST_AUTO_TEST_CASE(ReadvertiseClientRoute)
{
  auto entry = make_shared<RibEntry>();
  entry->setName("/test/A");
  Route route;
  route.origin = ndn::nfd::ROUTE_ORIGIN_CLIENT;
  auto routeIt = entry->insertRoute(route).first;
  RibRouteRef rrr{entry, routeIt};

  ClientToNlsrReadvertisePolicy policy;
  std::optional<ReadvertiseAction> action = policy.handleNewRoute(rrr);

  BOOST_REQUIRE(action);
  BOOST_CHECK_EQUAL(action->prefix, "/test/A");
  BOOST_REQUIRE_EQUAL(action->signer, ndn::security::SigningInfo());
}

BOOST_AUTO_TEST_CASE(DontReadvertiseRoute)
{
  auto entry = make_shared<RibEntry>();
  entry->setName("/test/A");
  Route route;
  route.origin = ndn::nfd::ROUTE_ORIGIN_NLSR;
  auto routeIt = entry->insertRoute(route).first;
  RibRouteRef rrr{entry, routeIt};

  ClientToNlsrReadvertisePolicy policy;
  std::optional<ReadvertiseAction> action = policy.handleNewRoute(rrr);

  BOOST_CHECK(!action);
}

BOOST_AUTO_TEST_SUITE_END() // TestClientToNlsrReadvertisePolicy
BOOST_AUTO_TEST_SUITE_END() // Rib

} // namespace nfd::tests
