Clean up some dev config kms code (#2321)

* Clean up some dev config kms code

Although it didn't matter in the combined state, the KMS for auth
storage was not actually being set properly if only a worker was being
instantiated.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2022-08-05 12:12:07 -04:00
1 parent 661d6a551e
commit 090b2b28f8
5 files changed
+44 -36

No files matched your search

+2 -2
View File
@@ -85,7 +85,7 @@ func TestRotationTicking(t *testing.T) {
require.NoError(err)
assert.Len(auths, 1)
// Fetch creds and store current key
currNodeCreds, err := types.LoadNodeCredentials(w.Context(), w.Worker().WorkerAuthStorage, nodeenrollment.CurrentId)
currNodeCreds, err := types.LoadNodeCredentials(w.Context(), w.Worker().WorkerAuthStorage, nodeenrollment.CurrentId, nodeenrollment.WithWrapper(w.Config().WorkerAuthStorageKms))
require.NoError(err)
currKey := currNodeCreds.CertificatePublicKeyPkix
@@ -101,7 +101,7 @@ func TestRotationTicking(t *testing.T) {
assert.Len(auths, i)
// Fetch creds and compare current key
currNodeCreds, err := types.LoadNodeCredentials(w.Context(), w.Worker().WorkerAuthStorage, nodeenrollment.CurrentId)
currNodeCreds, err := types.LoadNodeCredentials(w.Context(), w.Worker().WorkerAuthStorage, nodeenrollment.CurrentId, nodeenrollment.WithWrapper(w.Config().WorkerAuthStorageKms))
require.NoError(err)
assert.NotEqual(currKey, currNodeCreds.CertificatePublicKeyPkix)
currKey = currNodeCreds.CertificatePublicKeyPkix
+1
View File
@@ -225,6 +225,7 @@ func NewTestWorker(t testing.TB, opts *TestWorkerOpts) *TestWorker {
// Base server
tw.b = base.NewServer(nil)
tw.b.Command = &base.Command{
Context: ctx,
ShutdownCh: make(chan struct{}),
}
+6 -1
View File
@@ -112,7 +112,12 @@ func TestTestWorker_WorkerAuthStorageKms(t *testing.T) {
tw := NewTestWorker(t, &TestWorkerOpts{
WorkerAuthStorageKms: tt.wrapper,
})
require.Equal(tt.wrapper, tw.Config().WorkerAuthStorageKms)
if tt.wrapper == nil {
// DevWorker config will create one
require.NotNil(tw.Config().WorkerAuthStorageKms)
} else {
require.Equal(tt.wrapper, tw.Config().WorkerAuthStorageKms)
}
})
}
}