Replace strings.Split(RemoteAddr, ":") with net.SplitHostPort for correct IPv6 address extraction in vote deduplication and comment IP tracking. Harden image proxy: add SSRF-safe transport blocking private/reserved IPs at connection time with DNS rebinding protection, sanitize error messages to prevent information leakage, add response size limit via io.LimitReader. Fix shadowed error variables in BlockedUsers, SetTitle, and Delete methods. Exclude gosec taint analysis false positives at linter config level.
510 lines
13 KiB
Go
510 lines
13 KiB
Go
// Code generated by moq; DO NOT EDIT.
|
|
// github.com/matryer/moq
|
|
|
|
package engine
|
|
|
|
import (
|
|
"sync"
|
|
|
|
store "github.com/umputun/remark42/backend/app/store"
|
|
)
|
|
|
|
// Ensure, that InterfaceMock does implement Interface.
|
|
// If this is not the case, regenerate this file with moq.
|
|
var _ Interface = &InterfaceMock{}
|
|
|
|
// InterfaceMock is a mock implementation of Interface.
|
|
//
|
|
// func TestSomethingThatUsesInterface(t *testing.T) {
|
|
//
|
|
// // make and configure a mocked Interface
|
|
// mockedInterface := &InterfaceMock{
|
|
// CloseFunc: func() error {
|
|
// panic("mock out the Close method")
|
|
// },
|
|
// CountFunc: func(req FindRequest) (int, error) {
|
|
// panic("mock out the Count method")
|
|
// },
|
|
// CreateFunc: func(comment store.Comment) (string, error) {
|
|
// panic("mock out the Create method")
|
|
// },
|
|
// DeleteFunc: func(req DeleteRequest) error {
|
|
// panic("mock out the Delete method")
|
|
// },
|
|
// FindFunc: func(req FindRequest) ([]store.Comment, error) {
|
|
// panic("mock out the Find method")
|
|
// },
|
|
// FlagFunc: func(req FlagRequest) (bool, error) {
|
|
// panic("mock out the Flag method")
|
|
// },
|
|
// GetFunc: func(req GetRequest) (store.Comment, error) {
|
|
// panic("mock out the Get method")
|
|
// },
|
|
// InfoFunc: func(req InfoRequest) ([]store.PostInfo, error) {
|
|
// panic("mock out the Info method")
|
|
// },
|
|
// ListFlagsFunc: func(req FlagRequest) ([]interface{}, error) {
|
|
// panic("mock out the ListFlags method")
|
|
// },
|
|
// UpdateFunc: func(comment store.Comment) error {
|
|
// panic("mock out the Update method")
|
|
// },
|
|
// UserDetailFunc: func(req UserDetailRequest) ([]UserDetailEntry, error) {
|
|
// panic("mock out the UserDetail method")
|
|
// },
|
|
// }
|
|
//
|
|
// // use mockedInterface in code that requires Interface
|
|
// // and then make assertions.
|
|
//
|
|
// }
|
|
type InterfaceMock struct {
|
|
// CloseFunc mocks the Close method.
|
|
CloseFunc func() error
|
|
|
|
// CountFunc mocks the Count method.
|
|
CountFunc func(req FindRequest) (int, error)
|
|
|
|
// CreateFunc mocks the Create method.
|
|
CreateFunc func(comment store.Comment) (string, error)
|
|
|
|
// DeleteFunc mocks the Delete method.
|
|
DeleteFunc func(req DeleteRequest) error
|
|
|
|
// FindFunc mocks the Find method.
|
|
FindFunc func(req FindRequest) ([]store.Comment, error)
|
|
|
|
// FlagFunc mocks the Flag method.
|
|
FlagFunc func(req FlagRequest) (bool, error)
|
|
|
|
// GetFunc mocks the Get method.
|
|
GetFunc func(req GetRequest) (store.Comment, error)
|
|
|
|
// InfoFunc mocks the Info method.
|
|
InfoFunc func(req InfoRequest) ([]store.PostInfo, error)
|
|
|
|
// ListFlagsFunc mocks the ListFlags method.
|
|
ListFlagsFunc func(req FlagRequest) ([]interface{}, error)
|
|
|
|
// UpdateFunc mocks the Update method.
|
|
UpdateFunc func(comment store.Comment) error
|
|
|
|
// UserDetailFunc mocks the UserDetail method.
|
|
UserDetailFunc func(req UserDetailRequest) ([]UserDetailEntry, error)
|
|
|
|
// calls tracks calls to the methods.
|
|
calls struct {
|
|
// Close holds details about calls to the Close method.
|
|
Close []struct {
|
|
}
|
|
// Count holds details about calls to the Count method.
|
|
Count []struct {
|
|
// Req is the req argument value.
|
|
Req FindRequest
|
|
}
|
|
// Create holds details about calls to the Create method.
|
|
Create []struct {
|
|
// Comment is the comment argument value.
|
|
Comment store.Comment
|
|
}
|
|
// Delete holds details about calls to the Delete method.
|
|
Delete []struct {
|
|
// Req is the req argument value.
|
|
Req DeleteRequest
|
|
}
|
|
// Find holds details about calls to the Find method.
|
|
Find []struct {
|
|
// Req is the req argument value.
|
|
Req FindRequest
|
|
}
|
|
// Flag holds details about calls to the Flag method.
|
|
Flag []struct {
|
|
// Req is the req argument value.
|
|
Req FlagRequest
|
|
}
|
|
// Get holds details about calls to the Get method.
|
|
Get []struct {
|
|
// Req is the req argument value.
|
|
Req GetRequest
|
|
}
|
|
// Info holds details about calls to the Info method.
|
|
Info []struct {
|
|
// Req is the req argument value.
|
|
Req InfoRequest
|
|
}
|
|
// ListFlags holds details about calls to the ListFlags method.
|
|
ListFlags []struct {
|
|
// Req is the req argument value.
|
|
Req FlagRequest
|
|
}
|
|
// Update holds details about calls to the Update method.
|
|
Update []struct {
|
|
// Comment is the comment argument value.
|
|
Comment store.Comment
|
|
}
|
|
// UserDetail holds details about calls to the UserDetail method.
|
|
UserDetail []struct {
|
|
// Req is the req argument value.
|
|
Req UserDetailRequest
|
|
}
|
|
}
|
|
lockClose sync.RWMutex
|
|
lockCount sync.RWMutex
|
|
lockCreate sync.RWMutex
|
|
lockDelete sync.RWMutex
|
|
lockFind sync.RWMutex
|
|
lockFlag sync.RWMutex
|
|
lockGet sync.RWMutex
|
|
lockInfo sync.RWMutex
|
|
lockListFlags sync.RWMutex
|
|
lockUpdate sync.RWMutex
|
|
lockUserDetail sync.RWMutex
|
|
}
|
|
|
|
// Close calls CloseFunc.
|
|
func (mock *InterfaceMock) Close() error {
|
|
if mock.CloseFunc == nil {
|
|
panic("InterfaceMock.CloseFunc: method is nil but Interface.Close was just called")
|
|
}
|
|
callInfo := struct {
|
|
}{}
|
|
mock.lockClose.Lock()
|
|
mock.calls.Close = append(mock.calls.Close, callInfo)
|
|
mock.lockClose.Unlock()
|
|
return mock.CloseFunc()
|
|
}
|
|
|
|
// CloseCalls gets all the calls that were made to Close.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.CloseCalls())
|
|
func (mock *InterfaceMock) CloseCalls() []struct {
|
|
} {
|
|
var calls []struct {
|
|
}
|
|
mock.lockClose.RLock()
|
|
calls = mock.calls.Close
|
|
mock.lockClose.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// Count calls CountFunc.
|
|
func (mock *InterfaceMock) Count(req FindRequest) (int, error) {
|
|
if mock.CountFunc == nil {
|
|
panic("InterfaceMock.CountFunc: method is nil but Interface.Count was just called")
|
|
}
|
|
callInfo := struct {
|
|
Req FindRequest
|
|
}{
|
|
Req: req,
|
|
}
|
|
mock.lockCount.Lock()
|
|
mock.calls.Count = append(mock.calls.Count, callInfo)
|
|
mock.lockCount.Unlock()
|
|
return mock.CountFunc(req)
|
|
}
|
|
|
|
// CountCalls gets all the calls that were made to Count.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.CountCalls())
|
|
func (mock *InterfaceMock) CountCalls() []struct {
|
|
Req FindRequest
|
|
} {
|
|
var calls []struct {
|
|
Req FindRequest
|
|
}
|
|
mock.lockCount.RLock()
|
|
calls = mock.calls.Count
|
|
mock.lockCount.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// Create calls CreateFunc.
|
|
func (mock *InterfaceMock) Create(comment store.Comment) (string, error) {
|
|
if mock.CreateFunc == nil {
|
|
panic("InterfaceMock.CreateFunc: method is nil but Interface.Create was just called")
|
|
}
|
|
callInfo := struct {
|
|
Comment store.Comment
|
|
}{
|
|
Comment: comment,
|
|
}
|
|
mock.lockCreate.Lock()
|
|
mock.calls.Create = append(mock.calls.Create, callInfo)
|
|
mock.lockCreate.Unlock()
|
|
return mock.CreateFunc(comment)
|
|
}
|
|
|
|
// CreateCalls gets all the calls that were made to Create.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.CreateCalls())
|
|
func (mock *InterfaceMock) CreateCalls() []struct {
|
|
Comment store.Comment
|
|
} {
|
|
var calls []struct {
|
|
Comment store.Comment
|
|
}
|
|
mock.lockCreate.RLock()
|
|
calls = mock.calls.Create
|
|
mock.lockCreate.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// Delete calls DeleteFunc.
|
|
func (mock *InterfaceMock) Delete(req DeleteRequest) error {
|
|
if mock.DeleteFunc == nil {
|
|
panic("InterfaceMock.DeleteFunc: method is nil but Interface.Delete was just called")
|
|
}
|
|
callInfo := struct {
|
|
Req DeleteRequest
|
|
}{
|
|
Req: req,
|
|
}
|
|
mock.lockDelete.Lock()
|
|
mock.calls.Delete = append(mock.calls.Delete, callInfo)
|
|
mock.lockDelete.Unlock()
|
|
return mock.DeleteFunc(req)
|
|
}
|
|
|
|
// DeleteCalls gets all the calls that were made to Delete.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.DeleteCalls())
|
|
func (mock *InterfaceMock) DeleteCalls() []struct {
|
|
Req DeleteRequest
|
|
} {
|
|
var calls []struct {
|
|
Req DeleteRequest
|
|
}
|
|
mock.lockDelete.RLock()
|
|
calls = mock.calls.Delete
|
|
mock.lockDelete.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// Find calls FindFunc.
|
|
func (mock *InterfaceMock) Find(req FindRequest) ([]store.Comment, error) {
|
|
if mock.FindFunc == nil {
|
|
panic("InterfaceMock.FindFunc: method is nil but Interface.Find was just called")
|
|
}
|
|
callInfo := struct {
|
|
Req FindRequest
|
|
}{
|
|
Req: req,
|
|
}
|
|
mock.lockFind.Lock()
|
|
mock.calls.Find = append(mock.calls.Find, callInfo)
|
|
mock.lockFind.Unlock()
|
|
return mock.FindFunc(req)
|
|
}
|
|
|
|
// FindCalls gets all the calls that were made to Find.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.FindCalls())
|
|
func (mock *InterfaceMock) FindCalls() []struct {
|
|
Req FindRequest
|
|
} {
|
|
var calls []struct {
|
|
Req FindRequest
|
|
}
|
|
mock.lockFind.RLock()
|
|
calls = mock.calls.Find
|
|
mock.lockFind.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// Flag calls FlagFunc.
|
|
func (mock *InterfaceMock) Flag(req FlagRequest) (bool, error) {
|
|
if mock.FlagFunc == nil {
|
|
panic("InterfaceMock.FlagFunc: method is nil but Interface.Flag was just called")
|
|
}
|
|
callInfo := struct {
|
|
Req FlagRequest
|
|
}{
|
|
Req: req,
|
|
}
|
|
mock.lockFlag.Lock()
|
|
mock.calls.Flag = append(mock.calls.Flag, callInfo)
|
|
mock.lockFlag.Unlock()
|
|
return mock.FlagFunc(req)
|
|
}
|
|
|
|
// FlagCalls gets all the calls that were made to Flag.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.FlagCalls())
|
|
func (mock *InterfaceMock) FlagCalls() []struct {
|
|
Req FlagRequest
|
|
} {
|
|
var calls []struct {
|
|
Req FlagRequest
|
|
}
|
|
mock.lockFlag.RLock()
|
|
calls = mock.calls.Flag
|
|
mock.lockFlag.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// Get calls GetFunc.
|
|
func (mock *InterfaceMock) Get(req GetRequest) (store.Comment, error) {
|
|
if mock.GetFunc == nil {
|
|
panic("InterfaceMock.GetFunc: method is nil but Interface.Get was just called")
|
|
}
|
|
callInfo := struct {
|
|
Req GetRequest
|
|
}{
|
|
Req: req,
|
|
}
|
|
mock.lockGet.Lock()
|
|
mock.calls.Get = append(mock.calls.Get, callInfo)
|
|
mock.lockGet.Unlock()
|
|
return mock.GetFunc(req)
|
|
}
|
|
|
|
// GetCalls gets all the calls that were made to Get.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.GetCalls())
|
|
func (mock *InterfaceMock) GetCalls() []struct {
|
|
Req GetRequest
|
|
} {
|
|
var calls []struct {
|
|
Req GetRequest
|
|
}
|
|
mock.lockGet.RLock()
|
|
calls = mock.calls.Get
|
|
mock.lockGet.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// Info calls InfoFunc.
|
|
func (mock *InterfaceMock) Info(req InfoRequest) ([]store.PostInfo, error) {
|
|
if mock.InfoFunc == nil {
|
|
panic("InterfaceMock.InfoFunc: method is nil but Interface.Info was just called")
|
|
}
|
|
callInfo := struct {
|
|
Req InfoRequest
|
|
}{
|
|
Req: req,
|
|
}
|
|
mock.lockInfo.Lock()
|
|
mock.calls.Info = append(mock.calls.Info, callInfo)
|
|
mock.lockInfo.Unlock()
|
|
return mock.InfoFunc(req)
|
|
}
|
|
|
|
// InfoCalls gets all the calls that were made to Info.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.InfoCalls())
|
|
func (mock *InterfaceMock) InfoCalls() []struct {
|
|
Req InfoRequest
|
|
} {
|
|
var calls []struct {
|
|
Req InfoRequest
|
|
}
|
|
mock.lockInfo.RLock()
|
|
calls = mock.calls.Info
|
|
mock.lockInfo.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// ListFlags calls ListFlagsFunc.
|
|
func (mock *InterfaceMock) ListFlags(req FlagRequest) ([]interface{}, error) {
|
|
if mock.ListFlagsFunc == nil {
|
|
panic("InterfaceMock.ListFlagsFunc: method is nil but Interface.ListFlags was just called")
|
|
}
|
|
callInfo := struct {
|
|
Req FlagRequest
|
|
}{
|
|
Req: req,
|
|
}
|
|
mock.lockListFlags.Lock()
|
|
mock.calls.ListFlags = append(mock.calls.ListFlags, callInfo)
|
|
mock.lockListFlags.Unlock()
|
|
return mock.ListFlagsFunc(req)
|
|
}
|
|
|
|
// ListFlagsCalls gets all the calls that were made to ListFlags.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.ListFlagsCalls())
|
|
func (mock *InterfaceMock) ListFlagsCalls() []struct {
|
|
Req FlagRequest
|
|
} {
|
|
var calls []struct {
|
|
Req FlagRequest
|
|
}
|
|
mock.lockListFlags.RLock()
|
|
calls = mock.calls.ListFlags
|
|
mock.lockListFlags.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// Update calls UpdateFunc.
|
|
func (mock *InterfaceMock) Update(comment store.Comment) error {
|
|
if mock.UpdateFunc == nil {
|
|
panic("InterfaceMock.UpdateFunc: method is nil but Interface.Update was just called")
|
|
}
|
|
callInfo := struct {
|
|
Comment store.Comment
|
|
}{
|
|
Comment: comment,
|
|
}
|
|
mock.lockUpdate.Lock()
|
|
mock.calls.Update = append(mock.calls.Update, callInfo)
|
|
mock.lockUpdate.Unlock()
|
|
return mock.UpdateFunc(comment)
|
|
}
|
|
|
|
// UpdateCalls gets all the calls that were made to Update.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.UpdateCalls())
|
|
func (mock *InterfaceMock) UpdateCalls() []struct {
|
|
Comment store.Comment
|
|
} {
|
|
var calls []struct {
|
|
Comment store.Comment
|
|
}
|
|
mock.lockUpdate.RLock()
|
|
calls = mock.calls.Update
|
|
mock.lockUpdate.RUnlock()
|
|
return calls
|
|
}
|
|
|
|
// UserDetail calls UserDetailFunc.
|
|
func (mock *InterfaceMock) UserDetail(req UserDetailRequest) ([]UserDetailEntry, error) {
|
|
if mock.UserDetailFunc == nil {
|
|
panic("InterfaceMock.UserDetailFunc: method is nil but Interface.UserDetail was just called")
|
|
}
|
|
callInfo := struct {
|
|
Req UserDetailRequest
|
|
}{
|
|
Req: req,
|
|
}
|
|
mock.lockUserDetail.Lock()
|
|
mock.calls.UserDetail = append(mock.calls.UserDetail, callInfo)
|
|
mock.lockUserDetail.Unlock()
|
|
return mock.UserDetailFunc(req)
|
|
}
|
|
|
|
// UserDetailCalls gets all the calls that were made to UserDetail.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedInterface.UserDetailCalls())
|
|
func (mock *InterfaceMock) UserDetailCalls() []struct {
|
|
Req UserDetailRequest
|
|
} {
|
|
var calls []struct {
|
|
Req UserDetailRequest
|
|
}
|
|
mock.lockUserDetail.RLock()
|
|
calls = mock.calls.UserDetail
|
|
mock.lockUserDetail.RUnlock()
|
|
return calls
|
|
}
|