Merge pull request #3388 from hashicorp/b-migration-fixes
Test fixes from #3383
This commit is contained in:
commit
799a928812
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/hashicorp/nomad/testutil"
|
||||
"github.com/mitchellh/hashstructure"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/crypto/blake2b"
|
||||
|
||||
ctestutil "github.com/hashicorp/nomad/client/testutil"
|
||||
)
|
||||
|
@ -974,12 +973,9 @@ func TestClient_ValidateMigrateToken_ValidToken(t *testing.T) {
|
|||
defer c.Shutdown()
|
||||
|
||||
alloc := mock.Alloc()
|
||||
h, err := blake2b.New512([]byte(c.secretNodeID()))
|
||||
validToken, err := nomad.GenerateMigrateToken(alloc.ID, c.secretNodeID())
|
||||
assert.Nil(err)
|
||||
|
||||
h.Write([]byte(alloc.ID))
|
||||
validToken := string(h.Sum(nil))
|
||||
|
||||
assert.Equal(c.ValidateMigrateToken(alloc.ID, validToken), true)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
|
||||
"github.com/golang/snappy"
|
||||
"github.com/hashicorp/nomad/acl"
|
||||
"github.com/hashicorp/nomad/nomad"
|
||||
"github.com/hashicorp/nomad/nomad/mock"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/crypto/blake2b"
|
||||
)
|
||||
|
||||
func TestHTTP_AllocsList(t *testing.T) {
|
||||
|
@ -318,18 +318,6 @@ func TestHTTP_AllocSnapshot(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func createMigrateTokenForClientAndAlloc(allocID, clientSecret string) (string, error) {
|
||||
h, err := blake2b.New512([]byte(clientSecret))
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
h.Write([]byte(allocID))
|
||||
validMigrateToken, err := string(h.Sum(nil)), nil
|
||||
return validMigrateToken, err
|
||||
}
|
||||
|
||||
func TestHTTP_AllocSnapshot_WithMigrateToken(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert := assert.New(t)
|
||||
|
@ -347,7 +335,7 @@ func TestHTTP_AllocSnapshot_WithMigrateToken(t *testing.T) {
|
|||
// Create an allocation
|
||||
alloc := mock.Alloc()
|
||||
|
||||
validMigrateToken, err := createMigrateTokenForClientAndAlloc(alloc.ID, s.Agent.Client().Node().SecretID)
|
||||
validMigrateToken, err := nomad.GenerateMigrateToken(alloc.ID, s.Agent.Client().Node().SecretID)
|
||||
assert.Nil(err)
|
||||
|
||||
// Request with a token succeeds
|
||||
|
|
Loading…
Reference in a new issue