mirror of
https://github.com/kemko/nomad.git
synced 2026-01-02 00:15:43 +03:00
The Nomad clients store their Nomad identity in memory and within their state store. While active, it is not possible to dump the state to view the stored identity token, so having a way to view the current claims while running aids debugging and operations. This change adds a client identity workflow, allowing operators to view the current claims of the nodes identity. It does not return any of the signing key material.
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package api
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/api/internal/testutil"
|
|
"github.com/shoenig/test/must"
|
|
)
|
|
|
|
func TestNodeIdentity_Get(t *testing.T) {
|
|
testutil.Parallel(t)
|
|
|
|
configCallback := func(c *testutil.TestServerConfig) { c.DevMode = true }
|
|
testClient, testServer := makeClient(t, nil, configCallback)
|
|
defer testServer.Stop()
|
|
|
|
nodeID := oneNodeFromNodeList(t, testClient.Nodes()).ID
|
|
|
|
req := NodeIdentityGetRequest{
|
|
NodeID: nodeID,
|
|
}
|
|
|
|
resp, err := testClient.Nodes().Identity().Get(&req, nil)
|
|
must.NoError(t, err)
|
|
must.NotNil(t, resp)
|
|
must.MapLen(t, 9, resp.Claims)
|
|
}
|
|
|
|
func TestNodeIdentity_Renew(t *testing.T) {
|
|
testutil.Parallel(t)
|
|
|
|
configCallback := func(c *testutil.TestServerConfig) { c.DevMode = true }
|
|
testClient, testServer := makeClient(t, nil, configCallback)
|
|
defer testServer.Stop()
|
|
|
|
nodeID := oneNodeFromNodeList(t, testClient.Nodes()).ID
|
|
|
|
req := NodeIdentityRenewRequest{
|
|
NodeID: nodeID,
|
|
}
|
|
|
|
resp, err := testClient.Nodes().Identity().Renew(&req, nil)
|
|
must.NoError(t, err)
|
|
must.NotNil(t, resp)
|
|
}
|