Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions acl/enterprisemeta_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ func (m *EnterpriseMeta) MergeNoWildcard(_ *EnterpriseMeta) {
// do nothing
}

func (_ *EnterpriseMeta) Normalize() {}
func (_ *EnterpriseMeta) NormalizePartition() {}
func (_ *EnterpriseMeta) NormalizeNamespace() {}
func (*EnterpriseMeta) Normalize() {}
func (*EnterpriseMeta) NormalizePartition() {}
func (*EnterpriseMeta) NormalizeNamespace() {}

func (m *EnterpriseMeta) Matches(_ *EnterpriseMeta) bool {
return true
Expand Down
57 changes: 28 additions & 29 deletions agent/agent_endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/hashicorp/consul/agent/local"
"github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/agent/token"
tokenStore "github.com/hashicorp/consul/agent/token"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/envoyextensions/xdscommon"
"github.com/hashicorp/consul/lib"
Expand Down Expand Up @@ -1728,7 +1727,7 @@ func newDefaultBaseDeps(t *testing.T) BaseDeps {
func TestHTTPHandlers_AgentMetricsStream_ACLDeny(t *testing.T) {
t.Skip("this test panics without a license manager in enterprise")
bd := newDefaultBaseDeps(t)
bd.Tokens = new(tokenStore.Store)
bd.Tokens = new(token.Store)
sink := metrics.NewInmemSink(30*time.Millisecond, time.Second)
bd.MetricsConfig = &lib.MetricsConfig{
Handler: sink,
Expand Down Expand Up @@ -1760,7 +1759,7 @@ func TestHTTPHandlers_AgentMetricsStream_ACLDeny(t *testing.T) {
func TestHTTPHandlers_AgentMetricsStream(t *testing.T) {
t.Skip("this test panics without a license manager in enterprise")
bd := newDefaultBaseDeps(t)
bd.Tokens = new(tokenStore.Store)
bd.Tokens = new(token.Store)
sink := metrics.NewInmemSink(20*time.Millisecond, time.Second)
bd.MetricsConfig = &lib.MetricsConfig{
Handler: sink,
Expand Down Expand Up @@ -6479,15 +6478,15 @@ func TestAgent_Token(t *testing.T) {

type tokens struct {
user string
userSource tokenStore.TokenSource
userSource token.TokenSource
agent string
agentSource tokenStore.TokenSource
agentSource token.TokenSource
agentRecovery string
agentRecoverySource tokenStore.TokenSource
agentRecoverySource token.TokenSource
repl string
replSource tokenStore.TokenSource
replSource token.TokenSource
registration string
registrationSource tokenStore.TokenSource
registrationSource token.TokenSource
}

resetTokens := func(init tokens) {
Expand Down Expand Up @@ -6538,7 +6537,7 @@ func TestAgent_Token(t *testing.T) {
url: "acl_token",
body: body("U"),
code: http.StatusOK,
raw: tokens{user: "U", userSource: tokenStore.TokenSourceAPI},
raw: tokens{user: "U", userSource: token.TokenSourceAPI},
effective: tokens{user: "U", agent: "U"},
},
{
Expand All @@ -6547,7 +6546,7 @@ func TestAgent_Token(t *testing.T) {
url: "default",
body: body("U"),
code: http.StatusOK,
raw: tokens{user: "U", userSource: tokenStore.TokenSourceAPI},
raw: tokens{user: "U", userSource: token.TokenSourceAPI},
effective: tokens{user: "U", agent: "U"},
},
{
Expand All @@ -6557,7 +6556,7 @@ func TestAgent_Token(t *testing.T) {
body: body("A"),
code: http.StatusOK,
init: tokens{user: "U", agent: "U"},
raw: tokens{user: "U", agent: "A", agentSource: tokenStore.TokenSourceAPI},
raw: tokens{user: "U", agent: "A", agentSource: token.TokenSourceAPI},
effective: tokens{user: "U", agent: "A"},
},
{
Expand All @@ -6567,7 +6566,7 @@ func TestAgent_Token(t *testing.T) {
body: body("A"),
code: http.StatusOK,
init: tokens{user: "U", agent: "U"},
raw: tokens{user: "U", agent: "A", agentSource: tokenStore.TokenSourceAPI},
raw: tokens{user: "U", agent: "A", agentSource: token.TokenSourceAPI},
effective: tokens{user: "U", agent: "A"},
},
{
Expand All @@ -6576,7 +6575,7 @@ func TestAgent_Token(t *testing.T) {
url: "acl_agent_master_token",
body: body("M"),
code: http.StatusOK,
raw: tokens{agentRecovery: "M", agentRecoverySource: tokenStore.TokenSourceAPI},
raw: tokens{agentRecovery: "M", agentRecoverySource: token.TokenSourceAPI},
effective: tokens{agentRecovery: "M"},
},
{
Expand All @@ -6585,7 +6584,7 @@ func TestAgent_Token(t *testing.T) {
url: "agent_master",
body: body("M"),
code: http.StatusOK,
raw: tokens{agentRecovery: "M", agentRecoverySource: tokenStore.TokenSourceAPI},
raw: tokens{agentRecovery: "M", agentRecoverySource: token.TokenSourceAPI},
effective: tokens{agentRecovery: "M"},
},
{
Expand All @@ -6594,16 +6593,16 @@ func TestAgent_Token(t *testing.T) {
url: "agent_recovery",
body: body("R"),
code: http.StatusOK,
raw: tokens{agentRecovery: "R", agentRecoverySource: tokenStore.TokenSourceAPI},
effective: tokens{agentRecovery: "R", agentRecoverySource: tokenStore.TokenSourceAPI},
raw: tokens{agentRecovery: "R", agentRecoverySource: token.TokenSourceAPI},
effective: tokens{agentRecovery: "R", agentRecoverySource: token.TokenSourceAPI},
},
{
name: "set repl legacy",
method: "PUT",
url: "acl_replication_token",
body: body("R"),
code: http.StatusOK,
raw: tokens{repl: "R", replSource: tokenStore.TokenSourceAPI},
raw: tokens{repl: "R", replSource: token.TokenSourceAPI},
effective: tokens{repl: "R"},
},
{
Expand All @@ -6612,7 +6611,7 @@ func TestAgent_Token(t *testing.T) {
url: "replication",
body: body("R"),
code: http.StatusOK,
raw: tokens{repl: "R", replSource: tokenStore.TokenSourceAPI},
raw: tokens{repl: "R", replSource: token.TokenSourceAPI},
effective: tokens{repl: "R"},
},
{
Expand All @@ -6621,7 +6620,7 @@ func TestAgent_Token(t *testing.T) {
url: "config_file_service_registration",
body: body("G"),
code: http.StatusOK,
raw: tokens{registration: "G", registrationSource: tokenStore.TokenSourceAPI},
raw: tokens{registration: "G", registrationSource: token.TokenSourceAPI},
effective: tokens{registration: "G"},
},
{
Expand All @@ -6631,7 +6630,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{user: "U"},
raw: tokens{userSource: tokenStore.TokenSourceAPI},
raw: tokens{userSource: token.TokenSourceAPI},
},
{
name: "clear default",
Expand All @@ -6640,7 +6639,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{user: "U"},
raw: tokens{userSource: tokenStore.TokenSourceAPI},
raw: tokens{userSource: token.TokenSourceAPI},
},
{
name: "clear agent legacy",
Expand All @@ -6649,7 +6648,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{agent: "A"},
raw: tokens{agentSource: tokenStore.TokenSourceAPI},
raw: tokens{agentSource: token.TokenSourceAPI},
},
{
name: "clear agent",
Expand All @@ -6658,7 +6657,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{agent: "A"},
raw: tokens{agentSource: tokenStore.TokenSourceAPI},
raw: tokens{agentSource: token.TokenSourceAPI},
},
{
name: "clear master legacy",
Expand All @@ -6667,7 +6666,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{agentRecovery: "M"},
raw: tokens{agentRecoverySource: tokenStore.TokenSourceAPI},
raw: tokens{agentRecoverySource: token.TokenSourceAPI},
},
{
name: "clear master",
Expand All @@ -6676,7 +6675,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{agentRecovery: "M"},
raw: tokens{agentRecoverySource: tokenStore.TokenSourceAPI},
raw: tokens{agentRecoverySource: token.TokenSourceAPI},
},
{
name: "clear recovery",
Expand All @@ -6685,7 +6684,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{agentRecovery: "R"},
raw: tokens{agentRecoverySource: tokenStore.TokenSourceAPI},
raw: tokens{agentRecoverySource: token.TokenSourceAPI},
},
{
name: "clear repl legacy",
Expand All @@ -6694,7 +6693,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{repl: "R"},
raw: tokens{replSource: tokenStore.TokenSourceAPI},
raw: tokens{replSource: token.TokenSourceAPI},
},
{
name: "clear repl",
Expand All @@ -6703,7 +6702,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{repl: "R"},
raw: tokens{replSource: tokenStore.TokenSourceAPI},
raw: tokens{replSource: token.TokenSourceAPI},
},
{
name: "clear registration",
Expand All @@ -6712,7 +6711,7 @@ func TestAgent_Token(t *testing.T) {
body: body(""),
code: http.StatusOK,
init: tokens{registration: "G"},
raw: tokens{registrationSource: tokenStore.TokenSourceAPI},
raw: tokens{registrationSource: token.TokenSourceAPI},
},
}
for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion agent/auto-config/auto_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ func TestFallback(t *testing.T) {
// auto-config response which is how the Fallback for auto-config works
testAC.mcfg.tokens.On("UpdateAgentToken", testAC.originalToken, token.TokenSourceConfig).Return(true).Once()

testAC.mcfg.expectInitialTLS(t, "autoconf", "dc1", testAC.originalToken, secondCA, secondRoots, thirdCert, testAC.extraCerts)
testAC.mcfg.expectInitialTLS("autoconf", "dc1", testAC.originalToken, secondCA, secondRoots, thirdCert, testAC.extraCerts)

// after the second RPC we now will use the new certs validity period in the next run loop iteration
testAC.mcfg.tlsCfg.On("AutoEncryptCert").Return(&x509.Certificate{
Expand Down
2 changes: 1 addition & 1 deletion agent/auto-config/auto_encrypt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ func TestAutoEncrypt_Fallback(t *testing.T) {
&expectedRequest,
&structs.SignedResponse{}).Return(nil).Run(populateResponse).Once()

testAC.mcfg.expectInitialTLS(t, "autoconf", "dc1", testAC.originalToken, secondCA, &secondRoots, thirdCert, testAC.extraCerts)
testAC.mcfg.expectInitialTLS("autoconf", "dc1", testAC.originalToken, secondCA, &secondRoots, thirdCert, testAC.extraCerts)

// after the second RPC we now will use the new certs validity period in the next run loop iteration
testAC.mcfg.tlsCfg.On("AutoEncryptCert").Return(&x509.Certificate{
Expand Down
2 changes: 1 addition & 1 deletion agent/auto-config/config_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ package autoconf
type EnterpriseConfig struct{}

// finalize is a noop for CE
func (_ *EnterpriseConfig) validateAndFinalize() error {
func (*EnterpriseConfig) validateAndFinalize() error {
return nil
}
4 changes: 2 additions & 2 deletions agent/auto-config/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func newMockedConfig(t *testing.T) *mockedConfig {
}
}

func (m *mockedConfig) expectInitialTLS(t *testing.T, agentName, datacenter, token string, ca *structs.CARoot, indexedRoots *structs.IndexedCARoots, cert *structs.IssuedCert, extraCerts []string) {
func (m *mockedConfig) expectInitialTLS(agentName, datacenter, token string, ca *structs.CARoot, indexedRoots *structs.IndexedCARoots, cert *structs.IssuedCert, extraCerts []string) {
var pems []string
for _, root := range indexedRoots.Roots {
pems = append(pems, root.RootCert)
Expand Down Expand Up @@ -430,6 +430,6 @@ func (m *mockedConfig) setupInitialTLS(t *testing.T, agentName, datacenter, toke
ca2 := connect.TestCA(t, nil)
extraCerts := []string{ca2.RootCert}

m.expectInitialTLS(t, agentName, datacenter, token, ca, indexedRoots, cert, extraCerts)
m.expectInitialTLS(agentName, datacenter, token, ca, indexedRoots, cert, extraCerts)
return indexedRoots, cert, extraCerts
}
12 changes: 6 additions & 6 deletions agent/cache-types/catalog_list_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ func (c *CatalogListServices) Fetch(opts cache.FetchOptions, req cache.Request)
reqReal = &dup

// Set the minimum query index to our current index so we block
reqReal.QueryOptions.MinQueryIndex = opts.MinIndex
reqReal.QueryOptions.MaxQueryTime = opts.Timeout
reqReal.MinQueryIndex = opts.MinIndex
reqReal.MaxQueryTime = opts.Timeout

// Always allow stale - there's no point in hitting leader if the request is
// going to be served from cache and end up arbitrarily stale anyway. This
// allows cached service-discover to automatically read scale across all
// servers too.
reqReal.QueryOptions.AllowStale = true
reqReal.AllowStale = true

if opts.LastResult != nil {
reqReal.QueryOptions.AllowNotModifiedResponse = true
reqReal.AllowNotModifiedResponse = true
}

var reply structs.IndexedServices
Expand All @@ -54,7 +54,7 @@ func (c *CatalogListServices) Fetch(opts cache.FetchOptions, req cache.Request)
}

result.Value = &reply
result.Index = reply.QueryMeta.Index
result.NotModified = reply.QueryMeta.NotModified
result.Index = reply.Index
result.NotModified = reply.NotModified
return result, nil
}
8 changes: 4 additions & 4 deletions agent/cache-types/catalog_list_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ func TestCatalogListServices(t *testing.T) {
rpc.On("RPC", mock.Anything, "Catalog.ListServices", mock.Anything, mock.Anything).Return(nil).
Run(func(args mock.Arguments) {
req := args.Get(2).(*structs.DCSpecificRequest)
require.Equal(t, uint64(24), req.QueryOptions.MinQueryIndex)
require.Equal(t, 1*time.Second, req.QueryOptions.MaxQueryTime)
require.Equal(t, uint64(24), req.MinQueryIndex)
require.Equal(t, 1*time.Second, req.MaxQueryTime)
require.True(t, req.AllowStale)

reply := args.Get(3).(*structs.IndexedServices)
reply.Services = map[string][]string{
"foo": {"prod", "linux"},
"bar": {"qa", "windows"},
}
reply.QueryMeta.Index = 48
reply.Index = 48
resp = reply
})

Expand Down Expand Up @@ -86,7 +86,7 @@ func TestCatalogListServices_IntegrationWithCache_NotModifiedResponse(t *testing
require.True(t, req.AllowNotModifiedResponse)

reply := args.Get(3).(*structs.IndexedServices)
reply.QueryMeta.Index = 44
reply.Index = 44
reply.NotModified = true
})

Expand Down
6 changes: 3 additions & 3 deletions agent/cache-types/catalog_service_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func (c *CatalogServiceList) Fetch(opts cache.FetchOptions, req cache.Request) (
reqReal = &dup

// Set the minimum query index to our current index so we block
reqReal.QueryOptions.MinQueryIndex = opts.MinIndex
reqReal.QueryOptions.MaxQueryTime = opts.Timeout
reqReal.MinQueryIndex = opts.MinIndex
reqReal.MaxQueryTime = opts.Timeout

// Always allow stale - there's no point in hitting leader if the request is
// going to be served from cache and end up arbitrarily stale anyway. This
Expand All @@ -51,6 +51,6 @@ func (c *CatalogServiceList) Fetch(opts cache.FetchOptions, req cache.Request) (
}

result.Value = &reply
result.Index = reply.QueryMeta.Index
result.Index = reply.Index
return result, nil
}
6 changes: 3 additions & 3 deletions agent/cache-types/catalog_service_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func TestCatalogServiceList(t *testing.T) {
rpc.On("RPC", mock.Anything, "Catalog.ServiceList", mock.Anything, mock.Anything).Return(nil).
Run(func(args mock.Arguments) {
req := args.Get(2).(*structs.DCSpecificRequest)
require.Equal(t, uint64(24), req.QueryOptions.MinQueryIndex)
require.Equal(t, 1*time.Second, req.QueryOptions.MaxQueryTime)
require.Equal(t, uint64(24), req.MinQueryIndex)
require.Equal(t, 1*time.Second, req.MaxQueryTime)
require.True(t, req.AllowStale)

reply := args.Get(3).(*structs.IndexedServiceList)
Expand All @@ -37,7 +37,7 @@ func TestCatalogServiceList(t *testing.T) {
Name: "bar",
},
}
reply.QueryMeta.Index = 48
reply.Index = 48
resp = reply
})

Expand Down
Loading
Loading