2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2021-09-22 13:24:30 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
2022-12-14 15:24:22 +00:00
|
|
|
"context"
|
2021-09-22 13:24:30 +00:00
|
|
|
"io"
|
|
|
|
|
2021-09-22 22:55:53 +00:00
|
|
|
"github.com/hashicorp/serf/serf"
|
|
|
|
"github.com/stretchr/testify/mock"
|
|
|
|
|
2021-09-22 13:24:30 +00:00
|
|
|
"github.com/hashicorp/consul/acl"
|
2022-06-17 09:24:43 +00:00
|
|
|
"github.com/hashicorp/consul/acl/resolver"
|
2021-09-22 13:24:30 +00:00
|
|
|
"github.com/hashicorp/consul/agent/consul"
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
|
|
"github.com/hashicorp/consul/lib"
|
2023-07-17 13:44:49 +00:00
|
|
|
"github.com/hashicorp/consul/proto-public/pbresource"
|
2021-09-22 13:24:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type delegateMock struct {
|
|
|
|
mock.Mock
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *delegateMock) GetLANCoordinate() (lib.CoordinateSet, error) {
|
|
|
|
ret := m.Called()
|
|
|
|
return ret.Get(0).(lib.CoordinateSet), ret.Error(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *delegateMock) Leave() error {
|
|
|
|
return m.Called().Error(0)
|
|
|
|
}
|
|
|
|
|
2021-10-26 20:08:55 +00:00
|
|
|
func (m *delegateMock) LANMembersInAgentPartition() []serf.Member {
|
2021-09-22 13:24:30 +00:00
|
|
|
return m.Called().Get(0).([]serf.Member)
|
|
|
|
}
|
|
|
|
|
2021-10-26 20:08:55 +00:00
|
|
|
func (m *delegateMock) LANMembers(f consul.LANMemberFilter) ([]serf.Member, error) {
|
|
|
|
ret := m.Called(f)
|
2021-09-22 13:24:30 +00:00
|
|
|
return ret.Get(0).([]serf.Member), ret.Error(1)
|
|
|
|
}
|
|
|
|
|
2021-10-26 20:08:55 +00:00
|
|
|
func (m *delegateMock) AgentLocalMember() serf.Member {
|
2021-09-22 13:24:30 +00:00
|
|
|
return m.Called().Get(0).(serf.Member)
|
|
|
|
}
|
|
|
|
|
2022-04-05 21:10:06 +00:00
|
|
|
func (m *delegateMock) JoinLAN(addrs []string, entMeta *acl.EnterpriseMeta) (n int, err error) {
|
2021-10-26 20:08:55 +00:00
|
|
|
ret := m.Called(addrs, entMeta)
|
2021-09-22 13:24:30 +00:00
|
|
|
return ret.Int(0), ret.Error(1)
|
|
|
|
}
|
|
|
|
|
2022-04-05 21:10:06 +00:00
|
|
|
func (m *delegateMock) RemoveFailedNode(node string, prune bool, entMeta *acl.EnterpriseMeta) error {
|
2021-10-26 20:08:55 +00:00
|
|
|
return m.Called(node, prune, entMeta).Error(0)
|
2021-09-22 13:24:30 +00:00
|
|
|
}
|
|
|
|
|
2022-06-17 09:24:43 +00:00
|
|
|
func (m *delegateMock) ResolveTokenAndDefaultMeta(token string, entMeta *acl.EnterpriseMeta, authzContext *acl.AuthorizerContext) (resolver.Result, error) {
|
2021-09-22 13:24:30 +00:00
|
|
|
ret := m.Called(token, entMeta, authzContext)
|
2022-06-17 09:24:43 +00:00
|
|
|
return ret.Get(0).(resolver.Result), ret.Error(1)
|
2021-09-22 13:24:30 +00:00
|
|
|
}
|
|
|
|
|
2022-12-14 15:24:22 +00:00
|
|
|
func (m *delegateMock) RPC(ctx context.Context, method string, args interface{}, reply interface{}) error {
|
2021-09-22 13:24:30 +00:00
|
|
|
return m.Called(method, args, reply).Error(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *delegateMock) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io.Writer, replyFn structs.SnapshotReplyFn) error {
|
|
|
|
return m.Called(args, in, out, replyFn).Error(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *delegateMock) Shutdown() error {
|
|
|
|
return m.Called().Error(0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *delegateMock) Stats() map[string]map[string]string {
|
|
|
|
return m.Called().Get(0).(map[string]map[string]string)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *delegateMock) ReloadConfig(config consul.ReloadableConfig) error {
|
|
|
|
return m.Called(config).Error(0)
|
|
|
|
}
|
2023-07-17 13:44:49 +00:00
|
|
|
|
|
|
|
func (m *delegateMock) ResourceServiceClient() pbresource.ResourceServiceClient {
|
|
|
|
return nil
|
|
|
|
}
|