Files
nomad/client/identity_test.go
James Rasell 8096ea4129 client: Handle identities from servers and use for RPC auth. (#26218)
Nomad servers, if upgraded, can return node identities as part of
the register and update/heartbeat response objects. The Nomad
client will now handle this and store it as appropriate within its
memory and statedb.

The client will now use any stored identity for RPC authentication
with a fallback to the secretID. This supports upgrades paths where
the Nomad clients are updated before the Nomad servers.
2025-07-14 14:24:43 +01:00

33 lines
858 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package client
import (
"testing"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/client/serviceregistration/nsd"
"github.com/hashicorp/nomad/client/widmgr"
"github.com/shoenig/test/must"
)
var (
_ NodeIdentityHandler = (*widmgr.Signer)(nil)
_ NodeIdentityHandler = (*nsd.ServiceRegistrationHandler)(nil)
)
func Test_assertAndSetNodeIdentityToken(t *testing.T) {
ci.Parallel(t)
// Call the function with a non-nil object that implements the interface and
// verify that SetNodeIdentityToken is called with the expected token.
testImpl := &testHandler{}
assertAndSetNodeIdentityToken(testImpl, "test-token")
must.Eq(t, "test-token", testImpl.t)
}
type testHandler struct{ t string }
func (t *testHandler) SetNodeIdentityToken(token string) { t.t = token }