diff options
author | cinlin <cinlin@google.com> | 2023-07-13 13:43:53 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-07-13 13:44:47 -0700 |
commit | 0bbdfd84df04e7b8fe7da3217627bb9a9febb163 (patch) | |
tree | 2027105a64e77c9e0b27589845ea9cc95a1a9b11 /cc/core | |
parent | d26ed0209a33cd88a951ed9c2e17dd330baa9696 (diff) | |
download | tink-0bbdfd84df04e7b8fe7da3217627bb9a9febb163.tar.gz |
Move KeyGen/ConfigGlobalRegistry to public API. #tinkApiChange
PiperOrigin-RevId: 547908174
Diffstat (limited to 'cc/core')
-rw-r--r-- | cc/core/keyset_handle_test.cc | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/cc/core/keyset_handle_test.cc b/cc/core/keyset_handle_test.cc index 539dc2c77..91aad8eff 100644 --- a/cc/core/keyset_handle_test.cc +++ b/cc/core/keyset_handle_test.cc @@ -34,7 +34,7 @@ #include "tink/binary_keyset_writer.h" #include "tink/cleartext_keyset_handle.h" #include "tink/config/fips_140_2.h" -#include "tink/config/internal/global_registry.h" +#include "tink/config/global_registry.h" #include "tink/config/key_gen_fips_140_2.h" #include "tink/config/tink_config.h" #include "tink/core/key_manager_impl.h" @@ -581,12 +581,11 @@ TEST_F(KeysetHandleTest, GenerateNew) { &AeadKeyTemplates::Aes128CtrHmacSha256(), &AeadKeyTemplates::Aes256CtrHmacSha256(), }; - KeyGenConfiguration config; - ASSERT_THAT(internal::KeyGenConfigurationImpl::SetGlobalRegistryMode(config), - IsOk()); for (auto templ : templates) { EXPECT_THAT(KeysetHandle::GenerateNew(*templ).status(), IsOk()); - EXPECT_THAT(KeysetHandle::GenerateNew(*templ, config).status(), IsOk()); + EXPECT_THAT(KeysetHandle::GenerateNew(*templ, KeyGenConfigGlobalRegistry()) + .status(), + IsOk()); } } @@ -605,10 +604,8 @@ TEST_F(KeysetHandleTest, GenerateNewWithBespokeConfig) { } TEST_F(KeysetHandleTest, GenerateNewWithGlobalRegistryConfig) { - KeyGenConfiguration config; - ASSERT_THAT(internal::KeyGenConfigurationImpl::SetGlobalRegistryMode(config), - IsOk()); - EXPECT_THAT(KeysetHandle::GenerateNew(AeadKeyTemplates::Aes128Gcm(), config), + EXPECT_THAT(KeysetHandle::GenerateNew(AeadKeyTemplates::Aes128Gcm(), + KeyGenConfigGlobalRegistry()), IsOk()); } @@ -622,12 +619,9 @@ TEST_F(KeysetHandleTest, GenerateNewWithAnnotations) { ASSERT_THAT(handle, IsOk()); // `config_handle` uses a config that depends on the global registry. - KeyGenConfiguration config; - ASSERT_THAT(internal::KeyGenConfigurationImpl::SetGlobalRegistryMode(config), - IsOk()); util::StatusOr<std::unique_ptr<KeysetHandle>> config_handle = - KeysetHandle::GenerateNew(AeadKeyTemplates::Aes128Gcm(), config, - kAnnotations); + KeysetHandle::GenerateNew(AeadKeyTemplates::Aes128Gcm(), + KeyGenConfigGlobalRegistry(), kAnnotations); ASSERT_THAT(config_handle, IsOk()); for (KeysetHandle h : {**handle, **config_handle}) { @@ -853,14 +847,10 @@ TEST_F(KeysetHandleTest, GetPrimitiveWithBespokeConfigFailsIfEmpty) { TEST_F(KeysetHandleTest, GetPrimitiveWithGlobalRegistryConfig) { util::StatusOr<std::unique_ptr<KeysetHandle>> handle = KeysetHandle::GenerateNew(AeadKeyTemplates::Aes128Gcm(), - internal::KeyGenConfigGlobalRegistry()); + KeyGenConfigGlobalRegistry()); ASSERT_THAT(handle, IsOk()); - // TODO(b/265705174): Replace with ConfigGlobalRegistry instance. - Configuration config; - ASSERT_THAT(internal::ConfigurationImpl::SetGlobalRegistryMode(config), - IsOk()); - EXPECT_THAT((*handle)->GetPrimitive<Aead>(config), IsOk()); + EXPECT_THAT((*handle)->GetPrimitive<Aead>(ConfigGlobalRegistry()), IsOk()); } TEST_F(KeysetHandleTest, GetPrimitiveWithConfigFips1402) { |