mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
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.
33 lines
858 B
Go
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 }
|