From b5fd075d7465e383206a7eb697377887c2dd9760 Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Fri, 13 Oct 2017 15:45:35 -0700 Subject: [PATCH] Test fixes from #3383 --- client/client_test.go | 6 +----- command/agent/alloc_endpoint_test.go | 16 ++-------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index b3d36cb50..c69e834cb 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -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) } diff --git a/command/agent/alloc_endpoint_test.go b/command/agent/alloc_endpoint_test.go index 102bb5d25..80d4616d8 100644 --- a/command/agent/alloc_endpoint_test.go +++ b/command/agent/alloc_endpoint_test.go @@ -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