// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/unexportable_keys/ref_counted_unexportable_key.h"

#include <memory>

#include "components/unexportable_keys/unexportable_key_id.h"
#include "crypto/mock_unexportable_key.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace unexportable_keys {

TEST(RefCountedUnexportableKeyTest, RefCountedUnexportableSigningKey) {
  auto mock_key = std::make_unique<crypto::MockUnexportableSigningKey>();
  crypto::UnexportableSigningKey* mock_key_ptr = mock_key.get();
  auto ref_counted_key =
      MakeRefCountedUnexportableSigningKey(std::move(mock_key));

  EXPECT_EQ(&ref_counted_key->key(), mock_key_ptr);
  EXPECT_FALSE(ref_counted_key->id()->is_empty());
}

TEST(RefCountedUnexportableKeyTest, RefCountedUnexportableAttestationKey) {
  auto mock_key = std::make_unique<crypto::MockUnexportableAttestationKey>();
  crypto::UnexportableAttestationKey* mock_key_ptr = mock_key.get();
  auto ref_counted_key =
      MakeRefCountedUnexportableAttestationKey(std::move(mock_key));

  EXPECT_EQ(&ref_counted_key->key(), mock_key_ptr);
  EXPECT_FALSE(ref_counted_key->id()->is_empty());
}

}  // namespace unexportable_keys
