Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
f0629e57
Commit
f0629e57
authored
2 years ago
by
Tim Gross
Browse files
Options
Download
Email Patches
Plain Diff
[wip] failing test
parent
22eb7fa9
Branches unavailable
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nomad/encrypter_test.go
+65
-0
nomad/encrypter_test.go
with
65 additions
and
0 deletions
+65
-0
nomad/encrypter_test.go
0 → 100644
+
65
-
0
View file @
f0629e57
package
nomad
import
(
"testing"
msgpackrpc
"github.com/hashicorp/net-rpc-msgpackrpc"
"github.com/stretchr/testify/require"
"github.com/hashicorp/nomad/ci"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/testutil"
)
// TestEncrypter_LoadSave exercises loading and saving keys in the keystore
func
TestEncrypter_LoadSave
(
t
*
testing
.
T
)
{
ci
.
Parallel
(
t
)
// use a known tempdir so that we can restore from it
tmpDir
:=
t
.
TempDir
()
srv
,
rootToken
,
shutdown
:=
TestACLServer
(
t
,
func
(
c
*
Config
)
{
c
.
NumSchedulers
=
0
// Prevent automatic dequeue
c
.
DataDir
=
tmpDir
})
defer
shutdown
()
testutil
.
WaitForLeader
(
t
,
srv
.
RPC
)
codec
:=
rpcClient
(
t
,
srv
)
// Send a few key rotations so that we add keys
rotateReq
:=
&
structs
.
KeyringRotateRootKeyRequest
{
WriteRequest
:
structs
.
WriteRequest
{
Region
:
"global"
,
AuthToken
:
rootToken
.
SecretID
,
},
}
var
rotateResp
structs
.
KeyringRotateRootKeyResponse
for
i
:=
0
;
i
<
4
;
i
++
{
err
:=
msgpackrpc
.
CallWithCodec
(
codec
,
"Keyring.Rotate"
,
rotateReq
,
&
rotateResp
)
require
.
NoError
(
t
,
err
)
}
shutdown
()
srv
,
rootToken
,
shutdown2
:=
TestACLServer
(
t
,
func
(
c
*
Config
)
{
c
.
NumSchedulers
=
0
c
.
DataDir
=
tmpDir
})
defer
shutdown2
()
testutil
.
WaitForLeader
(
t
,
srv
.
RPC
)
codec
=
rpcClient
(
t
,
srv
)
// Verify we've restored all the keys from the old keystore
listReq
:=
&
structs
.
KeyringListRootKeyMetaRequest
{
QueryOptions
:
structs
.
QueryOptions
{
Region
:
"global"
,
},
}
var
listResp
structs
.
KeyringListRootKeyMetaResponse
err
:=
msgpackrpc
.
CallWithCodec
(
codec
,
"Keyring.List"
,
listReq
,
&
listResp
)
require
.
NoError
(
t
,
err
)
require
.
Len
(
t
,
listResp
.
Keys
,
4
)
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help