|
@@ -14,407 +14,6 @@ import (
|
|
|
lfsutil "gogs.io/gogs/internal/lfsutil"
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-type MockTwoFactorsStore struct {
|
|
|
-
|
|
|
-
|
|
|
- CreateFunc *TwoFactorsStoreCreateFunc
|
|
|
-
|
|
|
-
|
|
|
- GetByUserIDFunc *TwoFactorsStoreGetByUserIDFunc
|
|
|
-
|
|
|
-
|
|
|
- IsEnabledFunc *TwoFactorsStoreIsEnabledFunc
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func NewMockTwoFactorsStore() *MockTwoFactorsStore {
|
|
|
- return &MockTwoFactorsStore{
|
|
|
- CreateFunc: &TwoFactorsStoreCreateFunc{
|
|
|
- defaultHook: func(context.Context, int64, string, string) (r0 error) {
|
|
|
- return
|
|
|
- },
|
|
|
- },
|
|
|
- GetByUserIDFunc: &TwoFactorsStoreGetByUserIDFunc{
|
|
|
- defaultHook: func(context.Context, int64) (r0 *database.TwoFactor, r1 error) {
|
|
|
- return
|
|
|
- },
|
|
|
- },
|
|
|
- IsEnabledFunc: &TwoFactorsStoreIsEnabledFunc{
|
|
|
- defaultHook: func(context.Context, int64) (r0 bool) {
|
|
|
- return
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func NewStrictMockTwoFactorsStore() *MockTwoFactorsStore {
|
|
|
- return &MockTwoFactorsStore{
|
|
|
- CreateFunc: &TwoFactorsStoreCreateFunc{
|
|
|
- defaultHook: func(context.Context, int64, string, string) error {
|
|
|
- panic("unexpected invocation of MockTwoFactorsStore.Create")
|
|
|
- },
|
|
|
- },
|
|
|
- GetByUserIDFunc: &TwoFactorsStoreGetByUserIDFunc{
|
|
|
- defaultHook: func(context.Context, int64) (*database.TwoFactor, error) {
|
|
|
- panic("unexpected invocation of MockTwoFactorsStore.GetByUserID")
|
|
|
- },
|
|
|
- },
|
|
|
- IsEnabledFunc: &TwoFactorsStoreIsEnabledFunc{
|
|
|
- defaultHook: func(context.Context, int64) bool {
|
|
|
- panic("unexpected invocation of MockTwoFactorsStore.IsEnabled")
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func NewMockTwoFactorsStoreFrom(i database.TwoFactorsStore) *MockTwoFactorsStore {
|
|
|
- return &MockTwoFactorsStore{
|
|
|
- CreateFunc: &TwoFactorsStoreCreateFunc{
|
|
|
- defaultHook: i.Create,
|
|
|
- },
|
|
|
- GetByUserIDFunc: &TwoFactorsStoreGetByUserIDFunc{
|
|
|
- defaultHook: i.GetByUserID,
|
|
|
- },
|
|
|
- IsEnabledFunc: &TwoFactorsStoreIsEnabledFunc{
|
|
|
- defaultHook: i.IsEnabled,
|
|
|
- },
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-type TwoFactorsStoreCreateFunc struct {
|
|
|
- defaultHook func(context.Context, int64, string, string) error
|
|
|
- hooks []func(context.Context, int64, string, string) error
|
|
|
- history []TwoFactorsStoreCreateFuncCall
|
|
|
- mutex sync.Mutex
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (m *MockTwoFactorsStore) Create(v0 context.Context, v1 int64, v2 string, v3 string) error {
|
|
|
- r0 := m.CreateFunc.nextHook()(v0, v1, v2, v3)
|
|
|
- m.CreateFunc.appendCall(TwoFactorsStoreCreateFuncCall{v0, v1, v2, v3, r0})
|
|
|
- return r0
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreCreateFunc) SetDefaultHook(hook func(context.Context, int64, string, string) error) {
|
|
|
- f.defaultHook = hook
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreCreateFunc) PushHook(hook func(context.Context, int64, string, string) error) {
|
|
|
- f.mutex.Lock()
|
|
|
- f.hooks = append(f.hooks, hook)
|
|
|
- f.mutex.Unlock()
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreCreateFunc) SetDefaultReturn(r0 error) {
|
|
|
- f.SetDefaultHook(func(context.Context, int64, string, string) error {
|
|
|
- return r0
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreCreateFunc) PushReturn(r0 error) {
|
|
|
- f.PushHook(func(context.Context, int64, string, string) error {
|
|
|
- return r0
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreCreateFunc) nextHook() func(context.Context, int64, string, string) error {
|
|
|
- f.mutex.Lock()
|
|
|
- defer f.mutex.Unlock()
|
|
|
-
|
|
|
- if len(f.hooks) == 0 {
|
|
|
- return f.defaultHook
|
|
|
- }
|
|
|
-
|
|
|
- hook := f.hooks[0]
|
|
|
- f.hooks = f.hooks[1:]
|
|
|
- return hook
|
|
|
-}
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreCreateFunc) appendCall(r0 TwoFactorsStoreCreateFuncCall) {
|
|
|
- f.mutex.Lock()
|
|
|
- f.history = append(f.history, r0)
|
|
|
- f.mutex.Unlock()
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreCreateFunc) History() []TwoFactorsStoreCreateFuncCall {
|
|
|
- f.mutex.Lock()
|
|
|
- history := make([]TwoFactorsStoreCreateFuncCall, len(f.history))
|
|
|
- copy(history, f.history)
|
|
|
- f.mutex.Unlock()
|
|
|
-
|
|
|
- return history
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-type TwoFactorsStoreCreateFuncCall struct {
|
|
|
-
|
|
|
-
|
|
|
- Arg0 context.Context
|
|
|
-
|
|
|
-
|
|
|
- Arg1 int64
|
|
|
-
|
|
|
-
|
|
|
- Arg2 string
|
|
|
-
|
|
|
-
|
|
|
- Arg3 string
|
|
|
-
|
|
|
-
|
|
|
- Result0 error
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (c TwoFactorsStoreCreateFuncCall) Args() []interface{} {
|
|
|
- return []interface{}{c.Arg0, c.Arg1, c.Arg2, c.Arg3}
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (c TwoFactorsStoreCreateFuncCall) Results() []interface{} {
|
|
|
- return []interface{}{c.Result0}
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-type TwoFactorsStoreGetByUserIDFunc struct {
|
|
|
- defaultHook func(context.Context, int64) (*database.TwoFactor, error)
|
|
|
- hooks []func(context.Context, int64) (*database.TwoFactor, error)
|
|
|
- history []TwoFactorsStoreGetByUserIDFuncCall
|
|
|
- mutex sync.Mutex
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (m *MockTwoFactorsStore) GetByUserID(v0 context.Context, v1 int64) (*database.TwoFactor, error) {
|
|
|
- r0, r1 := m.GetByUserIDFunc.nextHook()(v0, v1)
|
|
|
- m.GetByUserIDFunc.appendCall(TwoFactorsStoreGetByUserIDFuncCall{v0, v1, r0, r1})
|
|
|
- return r0, r1
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreGetByUserIDFunc) SetDefaultHook(hook func(context.Context, int64) (*database.TwoFactor, error)) {
|
|
|
- f.defaultHook = hook
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreGetByUserIDFunc) PushHook(hook func(context.Context, int64) (*database.TwoFactor, error)) {
|
|
|
- f.mutex.Lock()
|
|
|
- f.hooks = append(f.hooks, hook)
|
|
|
- f.mutex.Unlock()
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreGetByUserIDFunc) SetDefaultReturn(r0 *database.TwoFactor, r1 error) {
|
|
|
- f.SetDefaultHook(func(context.Context, int64) (*database.TwoFactor, error) {
|
|
|
- return r0, r1
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreGetByUserIDFunc) PushReturn(r0 *database.TwoFactor, r1 error) {
|
|
|
- f.PushHook(func(context.Context, int64) (*database.TwoFactor, error) {
|
|
|
- return r0, r1
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreGetByUserIDFunc) nextHook() func(context.Context, int64) (*database.TwoFactor, error) {
|
|
|
- f.mutex.Lock()
|
|
|
- defer f.mutex.Unlock()
|
|
|
-
|
|
|
- if len(f.hooks) == 0 {
|
|
|
- return f.defaultHook
|
|
|
- }
|
|
|
-
|
|
|
- hook := f.hooks[0]
|
|
|
- f.hooks = f.hooks[1:]
|
|
|
- return hook
|
|
|
-}
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreGetByUserIDFunc) appendCall(r0 TwoFactorsStoreGetByUserIDFuncCall) {
|
|
|
- f.mutex.Lock()
|
|
|
- f.history = append(f.history, r0)
|
|
|
- f.mutex.Unlock()
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreGetByUserIDFunc) History() []TwoFactorsStoreGetByUserIDFuncCall {
|
|
|
- f.mutex.Lock()
|
|
|
- history := make([]TwoFactorsStoreGetByUserIDFuncCall, len(f.history))
|
|
|
- copy(history, f.history)
|
|
|
- f.mutex.Unlock()
|
|
|
-
|
|
|
- return history
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-type TwoFactorsStoreGetByUserIDFuncCall struct {
|
|
|
-
|
|
|
-
|
|
|
- Arg0 context.Context
|
|
|
-
|
|
|
-
|
|
|
- Arg1 int64
|
|
|
-
|
|
|
-
|
|
|
- Result0 *database.TwoFactor
|
|
|
-
|
|
|
-
|
|
|
- Result1 error
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (c TwoFactorsStoreGetByUserIDFuncCall) Args() []interface{} {
|
|
|
- return []interface{}{c.Arg0, c.Arg1}
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (c TwoFactorsStoreGetByUserIDFuncCall) Results() []interface{} {
|
|
|
- return []interface{}{c.Result0, c.Result1}
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-type TwoFactorsStoreIsEnabledFunc struct {
|
|
|
- defaultHook func(context.Context, int64) bool
|
|
|
- hooks []func(context.Context, int64) bool
|
|
|
- history []TwoFactorsStoreIsEnabledFuncCall
|
|
|
- mutex sync.Mutex
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (m *MockTwoFactorsStore) IsEnabled(v0 context.Context, v1 int64) bool {
|
|
|
- r0 := m.IsEnabledFunc.nextHook()(v0, v1)
|
|
|
- m.IsEnabledFunc.appendCall(TwoFactorsStoreIsEnabledFuncCall{v0, v1, r0})
|
|
|
- return r0
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreIsEnabledFunc) SetDefaultHook(hook func(context.Context, int64) bool) {
|
|
|
- f.defaultHook = hook
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreIsEnabledFunc) PushHook(hook func(context.Context, int64) bool) {
|
|
|
- f.mutex.Lock()
|
|
|
- f.hooks = append(f.hooks, hook)
|
|
|
- f.mutex.Unlock()
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreIsEnabledFunc) SetDefaultReturn(r0 bool) {
|
|
|
- f.SetDefaultHook(func(context.Context, int64) bool {
|
|
|
- return r0
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreIsEnabledFunc) PushReturn(r0 bool) {
|
|
|
- f.PushHook(func(context.Context, int64) bool {
|
|
|
- return r0
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreIsEnabledFunc) nextHook() func(context.Context, int64) bool {
|
|
|
- f.mutex.Lock()
|
|
|
- defer f.mutex.Unlock()
|
|
|
-
|
|
|
- if len(f.hooks) == 0 {
|
|
|
- return f.defaultHook
|
|
|
- }
|
|
|
-
|
|
|
- hook := f.hooks[0]
|
|
|
- f.hooks = f.hooks[1:]
|
|
|
- return hook
|
|
|
-}
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreIsEnabledFunc) appendCall(r0 TwoFactorsStoreIsEnabledFuncCall) {
|
|
|
- f.mutex.Lock()
|
|
|
- f.history = append(f.history, r0)
|
|
|
- f.mutex.Unlock()
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (f *TwoFactorsStoreIsEnabledFunc) History() []TwoFactorsStoreIsEnabledFuncCall {
|
|
|
- f.mutex.Lock()
|
|
|
- history := make([]TwoFactorsStoreIsEnabledFuncCall, len(f.history))
|
|
|
- copy(history, f.history)
|
|
|
- f.mutex.Unlock()
|
|
|
-
|
|
|
- return history
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-type TwoFactorsStoreIsEnabledFuncCall struct {
|
|
|
-
|
|
|
-
|
|
|
- Arg0 context.Context
|
|
|
-
|
|
|
-
|
|
|
- Arg1 int64
|
|
|
-
|
|
|
-
|
|
|
- Result0 bool
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (c TwoFactorsStoreIsEnabledFuncCall) Args() []interface{} {
|
|
|
- return []interface{}{c.Arg0, c.Arg1}
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-func (c TwoFactorsStoreIsEnabledFuncCall) Results() []interface{} {
|
|
|
- return []interface{}{c.Result0}
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
type MockUsersStore struct {
|
|
@@ -3968,6 +3567,9 @@ type MockStore struct {
|
|
|
|
|
|
|
|
|
GetRepositoryByNameFunc *StoreGetRepositoryByNameFunc
|
|
|
+
|
|
|
+
|
|
|
+ IsTwoFactorEnabledFunc *StoreIsTwoFactorEnabledFunc
|
|
|
|
|
|
|
|
|
TouchAccessTokenByIDFunc *StoreTouchAccessTokenByIDFunc
|
|
@@ -4007,6 +3609,11 @@ func NewMockStore() *MockStore {
|
|
|
return
|
|
|
},
|
|
|
},
|
|
|
+ IsTwoFactorEnabledFunc: &StoreIsTwoFactorEnabledFunc{
|
|
|
+ defaultHook: func(context.Context, int64) (r0 bool) {
|
|
|
+ return
|
|
|
+ },
|
|
|
+ },
|
|
|
TouchAccessTokenByIDFunc: &StoreTouchAccessTokenByIDFunc{
|
|
|
defaultHook: func(context.Context, int64) (r0 error) {
|
|
|
return
|
|
@@ -4049,6 +3656,11 @@ func NewStrictMockStore() *MockStore {
|
|
|
panic("unexpected invocation of MockStore.GetRepositoryByName")
|
|
|
},
|
|
|
},
|
|
|
+ IsTwoFactorEnabledFunc: &StoreIsTwoFactorEnabledFunc{
|
|
|
+ defaultHook: func(context.Context, int64) bool {
|
|
|
+ panic("unexpected invocation of MockStore.IsTwoFactorEnabled")
|
|
|
+ },
|
|
|
+ },
|
|
|
TouchAccessTokenByIDFunc: &StoreTouchAccessTokenByIDFunc{
|
|
|
defaultHook: func(context.Context, int64) error {
|
|
|
panic("unexpected invocation of MockStore.TouchAccessTokenByID")
|
|
@@ -4079,6 +3691,9 @@ func NewMockStoreFrom(i Store) *MockStore {
|
|
|
GetRepositoryByNameFunc: &StoreGetRepositoryByNameFunc{
|
|
|
defaultHook: i.GetRepositoryByName,
|
|
|
},
|
|
|
+ IsTwoFactorEnabledFunc: &StoreIsTwoFactorEnabledFunc{
|
|
|
+ defaultHook: i.IsTwoFactorEnabled,
|
|
|
+ },
|
|
|
TouchAccessTokenByIDFunc: &StoreTouchAccessTokenByIDFunc{
|
|
|
defaultHook: i.TouchAccessTokenByID,
|
|
|
},
|
|
@@ -4763,6 +4378,111 @@ func (c StoreGetRepositoryByNameFuncCall) Results() []interface{} {
|
|
|
return []interface{}{c.Result0, c.Result1}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+type StoreIsTwoFactorEnabledFunc struct {
|
|
|
+ defaultHook func(context.Context, int64) bool
|
|
|
+ hooks []func(context.Context, int64) bool
|
|
|
+ history []StoreIsTwoFactorEnabledFuncCall
|
|
|
+ mutex sync.Mutex
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *MockStore) IsTwoFactorEnabled(v0 context.Context, v1 int64) bool {
|
|
|
+ r0 := m.IsTwoFactorEnabledFunc.nextHook()(v0, v1)
|
|
|
+ m.IsTwoFactorEnabledFunc.appendCall(StoreIsTwoFactorEnabledFuncCall{v0, v1, r0})
|
|
|
+ return r0
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (f *StoreIsTwoFactorEnabledFunc) SetDefaultHook(hook func(context.Context, int64) bool) {
|
|
|
+ f.defaultHook = hook
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (f *StoreIsTwoFactorEnabledFunc) PushHook(hook func(context.Context, int64) bool) {
|
|
|
+ f.mutex.Lock()
|
|
|
+ f.hooks = append(f.hooks, hook)
|
|
|
+ f.mutex.Unlock()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (f *StoreIsTwoFactorEnabledFunc) SetDefaultReturn(r0 bool) {
|
|
|
+ f.SetDefaultHook(func(context.Context, int64) bool {
|
|
|
+ return r0
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func (f *StoreIsTwoFactorEnabledFunc) PushReturn(r0 bool) {
|
|
|
+ f.PushHook(func(context.Context, int64) bool {
|
|
|
+ return r0
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+func (f *StoreIsTwoFactorEnabledFunc) nextHook() func(context.Context, int64) bool {
|
|
|
+ f.mutex.Lock()
|
|
|
+ defer f.mutex.Unlock()
|
|
|
+
|
|
|
+ if len(f.hooks) == 0 {
|
|
|
+ return f.defaultHook
|
|
|
+ }
|
|
|
+
|
|
|
+ hook := f.hooks[0]
|
|
|
+ f.hooks = f.hooks[1:]
|
|
|
+ return hook
|
|
|
+}
|
|
|
+
|
|
|
+func (f *StoreIsTwoFactorEnabledFunc) appendCall(r0 StoreIsTwoFactorEnabledFuncCall) {
|
|
|
+ f.mutex.Lock()
|
|
|
+ f.history = append(f.history, r0)
|
|
|
+ f.mutex.Unlock()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (f *StoreIsTwoFactorEnabledFunc) History() []StoreIsTwoFactorEnabledFuncCall {
|
|
|
+ f.mutex.Lock()
|
|
|
+ history := make([]StoreIsTwoFactorEnabledFuncCall, len(f.history))
|
|
|
+ copy(history, f.history)
|
|
|
+ f.mutex.Unlock()
|
|
|
+
|
|
|
+ return history
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+type StoreIsTwoFactorEnabledFuncCall struct {
|
|
|
+
|
|
|
+
|
|
|
+ Arg0 context.Context
|
|
|
+
|
|
|
+
|
|
|
+ Arg1 int64
|
|
|
+
|
|
|
+
|
|
|
+ Result0 bool
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (c StoreIsTwoFactorEnabledFuncCall) Args() []interface{} {
|
|
|
+ return []interface{}{c.Arg0, c.Arg1}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (c StoreIsTwoFactorEnabledFuncCall) Results() []interface{} {
|
|
|
+ return []interface{}{c.Result0}
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
type StoreTouchAccessTokenByIDFunc struct {
|