Skip to content

Commit

Permalink
Rename internalapitoken to internalapi.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 587059071
Change-Id: I51b01aeba606cdaeb857cbef394b708eaf01d17d
  • Loading branch information
chuckx authored and copybara-github committed Dec 1, 2023
1 parent a077195 commit 6db1b13
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
package(default_visibility = ["//:__subpackages__"]) # keep

go_library(
name = "internalapitoken",
srcs = ["internalapitoken.go"],
importpath = "github.com/tink-crypto/tink-go/v2/internal/internalapitoken",
name = "internalapi",
srcs = ["token.go"],
importpath = "github.com/tink-crypto/tink-go/v2/internal/internalapi",
)

alias(
name = "go_default_library",
actual = ":internalapitoken",
actual = ":internalapi",
visibility = ["//:__subpackages__"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
//
////////////////////////////////////////////////////////////////////////////////

// Package internalapitoken provides a token that restricts access to Tink APIs
// that must be exported from their public packages but shouldn't be accessed by
// Tink users.
package internalapitoken
// Package internalapi provides a token that restricts access to Tink APIs.
package internalapi

// InternalAPIToken is the token described above.
type InternalAPIToken struct{}
// Token is used to restrict access to APIs that must be exported from their
// public packages but shouldn't be accessed by Tink users.
type Token struct{}
4 changes: 2 additions & 2 deletions internal/registryconfig/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go_library(
visibility = ["//keyset:__subpackages__"],
deps = [
"//core/registry",
"//internal/internalapitoken",
"//internal/internalapi",
"//proto/tink_go_proto",
],
)
Expand All @@ -24,7 +24,7 @@ go_test(
deps = [
":registryconfig",
"//core/registry",
"//internal/internalapitoken",
"//internal/internalapi",
"//mac/subtle",
"//proto/common_go_proto",
"//proto/tink_go_proto",
Expand Down
6 changes: 3 additions & 3 deletions internal/registryconfig/registry_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package registryconfig

import (
"github.com/tink-crypto/tink-go/v2/core/registry"
"github.com/tink-crypto/tink-go/v2/internal/internalapitoken"
"github.com/tink-crypto/tink-go/v2/internal/internalapi"
tinkpb "github.com/tink-crypto/tink-go/v2/proto/tink_go_proto"
)

Expand All @@ -31,12 +31,12 @@ type RegistryConfig struct{}

// PrimitiveFromKeyData creates a primitive from KeyData by forwarding the
// KeyData straight to the Registry.
func (c *RegistryConfig) PrimitiveFromKeyData(keyData *tinkpb.KeyData, _ internalapitoken.InternalAPIToken) (any, error) {
func (c *RegistryConfig) PrimitiveFromKeyData(keyData *tinkpb.KeyData, _ internalapi.Token) (any, error) {
return registry.PrimitiveFromKeyData(keyData)
}

// RegisterKeyManager registers a provided KeyManager by forwarding it directly
// to the Registry.
func (c *RegistryConfig) RegisterKeyManager(km registry.KeyManager, _ internalapitoken.InternalAPIToken) error {
func (c *RegistryConfig) RegisterKeyManager(km registry.KeyManager, _ internalapi.Token) error {
return registry.RegisterKeyManager(km)
}
8 changes: 4 additions & 4 deletions internal/registryconfig/registry_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"google.golang.org/protobuf/proto"
"github.com/tink-crypto/tink-go/v2/core/registry"
"github.com/tink-crypto/tink-go/v2/internal/internalapitoken"
"github.com/tink-crypto/tink-go/v2/internal/internalapi"
"github.com/tink-crypto/tink-go/v2/internal/registryconfig"
"github.com/tink-crypto/tink-go/v2/mac/subtle"
"github.com/tink-crypto/tink-go/v2/testutil"
Expand All @@ -32,7 +32,7 @@ import (
func TestPrimitiveFromKeyData(t *testing.T) {
keyData := testutil.NewHMACKeyData(commonpb.HashType_SHA256, 16)
registryConfig := &registryconfig.RegistryConfig{}
p, err := registryConfig.PrimitiveFromKeyData(keyData, internalapitoken.InternalAPIToken{})
p, err := registryConfig.PrimitiveFromKeyData(keyData, internalapi.Token{})
if err != nil {
t.Errorf("registryConfig.PrimitiveFromKeyData() err = %v, want nil", err)
}
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestPrimitiveFromKeyDataErrors(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if _, err := registryConfig.PrimitiveFromKeyData(tc.keyData, internalapitoken.InternalAPIToken{}); err == nil {
if _, err := registryConfig.PrimitiveFromKeyData(tc.keyData, internalapi.Token{}); err == nil {
t.Errorf("registryConfig.Primitive() err = nil, want not-nil")
}
})
Expand All @@ -90,7 +90,7 @@ func (km *testKeyManager) NewKeyData(_ []byte) (*tinkpb.KeyData, error) { return

func TestRegisterKeyManager(t *testing.T) {
registryConfig := &registryconfig.RegistryConfig{}
if err := registryConfig.RegisterKeyManager(new(testKeyManager), internalapitoken.InternalAPIToken{}); err != nil {
if err := registryConfig.RegisterKeyManager(new(testKeyManager), internalapi.Token{}); err != nil {
t.Fatalf("registryConfig.RegisterKeyManager() err = %v, want nil", err)
}
if _, err := registry.GetKeyManager("testKeyManager"); err != nil {
Expand Down

0 comments on commit 6db1b13

Please sign in to comment.