/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2014-2020, Regents of the University of California
 *
 * This file is part of NAC (Name-Based Access Control for NDN).
 * See AUTHORS.md for complete list of NAC authors and contributors.
 *
 * NAC 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.
 *
 * NAC 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
 * NAC, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "encrypted-content.hpp"

#include "tests/boost-test.hpp"

namespace ndn {
namespace nac {
namespace tests {

class EncryptedContentFixture
{
public:
  EncryptedContentFixture()
  {
    BOOST_ASSERT(randomBlock.value_size() == 3);
    BOOST_ASSERT(randomBuffer->size() == 10);
  }

public:
  EncryptedContent content;
  Block randomBlock = "01 03 000000"_block;
  ConstBufferPtr randomBuffer = make_shared<const Buffer>(10);
};

BOOST_FIXTURE_TEST_SUITE(TestEncryptedContent, EncryptedContentFixture)

BOOST_AUTO_TEST_CASE(Constructor)
{
  BOOST_CHECK_THROW(content.wireEncode(), tlv::Error);
  content.setPayload(randomBlock);

  BOOST_CHECK(!content.hasIv());
  BOOST_CHECK(!content.hasPayloadKey());
  BOOST_CHECK(!content.hasKeyLocator());

  BOOST_CHECK_EQUAL(content.wireEncode(), "82 07 84050103000000"_block);

  content.setIv(randomBlock);
  BOOST_CHECK_EQUAL(content.wireEncode(), "82[0E]=8405010300000085050103000000"_block);

  content.setKeyLocator("/random/name");
  BOOST_CHECK_EQUAL(content.wireEncode(), "82[1E]=8405010300000085050103000000070E080672616E646F6D08046E616D65"_block);

  content = EncryptedContent("82 07 84050103000000"_block);
  BOOST_CHECK(!content.hasIv());
  BOOST_CHECK(!content.hasPayloadKey());
  BOOST_CHECK(!content.hasKeyLocator());

  content = EncryptedContent("82 1E 8505010300000084050103000000070E080672616E646F6D08046E616D65"_block);
  BOOST_CHECK(content.hasIv());
  BOOST_CHECK(!content.hasPayloadKey());
  BOOST_CHECK(content.hasKeyLocator());
}

BOOST_AUTO_TEST_SUITE(SetterGetter)

BOOST_AUTO_TEST_CASE(Iv)
{
  content.setPayload(randomBlock);

  content.setIv(randomBlock);
  BOOST_REQUIRE(content.hasIv());
  BOOST_CHECK_EQUAL(content.getIv().type(), tlv::InitializationVector);
  BOOST_CHECK_EQUAL(content.getIv().blockFromValue(), randomBlock);

  content.unsetIv();
  BOOST_CHECK(!content.hasIv());

  content.setIv(randomBuffer);
  BOOST_REQUIRE(content.hasIv());
  BOOST_CHECK_EQUAL(content.getIv().type(), tlv::InitializationVector);
  BOOST_CHECK_THROW(content.getIv().blockFromValue(), tlv::Error);
  BOOST_CHECK_EQUAL(content.getIv().value_size(), randomBuffer->size());

  content = EncryptedContent("82[13]=84050103000000850A00000000000000000000"_block);
  BOOST_REQUIRE(content.hasIv());
  BOOST_CHECK_EQUAL(content.getIv().type(), tlv::InitializationVector);
  BOOST_CHECK_THROW(content.getIv().blockFromValue(), tlv::Error);
  BOOST_CHECK_EQUAL(content.getIv().value_size(), randomBuffer->size());
}

BOOST_AUTO_TEST_CASE(Payload)
{
  content.setPayload(randomBlock);
  BOOST_CHECK_EQUAL(content.getPayload().type(), tlv::EncryptedPayload);
  BOOST_CHECK_EQUAL(content.getPayload().blockFromValue(), randomBlock);

  content.setPayload(randomBuffer);
  BOOST_CHECK_EQUAL(content.getPayload().type(), tlv::EncryptedPayload);
  BOOST_CHECK_THROW(content.getPayload().blockFromValue(), tlv::Error);
  BOOST_CHECK_EQUAL(content.getPayload().value_size(), randomBuffer->size());

  content = EncryptedContent("82[0C]=840A00000000000000000000"_block);
  BOOST_CHECK_EQUAL(content.getPayload().type(), tlv::EncryptedPayload);
  BOOST_CHECK_THROW(content.getPayload().blockFromValue(), tlv::Error);
  BOOST_CHECK_EQUAL(content.getPayload().value_size(), randomBuffer->size());
}

BOOST_AUTO_TEST_CASE(PayloadKey)
{
  content.setPayload(randomBlock);

  content.setPayloadKey(randomBlock);
  BOOST_REQUIRE(content.hasPayloadKey());
  BOOST_CHECK_EQUAL(content.getPayloadKey().type(), tlv::EncryptedPayloadKey);
  BOOST_CHECK_EQUAL(content.getPayloadKey().blockFromValue(), randomBlock);

  content.unsetPayloadKey();
  BOOST_CHECK(!content.hasPayloadKey());

  content.setPayloadKey(randomBuffer);
  BOOST_REQUIRE(content.hasPayloadKey());
  BOOST_CHECK_EQUAL(content.getPayloadKey().type(), tlv::EncryptedPayloadKey);
  BOOST_CHECK_THROW(content.getPayloadKey().blockFromValue(), tlv::Error);
  BOOST_CHECK_EQUAL(content.getPayloadKey().value_size(), randomBuffer->size());

  content = EncryptedContent("82[13]=84050103000000860A00000000000000000000"_block);
  BOOST_CHECK_EQUAL(content.getPayloadKey().type(), tlv::EncryptedPayloadKey);
  BOOST_CHECK_THROW(content.getPayloadKey().blockFromValue(), tlv::Error);
  BOOST_CHECK_EQUAL(content.getPayloadKey().value_size(), randomBuffer->size());
}

BOOST_AUTO_TEST_CASE(KeyLocator)
{
  content.setPayload(randomBlock);

  content.setKeyLocator("/random/name");
  BOOST_REQUIRE(content.hasKeyLocator());
  BOOST_CHECK_EQUAL(content.getKeyLocator(), "/random/name");

  content.unsetPayloadKey();
  BOOST_CHECK(!content.hasPayloadKey());

  content = EncryptedContent("82[17]=84050103000000070E080672616E646F6D08046E616D65"_block);
  BOOST_REQUIRE(content.hasKeyLocator());
  BOOST_CHECK_EQUAL(content.getKeyLocator(), "/random/name");
}

BOOST_AUTO_TEST_SUITE_END() // SetterGetter

BOOST_AUTO_TEST_SUITE_END()

} // namespace tests
} // namespace nac
} // namespace ndn
