2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2017-08-20 23:00:54 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2022-10-20 07:37:32 +00:00
|
|
|
"time"
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/acl"
|
2022-03-15 12:42:43 +00:00
|
|
|
"github.com/hashicorp/nomad/ci"
|
2017-08-20 23:00:54 +00:00
|
|
|
"github.com/hashicorp/nomad/client/config"
|
2022-10-20 07:37:32 +00:00
|
|
|
"github.com/hashicorp/nomad/helper/pointer"
|
2017-09-29 16:58:48 +00:00
|
|
|
"github.com/hashicorp/nomad/helper/uuid"
|
2017-08-20 23:00:54 +00:00
|
|
|
"github.com/hashicorp/nomad/nomad/mock"
|
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
"github.com/hashicorp/nomad/testutil"
|
2023-02-27 18:17:47 +00:00
|
|
|
"github.com/shoenig/test"
|
2022-10-20 07:37:32 +00:00
|
|
|
"github.com/shoenig/test/must"
|
2017-08-20 23:00:54 +00:00
|
|
|
)
|
|
|
|
|
2022-10-20 07:37:32 +00:00
|
|
|
func Test_clientACLResolver_init(t *testing.T) {
|
2023-02-08 21:20:33 +00:00
|
|
|
resolver := new(clientACLResolver)
|
|
|
|
resolver.init()
|
2022-10-20 07:37:32 +00:00
|
|
|
must.NotNil(t, resolver.aclCache)
|
|
|
|
must.NotNil(t, resolver.policyCache)
|
|
|
|
must.NotNil(t, resolver.tokenCache)
|
|
|
|
must.NotNil(t, resolver.roleCache)
|
|
|
|
}
|
|
|
|
|
2017-08-20 23:00:54 +00:00
|
|
|
func TestClient_ACL_resolveTokenValue(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
|
|
|
|
2019-12-04 00:15:11 +00:00
|
|
|
s1, _, _, cleanupS1 := testACLServer(t, nil)
|
|
|
|
defer cleanupS1()
|
2017-08-20 23:00:54 +00:00
|
|
|
testutil.WaitForLeader(t, s1.RPC)
|
|
|
|
|
2018-10-16 03:07:16 +00:00
|
|
|
c1, cleanup := TestClient(t, func(c *config.Config) {
|
2017-08-20 23:00:54 +00:00
|
|
|
c.RPCHandler = s1
|
2017-08-22 00:31:32 +00:00
|
|
|
c.ACLEnabled = true
|
2017-08-20 23:00:54 +00:00
|
|
|
})
|
2018-10-16 03:07:16 +00:00
|
|
|
defer cleanup()
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Create a policy / token
|
|
|
|
policy := mock.ACLPolicy()
|
|
|
|
policy2 := mock.ACLPolicy()
|
|
|
|
token := mock.ACLToken()
|
|
|
|
token.Policies = []string{policy.Name, policy2.Name}
|
|
|
|
token2 := mock.ACLToken()
|
|
|
|
token2.Type = structs.ACLManagementToken
|
|
|
|
token2.Policies = nil
|
2020-12-01 16:11:34 +00:00
|
|
|
err := s1.State().UpsertACLPolicies(structs.MsgTypeTestSetup, 100, []*structs.ACLPolicy{policy, policy2})
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
2020-12-01 16:11:34 +00:00
|
|
|
err = s1.State().UpsertACLTokens(structs.MsgTypeTestSetup, 110, []*structs.ACLToken{token, token2})
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Test the client resolution
|
|
|
|
out0, err := c1.resolveTokenValue("")
|
2023-02-27 18:17:47 +00:00
|
|
|
test.Nil(t, err)
|
|
|
|
must.NotNil(t, out0)
|
|
|
|
test.Eq(t, structs.AnonymousACLToken, out0.ACLToken)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
out1, err := c1.resolveTokenValue(token.SecretID)
|
2023-02-27 18:17:47 +00:00
|
|
|
test.Nil(t, err)
|
|
|
|
must.NotNil(t, out1)
|
|
|
|
test.Eq(t, token, out1.ACLToken)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
out2, err := c1.resolveTokenValue(token2.SecretID)
|
2023-02-27 18:17:47 +00:00
|
|
|
test.Nil(t, err)
|
|
|
|
must.NotNil(t, out2)
|
|
|
|
test.Eq(t, token2, out2.ACLToken)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
out3, err := c1.resolveTokenValue(token.SecretID)
|
2023-02-27 18:17:47 +00:00
|
|
|
test.Nil(t, err)
|
|
|
|
must.Eq(t, out1, out3, must.Sprintf("bad caching"))
|
2017-08-20 23:00:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestClient_ACL_resolvePolicies(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
|
|
|
|
2019-12-04 00:15:11 +00:00
|
|
|
s1, _, root, cleanupS1 := testACLServer(t, nil)
|
|
|
|
defer cleanupS1()
|
2017-08-20 23:00:54 +00:00
|
|
|
testutil.WaitForLeader(t, s1.RPC)
|
|
|
|
|
2018-10-16 03:07:16 +00:00
|
|
|
c1, cleanup := TestClient(t, func(c *config.Config) {
|
2017-08-20 23:00:54 +00:00
|
|
|
c.RPCHandler = s1
|
2017-08-22 00:31:32 +00:00
|
|
|
c.ACLEnabled = true
|
2017-08-20 23:00:54 +00:00
|
|
|
})
|
2018-10-16 03:07:16 +00:00
|
|
|
defer cleanup()
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Create a policy / token
|
|
|
|
policy := mock.ACLPolicy()
|
|
|
|
policy2 := mock.ACLPolicy()
|
|
|
|
token := mock.ACLToken()
|
|
|
|
token.Policies = []string{policy.Name, policy2.Name}
|
|
|
|
token2 := mock.ACLToken()
|
|
|
|
token2.Type = structs.ACLManagementToken
|
|
|
|
token2.Policies = nil
|
2020-12-01 16:11:34 +00:00
|
|
|
err := s1.State().UpsertACLPolicies(structs.MsgTypeTestSetup, 100, []*structs.ACLPolicy{policy, policy2})
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
2020-12-01 16:11:34 +00:00
|
|
|
err = s1.State().UpsertACLTokens(structs.MsgTypeTestSetup, 110, []*structs.ACLToken{token, token2})
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Test the client resolution
|
2017-08-22 00:31:32 +00:00
|
|
|
out, err := c1.resolvePolicies(root.SecretID, []string{policy.Name, policy2.Name})
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
test.Len(t, 2, out)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Test caching
|
2017-08-22 00:31:32 +00:00
|
|
|
out2, err := c1.resolvePolicies(root.SecretID, []string{policy.Name, policy2.Name})
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
test.Len(t, 2, out2)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Check we get the same objects back (ignore ordering)
|
|
|
|
if out[0] != out2[0] && out[0] != out2[1] {
|
|
|
|
t.Fatalf("bad caching")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-20 07:37:32 +00:00
|
|
|
func TestClient_resolveTokenACLRoles(t *testing.T) {
|
|
|
|
ci.Parallel(t)
|
|
|
|
|
|
|
|
testServer, _, rootACLToken, testServerCleanupS1 := testACLServer(t, nil)
|
|
|
|
defer testServerCleanupS1()
|
|
|
|
testutil.WaitForLeader(t, testServer.RPC)
|
|
|
|
|
|
|
|
testClient, cleanup := TestClient(t, func(c *config.Config) {
|
|
|
|
c.RPCHandler = testServer
|
|
|
|
c.ACLEnabled = true
|
|
|
|
})
|
|
|
|
defer cleanup()
|
|
|
|
|
|
|
|
// Create an ACL Role and a client token which is linked to this.
|
2023-09-11 12:22:30 +00:00
|
|
|
mockACLRole1 := mock.ACLRole()
|
2022-10-20 07:37:32 +00:00
|
|
|
|
|
|
|
mockACLToken := mock.ACLToken()
|
|
|
|
mockACLToken.Policies = []string{}
|
2023-09-11 12:22:30 +00:00
|
|
|
mockACLToken.Roles = []*structs.ACLTokenRoleLink{{ID: mockACLRole1.ID}}
|
2022-10-20 07:37:32 +00:00
|
|
|
|
2023-09-11 12:22:30 +00:00
|
|
|
err := testServer.State().UpsertACLRoles(structs.MsgTypeTestSetup, 10, []*structs.ACLRole{mockACLRole1}, true)
|
2022-10-20 07:37:32 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
err = testServer.State().UpsertACLTokens(structs.MsgTypeTestSetup, 20, []*structs.ACLToken{mockACLToken})
|
|
|
|
must.NoError(t, err)
|
|
|
|
|
|
|
|
// Resolve the ACL policies linked via the role.
|
|
|
|
resolvedRoles1, err := testClient.resolveTokenACLRoles(rootACLToken.SecretID, mockACLToken.Roles)
|
|
|
|
must.NoError(t, err)
|
|
|
|
must.Len(t, 2, resolvedRoles1)
|
|
|
|
|
|
|
|
// Test the cache directly and check that the ACL role previously queried
|
|
|
|
// is now cached.
|
|
|
|
must.Eq(t, 1, testClient.roleCache.Len())
|
2023-09-11 12:22:30 +00:00
|
|
|
must.True(t, testClient.roleCache.Contains(mockACLRole1.ID))
|
2022-10-20 07:37:32 +00:00
|
|
|
|
|
|
|
// Resolve the roles again to check we get the same results.
|
|
|
|
resolvedRoles2, err := testClient.resolveTokenACLRoles(rootACLToken.SecretID, mockACLToken.Roles)
|
|
|
|
must.NoError(t, err)
|
|
|
|
must.SliceContainsAll(t, resolvedRoles1, resolvedRoles2)
|
2023-09-11 12:22:30 +00:00
|
|
|
|
|
|
|
// Create another ACL role which will have the same ACL policy links as the
|
|
|
|
// previous
|
|
|
|
mockACLRole2 := mock.ACLRole()
|
|
|
|
must.NoError(t,
|
|
|
|
testServer.State().UpsertACLRoles(
|
|
|
|
structs.MsgTypeTestSetup, 30, []*structs.ACLRole{mockACLRole2}, true))
|
|
|
|
|
|
|
|
// Update the ACL token so that it links to two ACL roles, which include
|
|
|
|
// duplicate ACL policies.
|
|
|
|
mockACLToken.Roles = append(mockACLToken.Roles, &structs.ACLTokenRoleLink{ID: mockACLRole2.ID})
|
|
|
|
must.NoError(t,
|
|
|
|
testServer.State().UpsertACLTokens(
|
|
|
|
structs.MsgTypeTestSetup, 40, []*structs.ACLToken{mockACLToken}))
|
|
|
|
|
|
|
|
// Ensure when resolving the ACL token, we are returned a deduplicated list
|
|
|
|
// of ACL policy names.
|
|
|
|
resolvedRoles3, err := testClient.resolveTokenACLRoles(rootACLToken.SecretID, mockACLToken.Roles)
|
|
|
|
must.NoError(t, err)
|
|
|
|
must.SliceContainsAll(t, []string{"mocked-test-policy-1", "mocked-test-policy-2"}, resolvedRoles3)
|
2022-10-20 07:37:32 +00:00
|
|
|
}
|
|
|
|
|
2017-08-23 20:49:08 +00:00
|
|
|
func TestClient_ACL_ResolveToken_Disabled(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
|
|
|
|
2019-12-04 00:15:11 +00:00
|
|
|
s1, _, cleanupS1 := testServer(t, nil)
|
|
|
|
defer cleanupS1()
|
2017-08-20 23:00:54 +00:00
|
|
|
testutil.WaitForLeader(t, s1.RPC)
|
|
|
|
|
2018-10-16 03:07:16 +00:00
|
|
|
c1, cleanup := TestClient(t, func(c *config.Config) {
|
2017-08-20 23:00:54 +00:00
|
|
|
c.RPCHandler = s1
|
|
|
|
})
|
2018-10-16 03:07:16 +00:00
|
|
|
defer cleanup()
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Should always get nil when disabled
|
2017-08-23 20:49:08 +00:00
|
|
|
aclObj, err := c1.ResolveToken("blah")
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
must.Nil(t, aclObj)
|
2017-08-20 23:00:54 +00:00
|
|
|
}
|
|
|
|
|
2017-08-23 20:49:08 +00:00
|
|
|
func TestClient_ACL_ResolveToken(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
|
|
|
|
2019-12-04 00:15:11 +00:00
|
|
|
s1, _, _, cleanupS1 := testACLServer(t, nil)
|
|
|
|
defer cleanupS1()
|
2017-08-20 23:00:54 +00:00
|
|
|
testutil.WaitForLeader(t, s1.RPC)
|
|
|
|
|
2018-10-16 03:07:16 +00:00
|
|
|
c1, cleanup := TestClient(t, func(c *config.Config) {
|
2017-08-20 23:00:54 +00:00
|
|
|
c.RPCHandler = s1
|
|
|
|
c.ACLEnabled = true
|
|
|
|
})
|
2018-10-16 03:07:16 +00:00
|
|
|
defer cleanup()
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Create a policy / token
|
|
|
|
policy := mock.ACLPolicy()
|
|
|
|
policy2 := mock.ACLPolicy()
|
|
|
|
token := mock.ACLToken()
|
|
|
|
token.Policies = []string{policy.Name, policy2.Name}
|
|
|
|
token2 := mock.ACLToken()
|
|
|
|
token2.Type = structs.ACLManagementToken
|
|
|
|
token2.Policies = nil
|
2020-12-01 16:11:34 +00:00
|
|
|
err := s1.State().UpsertACLPolicies(structs.MsgTypeTestSetup, 100, []*structs.ACLPolicy{policy, policy2})
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
2020-12-01 16:11:34 +00:00
|
|
|
err = s1.State().UpsertACLTokens(structs.MsgTypeTestSetup, 110, []*structs.ACLToken{token, token2})
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Test the client resolution
|
2017-08-23 20:49:08 +00:00
|
|
|
out, err := c1.ResolveToken(token.SecretID)
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
test.NotNil(t, out)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Test caching
|
2017-08-23 20:49:08 +00:00
|
|
|
out2, err := c1.ResolveToken(token.SecretID)
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
must.Eq(t, out, out2, must.Sprintf("should be cached"))
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Test management token
|
2017-08-23 20:49:08 +00:00
|
|
|
out3, err := c1.ResolveToken(token2.SecretID)
|
2023-02-27 18:17:47 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
must.Eq(t, acl.ManagementACL, out3)
|
2017-08-20 23:00:54 +00:00
|
|
|
|
|
|
|
// Test bad token
|
2017-09-29 16:58:48 +00:00
|
|
|
out4, err := c1.ResolveToken(uuid.Generate())
|
2023-02-27 18:17:47 +00:00
|
|
|
test.EqError(t, err, structs.ErrPermissionDenied.Error())
|
|
|
|
test.Nil(t, out4)
|
2017-08-20 23:00:54 +00:00
|
|
|
}
|
2020-03-22 16:17:33 +00:00
|
|
|
|
2023-02-27 18:17:47 +00:00
|
|
|
func TestClient_ACL_ResolveToken_Expired(t *testing.T) {
|
2022-03-15 12:42:43 +00:00
|
|
|
ci.Parallel(t)
|
2020-03-22 16:17:33 +00:00
|
|
|
|
|
|
|
s1, _, _, cleanupS1 := testACLServer(t, nil)
|
|
|
|
defer cleanupS1()
|
|
|
|
testutil.WaitForLeader(t, s1.RPC)
|
|
|
|
|
|
|
|
c1, cleanup := TestClient(t, func(c *config.Config) {
|
|
|
|
c.RPCHandler = s1
|
|
|
|
c.ACLEnabled = true
|
|
|
|
})
|
|
|
|
defer cleanup()
|
|
|
|
|
2022-10-20 07:37:32 +00:00
|
|
|
// Create and upsert a token which has just expired.
|
|
|
|
mockExpiredToken := mock.ACLToken()
|
|
|
|
mockExpiredToken.ExpirationTime = pointer.Of(time.Now().Add(-5 * time.Minute))
|
|
|
|
|
2023-02-27 18:17:47 +00:00
|
|
|
err := s1.State().UpsertACLTokens(structs.MsgTypeTestSetup, 120, []*structs.ACLToken{mockExpiredToken})
|
2022-10-20 07:37:32 +00:00
|
|
|
must.NoError(t, err)
|
|
|
|
|
2023-02-27 18:17:47 +00:00
|
|
|
expiredTokenResp, err := c1.ResolveToken(mockExpiredToken.SecretID)
|
2022-10-20 07:37:32 +00:00
|
|
|
must.Nil(t, expiredTokenResp)
|
2023-02-27 18:17:47 +00:00
|
|
|
must.ErrorContains(t, err, "ACL token expired")
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestClient_ACL_ResolveToken_Claims asserts that ResolveToken
|
|
|
|
// properly resolves valid workload identity claims.
|
|
|
|
func TestClient_ACL_ResolveToken_Claims(t *testing.T) {
|
|
|
|
ci.Parallel(t)
|
|
|
|
|
|
|
|
s1, _, rootToken, cleanupS1 := testACLServer(t, nil)
|
|
|
|
defer cleanupS1()
|
|
|
|
testutil.WaitForLeader(t, s1.RPC)
|
|
|
|
|
|
|
|
c1, cleanup := TestClient(t, func(c *config.Config) {
|
|
|
|
c.RPCHandler = s1
|
|
|
|
c.ACLEnabled = true
|
|
|
|
})
|
|
|
|
defer cleanup()
|
|
|
|
|
|
|
|
// Create a minimal job
|
|
|
|
job := mock.MinJob()
|
|
|
|
|
|
|
|
// Add a job policy
|
|
|
|
polArgs := structs.ACLPolicyUpsertRequest{
|
|
|
|
Policies: []*structs.ACLPolicy{
|
|
|
|
{
|
|
|
|
Name: "nw",
|
|
|
|
Description: "test job can write to nodes",
|
|
|
|
Rules: `node { policy = "write" }`,
|
|
|
|
JobACL: &structs.JobACL{
|
|
|
|
Namespace: job.Namespace,
|
|
|
|
JobID: job.ID,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
WriteRequest: structs.WriteRequest{
|
|
|
|
Region: job.Region,
|
|
|
|
AuthToken: rootToken.SecretID,
|
|
|
|
Namespace: job.Namespace,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
polReply := structs.GenericResponse{}
|
|
|
|
must.NoError(t, s1.RPC("ACL.UpsertPolicies", &polArgs, &polReply))
|
|
|
|
must.NonZero(t, polReply.WriteMeta.Index)
|
|
|
|
|
|
|
|
allocs := testutil.WaitForRunningWithToken(t, s1.RPC, job, rootToken.SecretID)
|
|
|
|
must.Len(t, 1, allocs)
|
|
|
|
|
|
|
|
alloc, err := s1.State().AllocByID(nil, allocs[0].ID)
|
|
|
|
must.NoError(t, err)
|
|
|
|
must.MapContainsKey(t, alloc.SignedIdentities, "t")
|
|
|
|
wid := alloc.SignedIdentities["t"]
|
|
|
|
|
|
|
|
aclObj, err := c1.ResolveToken(wid)
|
|
|
|
must.NoError(t, err)
|
|
|
|
must.True(t, aclObj.AllowNodeWrite(), must.Sprintf("expected workload id to allow node write"))
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestClient_ACL_ResolveToken_InvalidClaims asserts that ResolveToken properly
|
|
|
|
// rejects invalid workload identity claims.
|
|
|
|
func TestClient_ACL_ResolveToken_InvalidClaims(t *testing.T) {
|
|
|
|
ci.Parallel(t)
|
|
|
|
|
|
|
|
s1, _, rootToken, cleanupS1 := testACLServer(t, nil)
|
|
|
|
defer cleanupS1()
|
|
|
|
testutil.WaitForLeader(t, s1.RPC)
|
|
|
|
|
|
|
|
c1, cleanup := TestClient(t, func(c *config.Config) {
|
|
|
|
c.RPCHandler = s1
|
|
|
|
c.ACLEnabled = true
|
|
|
|
})
|
|
|
|
defer cleanup()
|
|
|
|
|
|
|
|
// Create a minimal job
|
|
|
|
job := mock.MinJob()
|
|
|
|
allocs := testutil.WaitForRunningWithToken(t, s1.RPC, job, rootToken.SecretID)
|
|
|
|
must.Len(t, 1, allocs)
|
|
|
|
|
|
|
|
// Get wid while it's still running
|
|
|
|
alloc, err := s1.State().AllocByID(nil, allocs[0].ID)
|
|
|
|
must.NoError(t, err)
|
|
|
|
must.MapContainsKey(t, alloc.SignedIdentities, "t")
|
|
|
|
wid := alloc.SignedIdentities["t"]
|
|
|
|
|
|
|
|
// Stop job
|
|
|
|
deregArgs := structs.JobDeregisterRequest{
|
|
|
|
JobID: job.ID,
|
|
|
|
WriteRequest: structs.WriteRequest{
|
|
|
|
Region: job.Region,
|
|
|
|
Namespace: job.Namespace,
|
|
|
|
AuthToken: rootToken.SecretID,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
deregReply := structs.JobDeregisterResponse{}
|
|
|
|
must.NoError(t, s1.RPC("Job.Deregister", &deregArgs, &deregReply))
|
|
|
|
|
|
|
|
cond := map[string]int{
|
|
|
|
structs.AllocClientStatusComplete: 1,
|
|
|
|
}
|
|
|
|
allocs = testutil.WaitForJobAllocStatusWithToken(t, s1.RPC, job, cond, rootToken.SecretID)
|
|
|
|
must.Len(t, 1, allocs)
|
|
|
|
|
|
|
|
// ResolveToken should error now that alloc is dead
|
|
|
|
aclObj, err := c1.ResolveToken(wid)
|
|
|
|
must.ErrorContains(t, err, "allocation is terminal")
|
|
|
|
must.Nil(t, aclObj)
|
2020-03-22 16:17:33 +00:00
|
|
|
}
|