detached e858e17

feat(boundaries): add authentication service and token store interfaces

Define contracts for authentication:
- AuthService interface for password/token validation and management
- TokenStore interface for token persistence and revocation
- Generated mocks for testing
commit
e858e171df13080106243bf91487cd532207e9fc
author
brice · · 2026-01-12 21:59 UTC
committer
brice · · 2026-01-12 20:34 UTC
parent
d69187a
signature
unsigned
5 files · +1003 -0
M .mockery.yaml +2 -0
@@ -19,9 +19,11 @@ packages:
1919 SecretProvider:
2020 EnvLoader:
2121 ContainerLogWriter:
22+ TokenStore:
2223 gordon/internal/boundaries/in:
2324 interfaces:
2425 ContainerService:
2526 RegistryService:
2627 ProxyService:
2728 ConfigService:
29+ AuthService:
@@ -19,9 +19,11 @@ packages:
19 SecretProvider:19 SecretProvider:
20 EnvLoader:20 EnvLoader:
21 ContainerLogWriter:21 ContainerLogWriter:
22+ TokenStore:
22 gordon/internal/boundaries/in:23 gordon/internal/boundaries/in:
23 interfaces:24 interfaces:
24 ContainerService:25 ContainerService:
25 RegistryService:26 RegistryService:
26 ProxyService:27 ProxyService:
27 ConfigService:28 ConfigService:
29+ AuthService:
A internal/boundaries/in/auth.go +38 -0
@@ -0,0 +1,38 @@
1+package in
2+
3+import (
4+ "context"
5+ "time"
6+
7+ "gordon/internal/domain"
8+)
9+
10+// AuthService defines the contract for registry authentication operations.
11+type AuthService interface {
12+ // GetAuthType returns the configured authentication type.
13+ GetAuthType() domain.AuthType
14+
15+ // IsEnabled returns whether authentication is enabled.
16+ IsEnabled() bool
17+
18+ // Password authentication
19+ // ValidatePassword checks if the username and password are valid.
20+ ValidatePassword(ctx context.Context, username, password string) bool
21+
22+ // Token authentication
23+ // ValidateToken validates a JWT token and returns its claims.
24+ ValidateToken(ctx context.Context, tokenString string) (*domain.TokenClaims, error)
25+
26+ // GenerateToken creates a new JWT token for the given subject.
27+ // If expiry is 0, the token never expires.
28+ GenerateToken(ctx context.Context, subject string, scopes []string, expiry time.Duration) (string, error)
29+
30+ // RevokeToken revokes a token by its ID.
31+ RevokeToken(ctx context.Context, tokenID string) error
32+
33+ // ListTokens returns all stored tokens.
34+ ListTokens(ctx context.Context) ([]domain.Token, error)
35+
36+ // GeneratePasswordHash generates a bcrypt hash for a password.
37+ GeneratePasswordHash(password string) (string, error)
38+}
@@ -0,0 +1,38 @@
1+package in
2+
3+import (
4+ "context"
5+ "time"
6+
7+ "gordon/internal/domain"
8+)
9+
10+// AuthService defines the contract for registry authentication operations.
11+type AuthService interface {
12+ // GetAuthType returns the configured authentication type.
13+ GetAuthType() domain.AuthType
14+
15+ // IsEnabled returns whether authentication is enabled.
16+ IsEnabled() bool
17+
18+ // Password authentication
19+ // ValidatePassword checks if the username and password are valid.
20+ ValidatePassword(ctx context.Context, username, password string) bool
21+
22+ // Token authentication
23+ // ValidateToken validates a JWT token and returns its claims.
24+ ValidateToken(ctx context.Context, tokenString string) (*domain.TokenClaims, error)
25+
26+ // GenerateToken creates a new JWT token for the given subject.
27+ // If expiry is 0, the token never expires.
28+ GenerateToken(ctx context.Context, subject string, scopes []string, expiry time.Duration) (string, error)
29+
30+ // RevokeToken revokes a token by its ID.
31+ RevokeToken(ctx context.Context, tokenID string) error
32+
33+ // ListTokens returns all stored tokens.
34+ ListTokens(ctx context.Context) ([]domain.Token, error)
35+
36+ // GeneratePasswordHash generates a bcrypt hash for a password.
37+ GeneratePasswordHash(password string) (string, error)
38+}
A internal/boundaries/in/mocks/mock_auth_service.go +516 -0
@@ -0,0 +1,516 @@
1+// Code generated by mockery; DO NOT EDIT.
2+// github.com/vektra/mockery
3+// template: testify
4+
5+package mocks
6+
7+import (
8+ "context"
9+ "gordon/internal/domain"
10+ "time"
11+
12+ mock "github.com/stretchr/testify/mock"
13+)
14+
15+// NewMockAuthService creates a new instance of MockAuthService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
16+// The first argument is typically a *testing.T value.
17+func NewMockAuthService(t interface {
18+ mock.TestingT
19+ Cleanup(func())
20+}) *MockAuthService {
21+ mock := &MockAuthService{}
22+ mock.Mock.Test(t)
23+
24+ t.Cleanup(func() { mock.AssertExpectations(t) })
25+
26+ return mock
27+}
28+
29+// MockAuthService is an autogenerated mock type for the AuthService type
30+type MockAuthService struct {
31+ mock.Mock
32+}
33+
34+type MockAuthService_Expecter struct {
35+ mock *mock.Mock
36+}
37+
38+func (_m *MockAuthService) EXPECT() *MockAuthService_Expecter {
39+ return &MockAuthService_Expecter{mock: &_m.Mock}
40+}
41+
42+// GeneratePasswordHash provides a mock function for the type MockAuthService
43+func (_mock *MockAuthService) GeneratePasswordHash(password string) (string, error) {
44+ ret := _mock.Called(password)
45+
46+ if len(ret) == 0 {
47+ panic("no return value specified for GeneratePasswordHash")
48+ }
49+
50+ var r0 string
51+ var r1 error
52+ if returnFunc, ok := ret.Get(0).(func(string) (string, error)); ok {
53+ return returnFunc(password)
54+ }
55+ if returnFunc, ok := ret.Get(0).(func(string) string); ok {
56+ r0 = returnFunc(password)
57+ } else {
58+ r0 = ret.Get(0).(string)
59+ }
60+ if returnFunc, ok := ret.Get(1).(func(string) error); ok {
61+ r1 = returnFunc(password)
62+ } else {
63+ r1 = ret.Error(1)
64+ }
65+ return r0, r1
66+}
67+
68+// MockAuthService_GeneratePasswordHash_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GeneratePasswordHash'
69+type MockAuthService_GeneratePasswordHash_Call struct {
70+ *mock.Call
71+}
72+
73+// GeneratePasswordHash is a helper method to define mock.On call
74+// - password string
75+func (_e *MockAuthService_Expecter) GeneratePasswordHash(password interface{}) *MockAuthService_GeneratePasswordHash_Call {
76+ return &MockAuthService_GeneratePasswordHash_Call{Call: _e.mock.On("GeneratePasswordHash", password)}
77+}
78+
79+func (_c *MockAuthService_GeneratePasswordHash_Call) Run(run func(password string)) *MockAuthService_GeneratePasswordHash_Call {
80+ _c.Call.Run(func(args mock.Arguments) {
81+ var arg0 string
82+ if args[0] != nil {
83+ arg0 = args[0].(string)
84+ }
85+ run(
86+ arg0,
87+ )
88+ })
89+ return _c
90+}
91+
92+func (_c *MockAuthService_GeneratePasswordHash_Call) Return(s string, err error) *MockAuthService_GeneratePasswordHash_Call {
93+ _c.Call.Return(s, err)
94+ return _c
95+}
96+
97+func (_c *MockAuthService_GeneratePasswordHash_Call) RunAndReturn(run func(password string) (string, error)) *MockAuthService_GeneratePasswordHash_Call {
98+ _c.Call.Return(run)
99+ return _c
100+}
101+
102+// GenerateToken provides a mock function for the type MockAuthService
103+func (_mock *MockAuthService) GenerateToken(ctx context.Context, subject string, scopes []string, expiry time.Duration) (string, error) {
104+ ret := _mock.Called(ctx, subject, scopes, expiry)
105+
106+ if len(ret) == 0 {
107+ panic("no return value specified for GenerateToken")
108+ }
109+
110+ var r0 string
111+ var r1 error
112+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, []string, time.Duration) (string, error)); ok {
113+ return returnFunc(ctx, subject, scopes, expiry)
114+ }
115+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, []string, time.Duration) string); ok {
116+ r0 = returnFunc(ctx, subject, scopes, expiry)
117+ } else {
118+ r0 = ret.Get(0).(string)
119+ }
120+ if returnFunc, ok := ret.Get(1).(func(context.Context, string, []string, time.Duration) error); ok {
121+ r1 = returnFunc(ctx, subject, scopes, expiry)
122+ } else {
123+ r1 = ret.Error(1)
124+ }
125+ return r0, r1
126+}
127+
128+// MockAuthService_GenerateToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenerateToken'
129+type MockAuthService_GenerateToken_Call struct {
130+ *mock.Call
131+}
132+
133+// GenerateToken is a helper method to define mock.On call
134+// - ctx context.Context
135+// - subject string
136+// - scopes []string
137+// - expiry time.Duration
138+func (_e *MockAuthService_Expecter) GenerateToken(ctx interface{}, subject interface{}, scopes interface{}, expiry interface{}) *MockAuthService_GenerateToken_Call {
139+ return &MockAuthService_GenerateToken_Call{Call: _e.mock.On("GenerateToken", ctx, subject, scopes, expiry)}
140+}
141+
142+func (_c *MockAuthService_GenerateToken_Call) Run(run func(ctx context.Context, subject string, scopes []string, expiry time.Duration)) *MockAuthService_GenerateToken_Call {
143+ _c.Call.Run(func(args mock.Arguments) {
144+ var arg0 context.Context
145+ if args[0] != nil {
146+ arg0 = args[0].(context.Context)
147+ }
148+ var arg1 string
149+ if args[1] != nil {
150+ arg1 = args[1].(string)
151+ }
152+ var arg2 []string
153+ if args[2] != nil {
154+ arg2 = args[2].([]string)
155+ }
156+ var arg3 time.Duration
157+ if args[3] != nil {
158+ arg3 = args[3].(time.Duration)
159+ }
160+ run(
161+ arg0,
162+ arg1,
163+ arg2,
164+ arg3,
165+ )
166+ })
167+ return _c
168+}
169+
170+func (_c *MockAuthService_GenerateToken_Call) Return(s string, err error) *MockAuthService_GenerateToken_Call {
171+ _c.Call.Return(s, err)
172+ return _c
173+}
174+
175+func (_c *MockAuthService_GenerateToken_Call) RunAndReturn(run func(ctx context.Context, subject string, scopes []string, expiry time.Duration) (string, error)) *MockAuthService_GenerateToken_Call {
176+ _c.Call.Return(run)
177+ return _c
178+}
179+
180+// GetAuthType provides a mock function for the type MockAuthService
181+func (_mock *MockAuthService) GetAuthType() domain.AuthType {
182+ ret := _mock.Called()
183+
184+ if len(ret) == 0 {
185+ panic("no return value specified for GetAuthType")
186+ }
187+
188+ var r0 domain.AuthType
189+ if returnFunc, ok := ret.Get(0).(func() domain.AuthType); ok {
190+ r0 = returnFunc()
191+ } else {
192+ r0 = ret.Get(0).(domain.AuthType)
193+ }
194+ return r0
195+}
196+
197+// MockAuthService_GetAuthType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAuthType'
198+type MockAuthService_GetAuthType_Call struct {
199+ *mock.Call
200+}
201+
202+// GetAuthType is a helper method to define mock.On call
203+func (_e *MockAuthService_Expecter) GetAuthType() *MockAuthService_GetAuthType_Call {
204+ return &MockAuthService_GetAuthType_Call{Call: _e.mock.On("GetAuthType")}
205+}
206+
207+func (_c *MockAuthService_GetAuthType_Call) Run(run func()) *MockAuthService_GetAuthType_Call {
208+ _c.Call.Run(func(args mock.Arguments) {
209+ run()
210+ })
211+ return _c
212+}
213+
214+func (_c *MockAuthService_GetAuthType_Call) Return(authType domain.AuthType) *MockAuthService_GetAuthType_Call {
215+ _c.Call.Return(authType)
216+ return _c
217+}
218+
219+func (_c *MockAuthService_GetAuthType_Call) RunAndReturn(run func() domain.AuthType) *MockAuthService_GetAuthType_Call {
220+ _c.Call.Return(run)
221+ return _c
222+}
223+
224+// IsEnabled provides a mock function for the type MockAuthService
225+func (_mock *MockAuthService) IsEnabled() bool {
226+ ret := _mock.Called()
227+
228+ if len(ret) == 0 {
229+ panic("no return value specified for IsEnabled")
230+ }
231+
232+ var r0 bool
233+ if returnFunc, ok := ret.Get(0).(func() bool); ok {
234+ r0 = returnFunc()
235+ } else {
236+ r0 = ret.Get(0).(bool)
237+ }
238+ return r0
239+}
240+
241+// MockAuthService_IsEnabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsEnabled'
242+type MockAuthService_IsEnabled_Call struct {
243+ *mock.Call
244+}
245+
246+// IsEnabled is a helper method to define mock.On call
247+func (_e *MockAuthService_Expecter) IsEnabled() *MockAuthService_IsEnabled_Call {
248+ return &MockAuthService_IsEnabled_Call{Call: _e.mock.On("IsEnabled")}
249+}
250+
251+func (_c *MockAuthService_IsEnabled_Call) Run(run func()) *MockAuthService_IsEnabled_Call {
252+ _c.Call.Run(func(args mock.Arguments) {
253+ run()
254+ })
255+ return _c
256+}
257+
258+func (_c *MockAuthService_IsEnabled_Call) Return(b bool) *MockAuthService_IsEnabled_Call {
259+ _c.Call.Return(b)
260+ return _c
261+}
262+
263+func (_c *MockAuthService_IsEnabled_Call) RunAndReturn(run func() bool) *MockAuthService_IsEnabled_Call {
264+ _c.Call.Return(run)
265+ return _c
266+}
267+
268+// ListTokens provides a mock function for the type MockAuthService
269+func (_mock *MockAuthService) ListTokens(ctx context.Context) ([]domain.Token, error) {
270+ ret := _mock.Called(ctx)
271+
272+ if len(ret) == 0 {
273+ panic("no return value specified for ListTokens")
274+ }
275+
276+ var r0 []domain.Token
277+ var r1 error
278+ if returnFunc, ok := ret.Get(0).(func(context.Context) ([]domain.Token, error)); ok {
279+ return returnFunc(ctx)
280+ }
281+ if returnFunc, ok := ret.Get(0).(func(context.Context) []domain.Token); ok {
282+ r0 = returnFunc(ctx)
283+ } else {
284+ if ret.Get(0) != nil {
285+ r0 = ret.Get(0).([]domain.Token)
286+ }
287+ }
288+ if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok {
289+ r1 = returnFunc(ctx)
290+ } else {
291+ r1 = ret.Error(1)
292+ }
293+ return r0, r1
294+}
295+
296+// MockAuthService_ListTokens_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListTokens'
297+type MockAuthService_ListTokens_Call struct {
298+ *mock.Call
299+}
300+
301+// ListTokens is a helper method to define mock.On call
302+// - ctx context.Context
303+func (_e *MockAuthService_Expecter) ListTokens(ctx interface{}) *MockAuthService_ListTokens_Call {
304+ return &MockAuthService_ListTokens_Call{Call: _e.mock.On("ListTokens", ctx)}
305+}
306+
307+func (_c *MockAuthService_ListTokens_Call) Run(run func(ctx context.Context)) *MockAuthService_ListTokens_Call {
308+ _c.Call.Run(func(args mock.Arguments) {
309+ var arg0 context.Context
310+ if args[0] != nil {
311+ arg0 = args[0].(context.Context)
312+ }
313+ run(
314+ arg0,
315+ )
316+ })
317+ return _c
318+}
319+
320+func (_c *MockAuthService_ListTokens_Call) Return(tokens []domain.Token, err error) *MockAuthService_ListTokens_Call {
321+ _c.Call.Return(tokens, err)
322+ return _c
323+}
324+
325+func (_c *MockAuthService_ListTokens_Call) RunAndReturn(run func(ctx context.Context) ([]domain.Token, error)) *MockAuthService_ListTokens_Call {
326+ _c.Call.Return(run)
327+ return _c
328+}
329+
330+// RevokeToken provides a mock function for the type MockAuthService
331+func (_mock *MockAuthService) RevokeToken(ctx context.Context, tokenID string) error {
332+ ret := _mock.Called(ctx, tokenID)
333+
334+ if len(ret) == 0 {
335+ panic("no return value specified for RevokeToken")
336+ }
337+
338+ var r0 error
339+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
340+ r0 = returnFunc(ctx, tokenID)
341+ } else {
342+ r0 = ret.Error(0)
343+ }
344+ return r0
345+}
346+
347+// MockAuthService_RevokeToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RevokeToken'
348+type MockAuthService_RevokeToken_Call struct {
349+ *mock.Call
350+}
351+
352+// RevokeToken is a helper method to define mock.On call
353+// - ctx context.Context
354+// - tokenID string
355+func (_e *MockAuthService_Expecter) RevokeToken(ctx interface{}, tokenID interface{}) *MockAuthService_RevokeToken_Call {
356+ return &MockAuthService_RevokeToken_Call{Call: _e.mock.On("RevokeToken", ctx, tokenID)}
357+}
358+
359+func (_c *MockAuthService_RevokeToken_Call) Run(run func(ctx context.Context, tokenID string)) *MockAuthService_RevokeToken_Call {
360+ _c.Call.Run(func(args mock.Arguments) {
361+ var arg0 context.Context
362+ if args[0] != nil {
363+ arg0 = args[0].(context.Context)
364+ }
365+ var arg1 string
366+ if args[1] != nil {
367+ arg1 = args[1].(string)
368+ }
369+ run(
370+ arg0,
371+ arg1,
372+ )
373+ })
374+ return _c
375+}
376+
377+func (_c *MockAuthService_RevokeToken_Call) Return(err error) *MockAuthService_RevokeToken_Call {
378+ _c.Call.Return(err)
379+ return _c
380+}
381+
382+func (_c *MockAuthService_RevokeToken_Call) RunAndReturn(run func(ctx context.Context, tokenID string) error) *MockAuthService_RevokeToken_Call {
383+ _c.Call.Return(run)
384+ return _c
385+}
386+
387+// ValidatePassword provides a mock function for the type MockAuthService
388+func (_mock *MockAuthService) ValidatePassword(ctx context.Context, username string, password string) bool {
389+ ret := _mock.Called(ctx, username, password)
390+
391+ if len(ret) == 0 {
392+ panic("no return value specified for ValidatePassword")
393+ }
394+
395+ var r0 bool
396+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) bool); ok {
397+ r0 = returnFunc(ctx, username, password)
398+ } else {
399+ r0 = ret.Get(0).(bool)
400+ }
401+ return r0
402+}
403+
404+// MockAuthService_ValidatePassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidatePassword'
405+type MockAuthService_ValidatePassword_Call struct {
406+ *mock.Call
407+}
408+
409+// ValidatePassword is a helper method to define mock.On call
410+// - ctx context.Context
411+// - username string
412+// - password string
413+func (_e *MockAuthService_Expecter) ValidatePassword(ctx interface{}, username interface{}, password interface{}) *MockAuthService_ValidatePassword_Call {
414+ return &MockAuthService_ValidatePassword_Call{Call: _e.mock.On("ValidatePassword", ctx, username, password)}
415+}
416+
417+func (_c *MockAuthService_ValidatePassword_Call) Run(run func(ctx context.Context, username string, password string)) *MockAuthService_ValidatePassword_Call {
418+ _c.Call.Run(func(args mock.Arguments) {
419+ var arg0 context.Context
420+ if args[0] != nil {
421+ arg0 = args[0].(context.Context)
422+ }
423+ var arg1 string
424+ if args[1] != nil {
425+ arg1 = args[1].(string)
426+ }
427+ var arg2 string
428+ if args[2] != nil {
429+ arg2 = args[2].(string)
430+ }
431+ run(
432+ arg0,
433+ arg1,
434+ arg2,
435+ )
436+ })
437+ return _c
438+}
439+
440+func (_c *MockAuthService_ValidatePassword_Call) Return(b bool) *MockAuthService_ValidatePassword_Call {
441+ _c.Call.Return(b)
442+ return _c
443+}
444+
445+func (_c *MockAuthService_ValidatePassword_Call) RunAndReturn(run func(ctx context.Context, username string, password string) bool) *MockAuthService_ValidatePassword_Call {
446+ _c.Call.Return(run)
447+ return _c
448+}
449+
450+// ValidateToken provides a mock function for the type MockAuthService
451+func (_mock *MockAuthService) ValidateToken(ctx context.Context, tokenString string) (*domain.TokenClaims, error) {
452+ ret := _mock.Called(ctx, tokenString)
453+
454+ if len(ret) == 0 {
455+ panic("no return value specified for ValidateToken")
456+ }
457+
458+ var r0 *domain.TokenClaims
459+ var r1 error
460+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) (*domain.TokenClaims, error)); ok {
461+ return returnFunc(ctx, tokenString)
462+ }
463+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) *domain.TokenClaims); ok {
464+ r0 = returnFunc(ctx, tokenString)
465+ } else {
466+ if ret.Get(0) != nil {
467+ r0 = ret.Get(0).(*domain.TokenClaims)
468+ }
469+ }
470+ if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
471+ r1 = returnFunc(ctx, tokenString)
472+ } else {
473+ r1 = ret.Error(1)
474+ }
475+ return r0, r1
476+}
477+
478+// MockAuthService_ValidateToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidateToken'
479+type MockAuthService_ValidateToken_Call struct {
480+ *mock.Call
481+}
482+
483+// ValidateToken is a helper method to define mock.On call
484+// - ctx context.Context
485+// - tokenString string
486+func (_e *MockAuthService_Expecter) ValidateToken(ctx interface{}, tokenString interface{}) *MockAuthService_ValidateToken_Call {
487+ return &MockAuthService_ValidateToken_Call{Call: _e.mock.On("ValidateToken", ctx, tokenString)}
488+}
489+
490+func (_c *MockAuthService_ValidateToken_Call) Run(run func(ctx context.Context, tokenString string)) *MockAuthService_ValidateToken_Call {
491+ _c.Call.Run(func(args mock.Arguments) {
492+ var arg0 context.Context
493+ if args[0] != nil {
494+ arg0 = args[0].(context.Context)
495+ }
496+ var arg1 string
497+ if args[1] != nil {
498+ arg1 = args[1].(string)
499+ }
500+ run(
501+ arg0,
502+ arg1,
503+ )
504+ })
505+ return _c
506+}
507+
508+func (_c *MockAuthService_ValidateToken_Call) Return(tokenClaims *domain.TokenClaims, err error) *MockAuthService_ValidateToken_Call {
509+ _c.Call.Return(tokenClaims, err)
510+ return _c
511+}
512+
513+func (_c *MockAuthService_ValidateToken_Call) RunAndReturn(run func(ctx context.Context, tokenString string) (*domain.TokenClaims, error)) *MockAuthService_ValidateToken_Call {
514+ _c.Call.Return(run)
515+ return _c
516+}
@@ -0,0 +1,516 @@
1+// Code generated by mockery; DO NOT EDIT.
2+// github.com/vektra/mockery
3+// template: testify
4+
5+package mocks
6+
7+import (
8+ "context"
9+ "gordon/internal/domain"
10+ "time"
11+
12+ mock "github.com/stretchr/testify/mock"
13+)
14+
15+// NewMockAuthService creates a new instance of MockAuthService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
16+// The first argument is typically a *testing.T value.
17+func NewMockAuthService(t interface {
18+ mock.TestingT
19+ Cleanup(func())
20+}) *MockAuthService {
21+ mock := &MockAuthService{}
22+ mock.Mock.Test(t)
23+
24+ t.Cleanup(func() { mock.AssertExpectations(t) })
25+
26+ return mock
27+}
28+
29+// MockAuthService is an autogenerated mock type for the AuthService type
30+type MockAuthService struct {
31+ mock.Mock
32+}
33+
34+type MockAuthService_Expecter struct {
35+ mock *mock.Mock
36+}
37+
38+func (_m *MockAuthService) EXPECT() *MockAuthService_Expecter {
39+ return &MockAuthService_Expecter{mock: &_m.Mock}
40+}
41+
42+// GeneratePasswordHash provides a mock function for the type MockAuthService
43+func (_mock *MockAuthService) GeneratePasswordHash(password string) (string, error) {
44+ ret := _mock.Called(password)
45+
46+ if len(ret) == 0 {
47+ panic("no return value specified for GeneratePasswordHash")
48+ }
49+
50+ var r0 string
51+ var r1 error
52+ if returnFunc, ok := ret.Get(0).(func(string) (string, error)); ok {
53+ return returnFunc(password)
54+ }
55+ if returnFunc, ok := ret.Get(0).(func(string) string); ok {
56+ r0 = returnFunc(password)
57+ } else {
58+ r0 = ret.Get(0).(string)
59+ }
60+ if returnFunc, ok := ret.Get(1).(func(string) error); ok {
61+ r1 = returnFunc(password)
62+ } else {
63+ r1 = ret.Error(1)
64+ }
65+ return r0, r1
66+}
67+
68+// MockAuthService_GeneratePasswordHash_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GeneratePasswordHash'
69+type MockAuthService_GeneratePasswordHash_Call struct {
70+ *mock.Call
71+}
72+
73+// GeneratePasswordHash is a helper method to define mock.On call
74+// - password string
75+func (_e *MockAuthService_Expecter) GeneratePasswordHash(password interface{}) *MockAuthService_GeneratePasswordHash_Call {
76+ return &MockAuthService_GeneratePasswordHash_Call{Call: _e.mock.On("GeneratePasswordHash", password)}
77+}
78+
79+func (_c *MockAuthService_GeneratePasswordHash_Call) Run(run func(password string)) *MockAuthService_GeneratePasswordHash_Call {
80+ _c.Call.Run(func(args mock.Arguments) {
81+ var arg0 string
82+ if args[0] != nil {
83+ arg0 = args[0].(string)
84+ }
85+ run(
86+ arg0,
87+ )
88+ })
89+ return _c
90+}
91+
92+func (_c *MockAuthService_GeneratePasswordHash_Call) Return(s string, err error) *MockAuthService_GeneratePasswordHash_Call {
93+ _c.Call.Return(s, err)
94+ return _c
95+}
96+
97+func (_c *MockAuthService_GeneratePasswordHash_Call) RunAndReturn(run func(password string) (string, error)) *MockAuthService_GeneratePasswordHash_Call {
98+ _c.Call.Return(run)
99+ return _c
100+}
101+
102+// GenerateToken provides a mock function for the type MockAuthService
103+func (_mock *MockAuthService) GenerateToken(ctx context.Context, subject string, scopes []string, expiry time.Duration) (string, error) {
104+ ret := _mock.Called(ctx, subject, scopes, expiry)
105+
106+ if len(ret) == 0 {
107+ panic("no return value specified for GenerateToken")
108+ }
109+
110+ var r0 string
111+ var r1 error
112+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, []string, time.Duration) (string, error)); ok {
113+ return returnFunc(ctx, subject, scopes, expiry)
114+ }
115+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, []string, time.Duration) string); ok {
116+ r0 = returnFunc(ctx, subject, scopes, expiry)
117+ } else {
118+ r0 = ret.Get(0).(string)
119+ }
120+ if returnFunc, ok := ret.Get(1).(func(context.Context, string, []string, time.Duration) error); ok {
121+ r1 = returnFunc(ctx, subject, scopes, expiry)
122+ } else {
123+ r1 = ret.Error(1)
124+ }
125+ return r0, r1
126+}
127+
128+// MockAuthService_GenerateToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenerateToken'
129+type MockAuthService_GenerateToken_Call struct {
130+ *mock.Call
131+}
132+
133+// GenerateToken is a helper method to define mock.On call
134+// - ctx context.Context
135+// - subject string
136+// - scopes []string
137+// - expiry time.Duration
138+func (_e *MockAuthService_Expecter) GenerateToken(ctx interface{}, subject interface{}, scopes interface{}, expiry interface{}) *MockAuthService_GenerateToken_Call {
139+ return &MockAuthService_GenerateToken_Call{Call: _e.mock.On("GenerateToken", ctx, subject, scopes, expiry)}
140+}
141+
142+func (_c *MockAuthService_GenerateToken_Call) Run(run func(ctx context.Context, subject string, scopes []string, expiry time.Duration)) *MockAuthService_GenerateToken_Call {
143+ _c.Call.Run(func(args mock.Arguments) {
144+ var arg0 context.Context
145+ if args[0] != nil {
146+ arg0 = args[0].(context.Context)
147+ }
148+ var arg1 string
149+ if args[1] != nil {
150+ arg1 = args[1].(string)
151+ }
152+ var arg2 []string
153+ if args[2] != nil {
154+ arg2 = args[2].([]string)
155+ }
156+ var arg3 time.Duration
157+ if args[3] != nil {
158+ arg3 = args[3].(time.Duration)
159+ }
160+ run(
161+ arg0,
162+ arg1,
163+ arg2,
164+ arg3,
165+ )
166+ })
167+ return _c
168+}
169+
170+func (_c *MockAuthService_GenerateToken_Call) Return(s string, err error) *MockAuthService_GenerateToken_Call {
171+ _c.Call.Return(s, err)
172+ return _c
173+}
174+
175+func (_c *MockAuthService_GenerateToken_Call) RunAndReturn(run func(ctx context.Context, subject string, scopes []string, expiry time.Duration) (string, error)) *MockAuthService_GenerateToken_Call {
176+ _c.Call.Return(run)
177+ return _c
178+}
179+
180+// GetAuthType provides a mock function for the type MockAuthService
181+func (_mock *MockAuthService) GetAuthType() domain.AuthType {
182+ ret := _mock.Called()
183+
184+ if len(ret) == 0 {
185+ panic("no return value specified for GetAuthType")
186+ }
187+
188+ var r0 domain.AuthType
189+ if returnFunc, ok := ret.Get(0).(func() domain.AuthType); ok {
190+ r0 = returnFunc()
191+ } else {
192+ r0 = ret.Get(0).(domain.AuthType)
193+ }
194+ return r0
195+}
196+
197+// MockAuthService_GetAuthType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAuthType'
198+type MockAuthService_GetAuthType_Call struct {
199+ *mock.Call
200+}
201+
202+// GetAuthType is a helper method to define mock.On call
203+func (_e *MockAuthService_Expecter) GetAuthType() *MockAuthService_GetAuthType_Call {
204+ return &MockAuthService_GetAuthType_Call{Call: _e.mock.On("GetAuthType")}
205+}
206+
207+func (_c *MockAuthService_GetAuthType_Call) Run(run func()) *MockAuthService_GetAuthType_Call {
208+ _c.Call.Run(func(args mock.Arguments) {
209+ run()
210+ })
211+ return _c
212+}
213+
214+func (_c *MockAuthService_GetAuthType_Call) Return(authType domain.AuthType) *MockAuthService_GetAuthType_Call {
215+ _c.Call.Return(authType)
216+ return _c
217+}
218+
219+func (_c *MockAuthService_GetAuthType_Call) RunAndReturn(run func() domain.AuthType) *MockAuthService_GetAuthType_Call {
220+ _c.Call.Return(run)
221+ return _c
222+}
223+
224+// IsEnabled provides a mock function for the type MockAuthService
225+func (_mock *MockAuthService) IsEnabled() bool {
226+ ret := _mock.Called()
227+
228+ if len(ret) == 0 {
229+ panic("no return value specified for IsEnabled")
230+ }
231+
232+ var r0 bool
233+ if returnFunc, ok := ret.Get(0).(func() bool); ok {
234+ r0 = returnFunc()
235+ } else {
236+ r0 = ret.Get(0).(bool)
237+ }
238+ return r0
239+}
240+
241+// MockAuthService_IsEnabled_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsEnabled'
242+type MockAuthService_IsEnabled_Call struct {
243+ *mock.Call
244+}
245+
246+// IsEnabled is a helper method to define mock.On call
247+func (_e *MockAuthService_Expecter) IsEnabled() *MockAuthService_IsEnabled_Call {
248+ return &MockAuthService_IsEnabled_Call{Call: _e.mock.On("IsEnabled")}
249+}
250+
251+func (_c *MockAuthService_IsEnabled_Call) Run(run func()) *MockAuthService_IsEnabled_Call {
252+ _c.Call.Run(func(args mock.Arguments) {
253+ run()
254+ })
255+ return _c
256+}
257+
258+func (_c *MockAuthService_IsEnabled_Call) Return(b bool) *MockAuthService_IsEnabled_Call {
259+ _c.Call.Return(b)
260+ return _c
261+}
262+
263+func (_c *MockAuthService_IsEnabled_Call) RunAndReturn(run func() bool) *MockAuthService_IsEnabled_Call {
264+ _c.Call.Return(run)
265+ return _c
266+}
267+
268+// ListTokens provides a mock function for the type MockAuthService
269+func (_mock *MockAuthService) ListTokens(ctx context.Context) ([]domain.Token, error) {
270+ ret := _mock.Called(ctx)
271+
272+ if len(ret) == 0 {
273+ panic("no return value specified for ListTokens")
274+ }
275+
276+ var r0 []domain.Token
277+ var r1 error
278+ if returnFunc, ok := ret.Get(0).(func(context.Context) ([]domain.Token, error)); ok {
279+ return returnFunc(ctx)
280+ }
281+ if returnFunc, ok := ret.Get(0).(func(context.Context) []domain.Token); ok {
282+ r0 = returnFunc(ctx)
283+ } else {
284+ if ret.Get(0) != nil {
285+ r0 = ret.Get(0).([]domain.Token)
286+ }
287+ }
288+ if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok {
289+ r1 = returnFunc(ctx)
290+ } else {
291+ r1 = ret.Error(1)
292+ }
293+ return r0, r1
294+}
295+
296+// MockAuthService_ListTokens_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListTokens'
297+type MockAuthService_ListTokens_Call struct {
298+ *mock.Call
299+}
300+
301+// ListTokens is a helper method to define mock.On call
302+// - ctx context.Context
303+func (_e *MockAuthService_Expecter) ListTokens(ctx interface{}) *MockAuthService_ListTokens_Call {
304+ return &MockAuthService_ListTokens_Call{Call: _e.mock.On("ListTokens", ctx)}
305+}
306+
307+func (_c *MockAuthService_ListTokens_Call) Run(run func(ctx context.Context)) *MockAuthService_ListTokens_Call {
308+ _c.Call.Run(func(args mock.Arguments) {
309+ var arg0 context.Context
310+ if args[0] != nil {
311+ arg0 = args[0].(context.Context)
312+ }
313+ run(
314+ arg0,
315+ )
316+ })
317+ return _c
318+}
319+
320+func (_c *MockAuthService_ListTokens_Call) Return(tokens []domain.Token, err error) *MockAuthService_ListTokens_Call {
321+ _c.Call.Return(tokens, err)
322+ return _c
323+}
324+
325+func (_c *MockAuthService_ListTokens_Call) RunAndReturn(run func(ctx context.Context) ([]domain.Token, error)) *MockAuthService_ListTokens_Call {
326+ _c.Call.Return(run)
327+ return _c
328+}
329+
330+// RevokeToken provides a mock function for the type MockAuthService
331+func (_mock *MockAuthService) RevokeToken(ctx context.Context, tokenID string) error {
332+ ret := _mock.Called(ctx, tokenID)
333+
334+ if len(ret) == 0 {
335+ panic("no return value specified for RevokeToken")
336+ }
337+
338+ var r0 error
339+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
340+ r0 = returnFunc(ctx, tokenID)
341+ } else {
342+ r0 = ret.Error(0)
343+ }
344+ return r0
345+}
346+
347+// MockAuthService_RevokeToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RevokeToken'
348+type MockAuthService_RevokeToken_Call struct {
349+ *mock.Call
350+}
351+
352+// RevokeToken is a helper method to define mock.On call
353+// - ctx context.Context
354+// - tokenID string
355+func (_e *MockAuthService_Expecter) RevokeToken(ctx interface{}, tokenID interface{}) *MockAuthService_RevokeToken_Call {
356+ return &MockAuthService_RevokeToken_Call{Call: _e.mock.On("RevokeToken", ctx, tokenID)}
357+}
358+
359+func (_c *MockAuthService_RevokeToken_Call) Run(run func(ctx context.Context, tokenID string)) *MockAuthService_RevokeToken_Call {
360+ _c.Call.Run(func(args mock.Arguments) {
361+ var arg0 context.Context
362+ if args[0] != nil {
363+ arg0 = args[0].(context.Context)
364+ }
365+ var arg1 string
366+ if args[1] != nil {
367+ arg1 = args[1].(string)
368+ }
369+ run(
370+ arg0,
371+ arg1,
372+ )
373+ })
374+ return _c
375+}
376+
377+func (_c *MockAuthService_RevokeToken_Call) Return(err error) *MockAuthService_RevokeToken_Call {
378+ _c.Call.Return(err)
379+ return _c
380+}
381+
382+func (_c *MockAuthService_RevokeToken_Call) RunAndReturn(run func(ctx context.Context, tokenID string) error) *MockAuthService_RevokeToken_Call {
383+ _c.Call.Return(run)
384+ return _c
385+}
386+
387+// ValidatePassword provides a mock function for the type MockAuthService
388+func (_mock *MockAuthService) ValidatePassword(ctx context.Context, username string, password string) bool {
389+ ret := _mock.Called(ctx, username, password)
390+
391+ if len(ret) == 0 {
392+ panic("no return value specified for ValidatePassword")
393+ }
394+
395+ var r0 bool
396+ if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) bool); ok {
397+ r0 = returnFunc(ctx, username, password)
398+ } else {
399+ r0 = ret.Get(0).(bool)
400+ }
401+ return r0
402+}
403+
404+// MockAuthService_ValidatePassword_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidatePassword'
405+type MockAuthService_ValidatePassword_Call struct {
406+ *mock.Call
407+}
408+
409+// ValidatePassword is a helper method to define mock.On call
410+// - ctx context.Context
411+// - username string
412+// - password string
413+func (_e *MockAuthService_Expecter) ValidatePassword(ctx interface{}, username interface{}, password interface{}) *MockAuthService_ValidatePassword_Call {
414+ return &MockAuthService_ValidatePassword_Call{Call: _e.mock.On("ValidatePassword", ctx, username, password)}
415+}
416+
417+func (_c *MockAuthService_ValidatePassword_Call) Run(run func(ctx context.Context, username string, password string)) *MockAuthService_ValidatePassword_Call {
418+ _c.Call.Run(func(args mock.Arguments) {
419+ var arg0 context.Context
420+ if args[0] != nil {
421+ arg0 = args[0].(context.Context)
422+ }
423+ var arg1 string
424+ if args[1] != nil {
425+ arg1 = args[1].(string)
426+ }
427+ var arg2 string
428+ if args[2] != nil {
429+ arg2 = args[2].(string)
430+ }
431+ run(
432+ arg0,
433+ arg1,
434+ arg2,
435+ )
436+ })
437+ return _c
438+}
439+
440+func (_c *MockAuthService_ValidatePassword_Call) Return(b bool) *MockAuthService_ValidatePassword_Call {
441+ _c.Call.Return(b)
442+ return _c
443+}
444+
445+func (_c *MockAuthService_ValidatePassword_Call) RunAndReturn(run func(ctx context.Context, username string, password string) bool) *MockAuthService_ValidatePassword_Call {
446+ _c.Call.Return(run)
447+ return _c
448+}
449+
450+// ValidateToken provides a mock function for the type MockAuthService
451+func (_mock *MockAuthService) ValidateToken(ctx context.Context, tokenString string) (*domain.TokenClaims, error) {
452+ ret := _mock.Called(ctx, tokenString)
453+
454+ if len(ret) == 0 {
455+ panic("no return value specified for ValidateToken")
456+ }
457+
458+ var r0 *domain.TokenClaims
459+ var r1 error
460+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) (*domain.TokenClaims, error)); ok {
461+ return returnFunc(ctx, tokenString)
462+ }
463+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) *domain.TokenClaims); ok {
464+ r0 = returnFunc(ctx, tokenString)
465+ } else {
466+ if ret.Get(0) != nil {
467+ r0 = ret.Get(0).(*domain.TokenClaims)
468+ }
469+ }
470+ if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
471+ r1 = returnFunc(ctx, tokenString)
472+ } else {
473+ r1 = ret.Error(1)
474+ }
475+ return r0, r1
476+}
477+
478+// MockAuthService_ValidateToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ValidateToken'
479+type MockAuthService_ValidateToken_Call struct {
480+ *mock.Call
481+}
482+
483+// ValidateToken is a helper method to define mock.On call
484+// - ctx context.Context
485+// - tokenString string
486+func (_e *MockAuthService_Expecter) ValidateToken(ctx interface{}, tokenString interface{}) *MockAuthService_ValidateToken_Call {
487+ return &MockAuthService_ValidateToken_Call{Call: _e.mock.On("ValidateToken", ctx, tokenString)}
488+}
489+
490+func (_c *MockAuthService_ValidateToken_Call) Run(run func(ctx context.Context, tokenString string)) *MockAuthService_ValidateToken_Call {
491+ _c.Call.Run(func(args mock.Arguments) {
492+ var arg0 context.Context
493+ if args[0] != nil {
494+ arg0 = args[0].(context.Context)
495+ }
496+ var arg1 string
497+ if args[1] != nil {
498+ arg1 = args[1].(string)
499+ }
500+ run(
501+ arg0,
502+ arg1,
503+ )
504+ })
505+ return _c
506+}
507+
508+func (_c *MockAuthService_ValidateToken_Call) Return(tokenClaims *domain.TokenClaims, err error) *MockAuthService_ValidateToken_Call {
509+ _c.Call.Return(tokenClaims, err)
510+ return _c
511+}
512+
513+func (_c *MockAuthService_ValidateToken_Call) RunAndReturn(run func(ctx context.Context, tokenString string) (*domain.TokenClaims, error)) *MockAuthService_ValidateToken_Call {
514+ _c.Call.Return(run)
515+ return _c
516+}
A internal/boundaries/out/mocks/mock_token_store.go +418 -0
@@ -0,0 +1,418 @@
1+// Code generated by mockery; DO NOT EDIT.
2+// github.com/vektra/mockery
3+// template: testify
4+
5+package mocks
6+
7+import (
8+ "context"
9+ "gordon/internal/domain"
10+
11+ mock "github.com/stretchr/testify/mock"
12+)
13+
14+// NewMockTokenStore creates a new instance of MockTokenStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
15+// The first argument is typically a *testing.T value.
16+func NewMockTokenStore(t interface {
17+ mock.TestingT
18+ Cleanup(func())
19+}) *MockTokenStore {
20+ mock := &MockTokenStore{}
21+ mock.Mock.Test(t)
22+
23+ t.Cleanup(func() { mock.AssertExpectations(t) })
24+
25+ return mock
26+}
27+
28+// MockTokenStore is an autogenerated mock type for the TokenStore type
29+type MockTokenStore struct {
30+ mock.Mock
31+}
32+
33+type MockTokenStore_Expecter struct {
34+ mock *mock.Mock
35+}
36+
37+func (_m *MockTokenStore) EXPECT() *MockTokenStore_Expecter {
38+ return &MockTokenStore_Expecter{mock: &_m.Mock}
39+}
40+
41+// DeleteToken provides a mock function for the type MockTokenStore
42+func (_mock *MockTokenStore) DeleteToken(ctx context.Context, subject string) error {
43+ ret := _mock.Called(ctx, subject)
44+
45+ if len(ret) == 0 {
46+ panic("no return value specified for DeleteToken")
47+ }
48+
49+ var r0 error
50+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
51+ r0 = returnFunc(ctx, subject)
52+ } else {
53+ r0 = ret.Error(0)
54+ }
55+ return r0
56+}
57+
58+// MockTokenStore_DeleteToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteToken'
59+type MockTokenStore_DeleteToken_Call struct {
60+ *mock.Call
61+}
62+
63+// DeleteToken is a helper method to define mock.On call
64+// - ctx context.Context
65+// - subject string
66+func (_e *MockTokenStore_Expecter) DeleteToken(ctx interface{}, subject interface{}) *MockTokenStore_DeleteToken_Call {
67+ return &MockTokenStore_DeleteToken_Call{Call: _e.mock.On("DeleteToken", ctx, subject)}
68+}
69+
70+func (_c *MockTokenStore_DeleteToken_Call) Run(run func(ctx context.Context, subject string)) *MockTokenStore_DeleteToken_Call {
71+ _c.Call.Run(func(args mock.Arguments) {
72+ var arg0 context.Context
73+ if args[0] != nil {
74+ arg0 = args[0].(context.Context)
75+ }
76+ var arg1 string
77+ if args[1] != nil {
78+ arg1 = args[1].(string)
79+ }
80+ run(
81+ arg0,
82+ arg1,
83+ )
84+ })
85+ return _c
86+}
87+
88+func (_c *MockTokenStore_DeleteToken_Call) Return(err error) *MockTokenStore_DeleteToken_Call {
89+ _c.Call.Return(err)
90+ return _c
91+}
92+
93+func (_c *MockTokenStore_DeleteToken_Call) RunAndReturn(run func(ctx context.Context, subject string) error) *MockTokenStore_DeleteToken_Call {
94+ _c.Call.Return(run)
95+ return _c
96+}
97+
98+// GetToken provides a mock function for the type MockTokenStore
99+func (_mock *MockTokenStore) GetToken(ctx context.Context, subject string) (string, *domain.Token, error) {
100+ ret := _mock.Called(ctx, subject)
101+
102+ if len(ret) == 0 {
103+ panic("no return value specified for GetToken")
104+ }
105+
106+ var r0 string
107+ var r1 *domain.Token
108+ var r2 error
109+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) (string, *domain.Token, error)); ok {
110+ return returnFunc(ctx, subject)
111+ }
112+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) string); ok {
113+ r0 = returnFunc(ctx, subject)
114+ } else {
115+ r0 = ret.Get(0).(string)
116+ }
117+ if returnFunc, ok := ret.Get(1).(func(context.Context, string) *domain.Token); ok {
118+ r1 = returnFunc(ctx, subject)
119+ } else {
120+ if ret.Get(1) != nil {
121+ r1 = ret.Get(1).(*domain.Token)
122+ }
123+ }
124+ if returnFunc, ok := ret.Get(2).(func(context.Context, string) error); ok {
125+ r2 = returnFunc(ctx, subject)
126+ } else {
127+ r2 = ret.Error(2)
128+ }
129+ return r0, r1, r2
130+}
131+
132+// MockTokenStore_GetToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetToken'
133+type MockTokenStore_GetToken_Call struct {
134+ *mock.Call
135+}
136+
137+// GetToken is a helper method to define mock.On call
138+// - ctx context.Context
139+// - subject string
140+func (_e *MockTokenStore_Expecter) GetToken(ctx interface{}, subject interface{}) *MockTokenStore_GetToken_Call {
141+ return &MockTokenStore_GetToken_Call{Call: _e.mock.On("GetToken", ctx, subject)}
142+}
143+
144+func (_c *MockTokenStore_GetToken_Call) Run(run func(ctx context.Context, subject string)) *MockTokenStore_GetToken_Call {
145+ _c.Call.Run(func(args mock.Arguments) {
146+ var arg0 context.Context
147+ if args[0] != nil {
148+ arg0 = args[0].(context.Context)
149+ }
150+ var arg1 string
151+ if args[1] != nil {
152+ arg1 = args[1].(string)
153+ }
154+ run(
155+ arg0,
156+ arg1,
157+ )
158+ })
159+ return _c
160+}
161+
162+func (_c *MockTokenStore_GetToken_Call) Return(s string, token *domain.Token, err error) *MockTokenStore_GetToken_Call {
163+ _c.Call.Return(s, token, err)
164+ return _c
165+}
166+
167+func (_c *MockTokenStore_GetToken_Call) RunAndReturn(run func(ctx context.Context, subject string) (string, *domain.Token, error)) *MockTokenStore_GetToken_Call {
168+ _c.Call.Return(run)
169+ return _c
170+}
171+
172+// IsRevoked provides a mock function for the type MockTokenStore
173+func (_mock *MockTokenStore) IsRevoked(ctx context.Context, tokenID string) (bool, error) {
174+ ret := _mock.Called(ctx, tokenID)
175+
176+ if len(ret) == 0 {
177+ panic("no return value specified for IsRevoked")
178+ }
179+
180+ var r0 bool
181+ var r1 error
182+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) (bool, error)); ok {
183+ return returnFunc(ctx, tokenID)
184+ }
185+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) bool); ok {
186+ r0 = returnFunc(ctx, tokenID)
187+ } else {
188+ r0 = ret.Get(0).(bool)
189+ }
190+ if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
191+ r1 = returnFunc(ctx, tokenID)
192+ } else {
193+ r1 = ret.Error(1)
194+ }
195+ return r0, r1
196+}
197+
198+// MockTokenStore_IsRevoked_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRevoked'
199+type MockTokenStore_IsRevoked_Call struct {
200+ *mock.Call
201+}
202+
203+// IsRevoked is a helper method to define mock.On call
204+// - ctx context.Context
205+// - tokenID string
206+func (_e *MockTokenStore_Expecter) IsRevoked(ctx interface{}, tokenID interface{}) *MockTokenStore_IsRevoked_Call {
207+ return &MockTokenStore_IsRevoked_Call{Call: _e.mock.On("IsRevoked", ctx, tokenID)}
208+}
209+
210+func (_c *MockTokenStore_IsRevoked_Call) Run(run func(ctx context.Context, tokenID string)) *MockTokenStore_IsRevoked_Call {
211+ _c.Call.Run(func(args mock.Arguments) {
212+ var arg0 context.Context
213+ if args[0] != nil {
214+ arg0 = args[0].(context.Context)
215+ }
216+ var arg1 string
217+ if args[1] != nil {
218+ arg1 = args[1].(string)
219+ }
220+ run(
221+ arg0,
222+ arg1,
223+ )
224+ })
225+ return _c
226+}
227+
228+func (_c *MockTokenStore_IsRevoked_Call) Return(b bool, err error) *MockTokenStore_IsRevoked_Call {
229+ _c.Call.Return(b, err)
230+ return _c
231+}
232+
233+func (_c *MockTokenStore_IsRevoked_Call) RunAndReturn(run func(ctx context.Context, tokenID string) (bool, error)) *MockTokenStore_IsRevoked_Call {
234+ _c.Call.Return(run)
235+ return _c
236+}
237+
238+// ListTokens provides a mock function for the type MockTokenStore
239+func (_mock *MockTokenStore) ListTokens(ctx context.Context) ([]domain.Token, error) {
240+ ret := _mock.Called(ctx)
241+
242+ if len(ret) == 0 {
243+ panic("no return value specified for ListTokens")
244+ }
245+
246+ var r0 []domain.Token
247+ var r1 error
248+ if returnFunc, ok := ret.Get(0).(func(context.Context) ([]domain.Token, error)); ok {
249+ return returnFunc(ctx)
250+ }
251+ if returnFunc, ok := ret.Get(0).(func(context.Context) []domain.Token); ok {
252+ r0 = returnFunc(ctx)
253+ } else {
254+ if ret.Get(0) != nil {
255+ r0 = ret.Get(0).([]domain.Token)
256+ }
257+ }
258+ if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok {
259+ r1 = returnFunc(ctx)
260+ } else {
261+ r1 = ret.Error(1)
262+ }
263+ return r0, r1
264+}
265+
266+// MockTokenStore_ListTokens_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListTokens'
267+type MockTokenStore_ListTokens_Call struct {
268+ *mock.Call
269+}
270+
271+// ListTokens is a helper method to define mock.On call
272+// - ctx context.Context
273+func (_e *MockTokenStore_Expecter) ListTokens(ctx interface{}) *MockTokenStore_ListTokens_Call {
274+ return &MockTokenStore_ListTokens_Call{Call: _e.mock.On("ListTokens", ctx)}
275+}
276+
277+func (_c *MockTokenStore_ListTokens_Call) Run(run func(ctx context.Context)) *MockTokenStore_ListTokens_Call {
278+ _c.Call.Run(func(args mock.Arguments) {
279+ var arg0 context.Context
280+ if args[0] != nil {
281+ arg0 = args[0].(context.Context)
282+ }
283+ run(
284+ arg0,
285+ )
286+ })
287+ return _c
288+}
289+
290+func (_c *MockTokenStore_ListTokens_Call) Return(tokens []domain.Token, err error) *MockTokenStore_ListTokens_Call {
291+ _c.Call.Return(tokens, err)
292+ return _c
293+}
294+
295+func (_c *MockTokenStore_ListTokens_Call) RunAndReturn(run func(ctx context.Context) ([]domain.Token, error)) *MockTokenStore_ListTokens_Call {
296+ _c.Call.Return(run)
297+ return _c
298+}
299+
300+// Revoke provides a mock function for the type MockTokenStore
301+func (_mock *MockTokenStore) Revoke(ctx context.Context, tokenID string) error {
302+ ret := _mock.Called(ctx, tokenID)
303+
304+ if len(ret) == 0 {
305+ panic("no return value specified for Revoke")
306+ }
307+
308+ var r0 error
309+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
310+ r0 = returnFunc(ctx, tokenID)
311+ } else {
312+ r0 = ret.Error(0)
313+ }
314+ return r0
315+}
316+
317+// MockTokenStore_Revoke_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Revoke'
318+type MockTokenStore_Revoke_Call struct {
319+ *mock.Call
320+}
321+
322+// Revoke is a helper method to define mock.On call
323+// - ctx context.Context
324+// - tokenID string
325+func (_e *MockTokenStore_Expecter) Revoke(ctx interface{}, tokenID interface{}) *MockTokenStore_Revoke_Call {
326+ return &MockTokenStore_Revoke_Call{Call: _e.mock.On("Revoke", ctx, tokenID)}
327+}
328+
329+func (_c *MockTokenStore_Revoke_Call) Run(run func(ctx context.Context, tokenID string)) *MockTokenStore_Revoke_Call {
330+ _c.Call.Run(func(args mock.Arguments) {
331+ var arg0 context.Context
332+ if args[0] != nil {
333+ arg0 = args[0].(context.Context)
334+ }
335+ var arg1 string
336+ if args[1] != nil {
337+ arg1 = args[1].(string)
338+ }
339+ run(
340+ arg0,
341+ arg1,
342+ )
343+ })
344+ return _c
345+}
346+
347+func (_c *MockTokenStore_Revoke_Call) Return(err error) *MockTokenStore_Revoke_Call {
348+ _c.Call.Return(err)
349+ return _c
350+}
351+
352+func (_c *MockTokenStore_Revoke_Call) RunAndReturn(run func(ctx context.Context, tokenID string) error) *MockTokenStore_Revoke_Call {
353+ _c.Call.Return(run)
354+ return _c
355+}
356+
357+// SaveToken provides a mock function for the type MockTokenStore
358+func (_mock *MockTokenStore) SaveToken(ctx context.Context, token *domain.Token, jwt string) error {
359+ ret := _mock.Called(ctx, token, jwt)
360+
361+ if len(ret) == 0 {
362+ panic("no return value specified for SaveToken")
363+ }
364+
365+ var r0 error
366+ if returnFunc, ok := ret.Get(0).(func(context.Context, *domain.Token, string) error); ok {
367+ r0 = returnFunc(ctx, token, jwt)
368+ } else {
369+ r0 = ret.Error(0)
370+ }
371+ return r0
372+}
373+
374+// MockTokenStore_SaveToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveToken'
375+type MockTokenStore_SaveToken_Call struct {
376+ *mock.Call
377+}
378+
379+// SaveToken is a helper method to define mock.On call
380+// - ctx context.Context
381+// - token *domain.Token
382+// - jwt string
383+func (_e *MockTokenStore_Expecter) SaveToken(ctx interface{}, token interface{}, jwt interface{}) *MockTokenStore_SaveToken_Call {
384+ return &MockTokenStore_SaveToken_Call{Call: _e.mock.On("SaveToken", ctx, token, jwt)}
385+}
386+
387+func (_c *MockTokenStore_SaveToken_Call) Run(run func(ctx context.Context, token *domain.Token, jwt string)) *MockTokenStore_SaveToken_Call {
388+ _c.Call.Run(func(args mock.Arguments) {
389+ var arg0 context.Context
390+ if args[0] != nil {
391+ arg0 = args[0].(context.Context)
392+ }
393+ var arg1 *domain.Token
394+ if args[1] != nil {
395+ arg1 = args[1].(*domain.Token)
396+ }
397+ var arg2 string
398+ if args[2] != nil {
399+ arg2 = args[2].(string)
400+ }
401+ run(
402+ arg0,
403+ arg1,
404+ arg2,
405+ )
406+ })
407+ return _c
408+}
409+
410+func (_c *MockTokenStore_SaveToken_Call) Return(err error) *MockTokenStore_SaveToken_Call {
411+ _c.Call.Return(err)
412+ return _c
413+}
414+
415+func (_c *MockTokenStore_SaveToken_Call) RunAndReturn(run func(ctx context.Context, token *domain.Token, jwt string) error) *MockTokenStore_SaveToken_Call {
416+ _c.Call.Return(run)
417+ return _c
418+}
@@ -0,0 +1,418 @@
1+// Code generated by mockery; DO NOT EDIT.
2+// github.com/vektra/mockery
3+// template: testify
4+
5+package mocks
6+
7+import (
8+ "context"
9+ "gordon/internal/domain"
10+
11+ mock "github.com/stretchr/testify/mock"
12+)
13+
14+// NewMockTokenStore creates a new instance of MockTokenStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
15+// The first argument is typically a *testing.T value.
16+func NewMockTokenStore(t interface {
17+ mock.TestingT
18+ Cleanup(func())
19+}) *MockTokenStore {
20+ mock := &MockTokenStore{}
21+ mock.Mock.Test(t)
22+
23+ t.Cleanup(func() { mock.AssertExpectations(t) })
24+
25+ return mock
26+}
27+
28+// MockTokenStore is an autogenerated mock type for the TokenStore type
29+type MockTokenStore struct {
30+ mock.Mock
31+}
32+
33+type MockTokenStore_Expecter struct {
34+ mock *mock.Mock
35+}
36+
37+func (_m *MockTokenStore) EXPECT() *MockTokenStore_Expecter {
38+ return &MockTokenStore_Expecter{mock: &_m.Mock}
39+}
40+
41+// DeleteToken provides a mock function for the type MockTokenStore
42+func (_mock *MockTokenStore) DeleteToken(ctx context.Context, subject string) error {
43+ ret := _mock.Called(ctx, subject)
44+
45+ if len(ret) == 0 {
46+ panic("no return value specified for DeleteToken")
47+ }
48+
49+ var r0 error
50+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
51+ r0 = returnFunc(ctx, subject)
52+ } else {
53+ r0 = ret.Error(0)
54+ }
55+ return r0
56+}
57+
58+// MockTokenStore_DeleteToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteToken'
59+type MockTokenStore_DeleteToken_Call struct {
60+ *mock.Call
61+}
62+
63+// DeleteToken is a helper method to define mock.On call
64+// - ctx context.Context
65+// - subject string
66+func (_e *MockTokenStore_Expecter) DeleteToken(ctx interface{}, subject interface{}) *MockTokenStore_DeleteToken_Call {
67+ return &MockTokenStore_DeleteToken_Call{Call: _e.mock.On("DeleteToken", ctx, subject)}
68+}
69+
70+func (_c *MockTokenStore_DeleteToken_Call) Run(run func(ctx context.Context, subject string)) *MockTokenStore_DeleteToken_Call {
71+ _c.Call.Run(func(args mock.Arguments) {
72+ var arg0 context.Context
73+ if args[0] != nil {
74+ arg0 = args[0].(context.Context)
75+ }
76+ var arg1 string
77+ if args[1] != nil {
78+ arg1 = args[1].(string)
79+ }
80+ run(
81+ arg0,
82+ arg1,
83+ )
84+ })
85+ return _c
86+}
87+
88+func (_c *MockTokenStore_DeleteToken_Call) Return(err error) *MockTokenStore_DeleteToken_Call {
89+ _c.Call.Return(err)
90+ return _c
91+}
92+
93+func (_c *MockTokenStore_DeleteToken_Call) RunAndReturn(run func(ctx context.Context, subject string) error) *MockTokenStore_DeleteToken_Call {
94+ _c.Call.Return(run)
95+ return _c
96+}
97+
98+// GetToken provides a mock function for the type MockTokenStore
99+func (_mock *MockTokenStore) GetToken(ctx context.Context, subject string) (string, *domain.Token, error) {
100+ ret := _mock.Called(ctx, subject)
101+
102+ if len(ret) == 0 {
103+ panic("no return value specified for GetToken")
104+ }
105+
106+ var r0 string
107+ var r1 *domain.Token
108+ var r2 error
109+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) (string, *domain.Token, error)); ok {
110+ return returnFunc(ctx, subject)
111+ }
112+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) string); ok {
113+ r0 = returnFunc(ctx, subject)
114+ } else {
115+ r0 = ret.Get(0).(string)
116+ }
117+ if returnFunc, ok := ret.Get(1).(func(context.Context, string) *domain.Token); ok {
118+ r1 = returnFunc(ctx, subject)
119+ } else {
120+ if ret.Get(1) != nil {
121+ r1 = ret.Get(1).(*domain.Token)
122+ }
123+ }
124+ if returnFunc, ok := ret.Get(2).(func(context.Context, string) error); ok {
125+ r2 = returnFunc(ctx, subject)
126+ } else {
127+ r2 = ret.Error(2)
128+ }
129+ return r0, r1, r2
130+}
131+
132+// MockTokenStore_GetToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetToken'
133+type MockTokenStore_GetToken_Call struct {
134+ *mock.Call
135+}
136+
137+// GetToken is a helper method to define mock.On call
138+// - ctx context.Context
139+// - subject string
140+func (_e *MockTokenStore_Expecter) GetToken(ctx interface{}, subject interface{}) *MockTokenStore_GetToken_Call {
141+ return &MockTokenStore_GetToken_Call{Call: _e.mock.On("GetToken", ctx, subject)}
142+}
143+
144+func (_c *MockTokenStore_GetToken_Call) Run(run func(ctx context.Context, subject string)) *MockTokenStore_GetToken_Call {
145+ _c.Call.Run(func(args mock.Arguments) {
146+ var arg0 context.Context
147+ if args[0] != nil {
148+ arg0 = args[0].(context.Context)
149+ }
150+ var arg1 string
151+ if args[1] != nil {
152+ arg1 = args[1].(string)
153+ }
154+ run(
155+ arg0,
156+ arg1,
157+ )
158+ })
159+ return _c
160+}
161+
162+func (_c *MockTokenStore_GetToken_Call) Return(s string, token *domain.Token, err error) *MockTokenStore_GetToken_Call {
163+ _c.Call.Return(s, token, err)
164+ return _c
165+}
166+
167+func (_c *MockTokenStore_GetToken_Call) RunAndReturn(run func(ctx context.Context, subject string) (string, *domain.Token, error)) *MockTokenStore_GetToken_Call {
168+ _c.Call.Return(run)
169+ return _c
170+}
171+
172+// IsRevoked provides a mock function for the type MockTokenStore
173+func (_mock *MockTokenStore) IsRevoked(ctx context.Context, tokenID string) (bool, error) {
174+ ret := _mock.Called(ctx, tokenID)
175+
176+ if len(ret) == 0 {
177+ panic("no return value specified for IsRevoked")
178+ }
179+
180+ var r0 bool
181+ var r1 error
182+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) (bool, error)); ok {
183+ return returnFunc(ctx, tokenID)
184+ }
185+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) bool); ok {
186+ r0 = returnFunc(ctx, tokenID)
187+ } else {
188+ r0 = ret.Get(0).(bool)
189+ }
190+ if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
191+ r1 = returnFunc(ctx, tokenID)
192+ } else {
193+ r1 = ret.Error(1)
194+ }
195+ return r0, r1
196+}
197+
198+// MockTokenStore_IsRevoked_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRevoked'
199+type MockTokenStore_IsRevoked_Call struct {
200+ *mock.Call
201+}
202+
203+// IsRevoked is a helper method to define mock.On call
204+// - ctx context.Context
205+// - tokenID string
206+func (_e *MockTokenStore_Expecter) IsRevoked(ctx interface{}, tokenID interface{}) *MockTokenStore_IsRevoked_Call {
207+ return &MockTokenStore_IsRevoked_Call{Call: _e.mock.On("IsRevoked", ctx, tokenID)}
208+}
209+
210+func (_c *MockTokenStore_IsRevoked_Call) Run(run func(ctx context.Context, tokenID string)) *MockTokenStore_IsRevoked_Call {
211+ _c.Call.Run(func(args mock.Arguments) {
212+ var arg0 context.Context
213+ if args[0] != nil {
214+ arg0 = args[0].(context.Context)
215+ }
216+ var arg1 string
217+ if args[1] != nil {
218+ arg1 = args[1].(string)
219+ }
220+ run(
221+ arg0,
222+ arg1,
223+ )
224+ })
225+ return _c
226+}
227+
228+func (_c *MockTokenStore_IsRevoked_Call) Return(b bool, err error) *MockTokenStore_IsRevoked_Call {
229+ _c.Call.Return(b, err)
230+ return _c
231+}
232+
233+func (_c *MockTokenStore_IsRevoked_Call) RunAndReturn(run func(ctx context.Context, tokenID string) (bool, error)) *MockTokenStore_IsRevoked_Call {
234+ _c.Call.Return(run)
235+ return _c
236+}
237+
238+// ListTokens provides a mock function for the type MockTokenStore
239+func (_mock *MockTokenStore) ListTokens(ctx context.Context) ([]domain.Token, error) {
240+ ret := _mock.Called(ctx)
241+
242+ if len(ret) == 0 {
243+ panic("no return value specified for ListTokens")
244+ }
245+
246+ var r0 []domain.Token
247+ var r1 error
248+ if returnFunc, ok := ret.Get(0).(func(context.Context) ([]domain.Token, error)); ok {
249+ return returnFunc(ctx)
250+ }
251+ if returnFunc, ok := ret.Get(0).(func(context.Context) []domain.Token); ok {
252+ r0 = returnFunc(ctx)
253+ } else {
254+ if ret.Get(0) != nil {
255+ r0 = ret.Get(0).([]domain.Token)
256+ }
257+ }
258+ if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok {
259+ r1 = returnFunc(ctx)
260+ } else {
261+ r1 = ret.Error(1)
262+ }
263+ return r0, r1
264+}
265+
266+// MockTokenStore_ListTokens_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListTokens'
267+type MockTokenStore_ListTokens_Call struct {
268+ *mock.Call
269+}
270+
271+// ListTokens is a helper method to define mock.On call
272+// - ctx context.Context
273+func (_e *MockTokenStore_Expecter) ListTokens(ctx interface{}) *MockTokenStore_ListTokens_Call {
274+ return &MockTokenStore_ListTokens_Call{Call: _e.mock.On("ListTokens", ctx)}
275+}
276+
277+func (_c *MockTokenStore_ListTokens_Call) Run(run func(ctx context.Context)) *MockTokenStore_ListTokens_Call {
278+ _c.Call.Run(func(args mock.Arguments) {
279+ var arg0 context.Context
280+ if args[0] != nil {
281+ arg0 = args[0].(context.Context)
282+ }
283+ run(
284+ arg0,
285+ )
286+ })
287+ return _c
288+}
289+
290+func (_c *MockTokenStore_ListTokens_Call) Return(tokens []domain.Token, err error) *MockTokenStore_ListTokens_Call {
291+ _c.Call.Return(tokens, err)
292+ return _c
293+}
294+
295+func (_c *MockTokenStore_ListTokens_Call) RunAndReturn(run func(ctx context.Context) ([]domain.Token, error)) *MockTokenStore_ListTokens_Call {
296+ _c.Call.Return(run)
297+ return _c
298+}
299+
300+// Revoke provides a mock function for the type MockTokenStore
301+func (_mock *MockTokenStore) Revoke(ctx context.Context, tokenID string) error {
302+ ret := _mock.Called(ctx, tokenID)
303+
304+ if len(ret) == 0 {
305+ panic("no return value specified for Revoke")
306+ }
307+
308+ var r0 error
309+ if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
310+ r0 = returnFunc(ctx, tokenID)
311+ } else {
312+ r0 = ret.Error(0)
313+ }
314+ return r0
315+}
316+
317+// MockTokenStore_Revoke_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Revoke'
318+type MockTokenStore_Revoke_Call struct {
319+ *mock.Call
320+}
321+
322+// Revoke is a helper method to define mock.On call
323+// - ctx context.Context
324+// - tokenID string
325+func (_e *MockTokenStore_Expecter) Revoke(ctx interface{}, tokenID interface{}) *MockTokenStore_Revoke_Call {
326+ return &MockTokenStore_Revoke_Call{Call: _e.mock.On("Revoke", ctx, tokenID)}
327+}
328+
329+func (_c *MockTokenStore_Revoke_Call) Run(run func(ctx context.Context, tokenID string)) *MockTokenStore_Revoke_Call {
330+ _c.Call.Run(func(args mock.Arguments) {
331+ var arg0 context.Context
332+ if args[0] != nil {
333+ arg0 = args[0].(context.Context)
334+ }
335+ var arg1 string
336+ if args[1] != nil {
337+ arg1 = args[1].(string)
338+ }
339+ run(
340+ arg0,
341+ arg1,
342+ )
343+ })
344+ return _c
345+}
346+
347+func (_c *MockTokenStore_Revoke_Call) Return(err error) *MockTokenStore_Revoke_Call {
348+ _c.Call.Return(err)
349+ return _c
350+}
351+
352+func (_c *MockTokenStore_Revoke_Call) RunAndReturn(run func(ctx context.Context, tokenID string) error) *MockTokenStore_Revoke_Call {
353+ _c.Call.Return(run)
354+ return _c
355+}
356+
357+// SaveToken provides a mock function for the type MockTokenStore
358+func (_mock *MockTokenStore) SaveToken(ctx context.Context, token *domain.Token, jwt string) error {
359+ ret := _mock.Called(ctx, token, jwt)
360+
361+ if len(ret) == 0 {
362+ panic("no return value specified for SaveToken")
363+ }
364+
365+ var r0 error
366+ if returnFunc, ok := ret.Get(0).(func(context.Context, *domain.Token, string) error); ok {
367+ r0 = returnFunc(ctx, token, jwt)
368+ } else {
369+ r0 = ret.Error(0)
370+ }
371+ return r0
372+}
373+
374+// MockTokenStore_SaveToken_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveToken'
375+type MockTokenStore_SaveToken_Call struct {
376+ *mock.Call
377+}
378+
379+// SaveToken is a helper method to define mock.On call
380+// - ctx context.Context
381+// - token *domain.Token
382+// - jwt string
383+func (_e *MockTokenStore_Expecter) SaveToken(ctx interface{}, token interface{}, jwt interface{}) *MockTokenStore_SaveToken_Call {
384+ return &MockTokenStore_SaveToken_Call{Call: _e.mock.On("SaveToken", ctx, token, jwt)}
385+}
386+
387+func (_c *MockTokenStore_SaveToken_Call) Run(run func(ctx context.Context, token *domain.Token, jwt string)) *MockTokenStore_SaveToken_Call {
388+ _c.Call.Run(func(args mock.Arguments) {
389+ var arg0 context.Context
390+ if args[0] != nil {
391+ arg0 = args[0].(context.Context)
392+ }
393+ var arg1 *domain.Token
394+ if args[1] != nil {
395+ arg1 = args[1].(*domain.Token)
396+ }
397+ var arg2 string
398+ if args[2] != nil {
399+ arg2 = args[2].(string)
400+ }
401+ run(
402+ arg0,
403+ arg1,
404+ arg2,
405+ )
406+ })
407+ return _c
408+}
409+
410+func (_c *MockTokenStore_SaveToken_Call) Return(err error) *MockTokenStore_SaveToken_Call {
411+ _c.Call.Return(err)
412+ return _c
413+}
414+
415+func (_c *MockTokenStore_SaveToken_Call) RunAndReturn(run func(ctx context.Context, token *domain.Token, jwt string) error) *MockTokenStore_SaveToken_Call {
416+ _c.Call.Return(run)
417+ return _c
418+}
A internal/boundaries/out/token_store.go +29 -0
@@ -0,0 +1,29 @@
1+package out
2+
3+import (
4+ "context"
5+
6+ "gordon/internal/domain"
7+)
8+
9+// TokenStore defines the contract for storing and managing authentication tokens.
10+// Implementations may use different backends (pass, sops, unsafe file storage).
11+type TokenStore interface {
12+ // SaveToken stores a token JWT and metadata.
13+ SaveToken(ctx context.Context, token *domain.Token, jwt string) error
14+
15+ // GetToken retrieves token JWT by subject.
16+ GetToken(ctx context.Context, subject string) (string, *domain.Token, error)
17+
18+ // ListTokens returns all stored tokens.
19+ ListTokens(ctx context.Context) ([]domain.Token, error)
20+
21+ // Revoke adds token ID to revocation list.
22+ Revoke(ctx context.Context, tokenID string) error
23+
24+ // IsRevoked checks if token ID is in revocation list.
25+ IsRevoked(ctx context.Context, tokenID string) (bool, error)
26+
27+ // DeleteToken removes token from store.
28+ DeleteToken(ctx context.Context, subject string) error
29+}
@@ -0,0 +1,29 @@
1+package out
2+
3+import (
4+ "context"
5+
6+ "gordon/internal/domain"
7+)
8+
9+// TokenStore defines the contract for storing and managing authentication tokens.
10+// Implementations may use different backends (pass, sops, unsafe file storage).
11+type TokenStore interface {
12+ // SaveToken stores a token JWT and metadata.
13+ SaveToken(ctx context.Context, token *domain.Token, jwt string) error
14+
15+ // GetToken retrieves token JWT by subject.
16+ GetToken(ctx context.Context, subject string) (string, *domain.Token, error)
17+
18+ // ListTokens returns all stored tokens.
19+ ListTokens(ctx context.Context) ([]domain.Token, error)
20+
21+ // Revoke adds token ID to revocation list.
22+ Revoke(ctx context.Context, tokenID string) error
23+
24+ // IsRevoked checks if token ID is in revocation list.
25+ IsRevoked(ctx context.Context, tokenID string) (bool, error)
26+
27+ // DeleteToken removes token from store.
28+ DeleteToken(ctx context.Context, subject string) error
29+}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close