mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
This change implements the client -> server workflow for Nomad node introduction. A Nomad node can optionally be started with an introduction token, which is a signed JWT containing claims for the node registration. The server handles this according to the enforcement configuration. The introduction token can be provided by env var, cli flag, or by placing it within a default filesystem location. The latter option does not override the CLI or env var. The region claims has been removed from the initial claims set of the intro identity. This boundary is guarded by mTLS and aligns with the node identity.
37 lines
843 B
Go
37 lines
843 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package helper
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/nomad/ci"
|
|
"github.com/shoenig/test/must"
|
|
)
|
|
|
|
func Test_ReadFileContent(t *testing.T) {
|
|
ci.Parallel(t)
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
rootDir, err := os.OpenRoot(tmpDir)
|
|
must.NoError(t, err)
|
|
t.Cleanup(func() { must.NoError(t, rootDir.Close()) })
|
|
|
|
rootFile, err := rootDir.OpenFile("testfile.txt", os.O_CREATE|os.O_RDWR, 0777)
|
|
must.NoError(t, err)
|
|
|
|
_, err = rootFile.WriteString("Hello, World!")
|
|
must.NoError(t, err)
|
|
must.NoError(t, rootFile.Close())
|
|
|
|
// Reopen the file using os.OpenInRoot to simulate reading from a root
|
|
// file.
|
|
rootFileRead, err := os.OpenInRoot(tmpDir, "testfile.txt")
|
|
data, err := ReadFileContent(rootFileRead)
|
|
must.NoError(t, err)
|
|
must.Eq(t, "Hello, World!", string(data))
|
|
}
|