This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
o_auth2_provider.go
462 lines (367 loc) · 16.1 KB
/
o_auth2_provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
// Code generated by mockery v1.0.1. DO NOT EDIT.
package mocks
import (
context "context"
fosite "github.com/ory/fosite"
http "net/http"
interfaces "github.com/flyteorg/flyteadmin/auth/interfaces"
jwk "github.com/lestrrat-go/jwx/jwk"
mock "github.com/stretchr/testify/mock"
oauth2 "github.com/ory/fosite/handler/oauth2"
service "github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/service"
)
// OAuth2Provider is an autogenerated mock type for the OAuth2Provider type
type OAuth2Provider struct {
mock.Mock
}
type OAuth2Provider_IntrospectToken struct {
*mock.Call
}
func (_m OAuth2Provider_IntrospectToken) Return(_a0 fosite.TokenType, _a1 fosite.AccessRequester, _a2 error) *OAuth2Provider_IntrospectToken {
return &OAuth2Provider_IntrospectToken{Call: _m.Call.Return(_a0, _a1, _a2)}
}
func (_m *OAuth2Provider) OnIntrospectToken(ctx context.Context, token string, tokenUse fosite.TokenType, session fosite.Session, scope ...string) *OAuth2Provider_IntrospectToken {
c_call := _m.On("IntrospectToken", ctx, token, tokenUse, session, scope)
return &OAuth2Provider_IntrospectToken{Call: c_call}
}
func (_m *OAuth2Provider) OnIntrospectTokenMatch(matchers ...interface{}) *OAuth2Provider_IntrospectToken {
c_call := _m.On("IntrospectToken", matchers...)
return &OAuth2Provider_IntrospectToken{Call: c_call}
}
// IntrospectToken provides a mock function with given fields: ctx, token, tokenUse, session, scope
func (_m *OAuth2Provider) IntrospectToken(ctx context.Context, token string, tokenUse fosite.TokenType, session fosite.Session, scope ...string) (fosite.TokenType, fosite.AccessRequester, error) {
_va := make([]interface{}, len(scope))
for _i := range scope {
_va[_i] = scope[_i]
}
var _ca []interface{}
_ca = append(_ca, ctx, token, tokenUse, session)
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)
var r0 fosite.TokenType
if rf, ok := ret.Get(0).(func(context.Context, string, fosite.TokenType, fosite.Session, ...string) fosite.TokenType); ok {
r0 = rf(ctx, token, tokenUse, session, scope...)
} else {
r0 = ret.Get(0).(fosite.TokenType)
}
var r1 fosite.AccessRequester
if rf, ok := ret.Get(1).(func(context.Context, string, fosite.TokenType, fosite.Session, ...string) fosite.AccessRequester); ok {
r1 = rf(ctx, token, tokenUse, session, scope...)
} else {
if ret.Get(1) != nil {
r1 = ret.Get(1).(fosite.AccessRequester)
}
}
var r2 error
if rf, ok := ret.Get(2).(func(context.Context, string, fosite.TokenType, fosite.Session, ...string) error); ok {
r2 = rf(ctx, token, tokenUse, session, scope...)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
type OAuth2Provider_KeySet struct {
*mock.Call
}
func (_m OAuth2Provider_KeySet) Return(_a0 jwk.Set) *OAuth2Provider_KeySet {
return &OAuth2Provider_KeySet{Call: _m.Call.Return(_a0)}
}
func (_m *OAuth2Provider) OnKeySet() *OAuth2Provider_KeySet {
c_call := _m.On("KeySet")
return &OAuth2Provider_KeySet{Call: c_call}
}
func (_m *OAuth2Provider) OnKeySetMatch(matchers ...interface{}) *OAuth2Provider_KeySet {
c_call := _m.On("KeySet", matchers...)
return &OAuth2Provider_KeySet{Call: c_call}
}
// KeySet provides a mock function with given fields:
func (_m *OAuth2Provider) KeySet() jwk.Set {
ret := _m.Called()
var r0 jwk.Set
if rf, ok := ret.Get(0).(func() jwk.Set); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(jwk.Set)
}
}
return r0
}
type OAuth2Provider_NewAccessRequest struct {
*mock.Call
}
func (_m OAuth2Provider_NewAccessRequest) Return(_a0 fosite.AccessRequester, _a1 error) *OAuth2Provider_NewAccessRequest {
return &OAuth2Provider_NewAccessRequest{Call: _m.Call.Return(_a0, _a1)}
}
func (_m *OAuth2Provider) OnNewAccessRequest(ctx context.Context, req *http.Request, session fosite.Session) *OAuth2Provider_NewAccessRequest {
c_call := _m.On("NewAccessRequest", ctx, req, session)
return &OAuth2Provider_NewAccessRequest{Call: c_call}
}
func (_m *OAuth2Provider) OnNewAccessRequestMatch(matchers ...interface{}) *OAuth2Provider_NewAccessRequest {
c_call := _m.On("NewAccessRequest", matchers...)
return &OAuth2Provider_NewAccessRequest{Call: c_call}
}
// NewAccessRequest provides a mock function with given fields: ctx, req, session
func (_m *OAuth2Provider) NewAccessRequest(ctx context.Context, req *http.Request, session fosite.Session) (fosite.AccessRequester, error) {
ret := _m.Called(ctx, req, session)
var r0 fosite.AccessRequester
if rf, ok := ret.Get(0).(func(context.Context, *http.Request, fosite.Session) fosite.AccessRequester); ok {
r0 = rf(ctx, req, session)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(fosite.AccessRequester)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, *http.Request, fosite.Session) error); ok {
r1 = rf(ctx, req, session)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
type OAuth2Provider_NewAccessResponse struct {
*mock.Call
}
func (_m OAuth2Provider_NewAccessResponse) Return(_a0 fosite.AccessResponder, _a1 error) *OAuth2Provider_NewAccessResponse {
return &OAuth2Provider_NewAccessResponse{Call: _m.Call.Return(_a0, _a1)}
}
func (_m *OAuth2Provider) OnNewAccessResponse(ctx context.Context, requester fosite.AccessRequester) *OAuth2Provider_NewAccessResponse {
c_call := _m.On("NewAccessResponse", ctx, requester)
return &OAuth2Provider_NewAccessResponse{Call: c_call}
}
func (_m *OAuth2Provider) OnNewAccessResponseMatch(matchers ...interface{}) *OAuth2Provider_NewAccessResponse {
c_call := _m.On("NewAccessResponse", matchers...)
return &OAuth2Provider_NewAccessResponse{Call: c_call}
}
// NewAccessResponse provides a mock function with given fields: ctx, requester
func (_m *OAuth2Provider) NewAccessResponse(ctx context.Context, requester fosite.AccessRequester) (fosite.AccessResponder, error) {
ret := _m.Called(ctx, requester)
var r0 fosite.AccessResponder
if rf, ok := ret.Get(0).(func(context.Context, fosite.AccessRequester) fosite.AccessResponder); ok {
r0 = rf(ctx, requester)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(fosite.AccessResponder)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, fosite.AccessRequester) error); ok {
r1 = rf(ctx, requester)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
type OAuth2Provider_NewAuthorizeRequest struct {
*mock.Call
}
func (_m OAuth2Provider_NewAuthorizeRequest) Return(_a0 fosite.AuthorizeRequester, _a1 error) *OAuth2Provider_NewAuthorizeRequest {
return &OAuth2Provider_NewAuthorizeRequest{Call: _m.Call.Return(_a0, _a1)}
}
func (_m *OAuth2Provider) OnNewAuthorizeRequest(ctx context.Context, req *http.Request) *OAuth2Provider_NewAuthorizeRequest {
c_call := _m.On("NewAuthorizeRequest", ctx, req)
return &OAuth2Provider_NewAuthorizeRequest{Call: c_call}
}
func (_m *OAuth2Provider) OnNewAuthorizeRequestMatch(matchers ...interface{}) *OAuth2Provider_NewAuthorizeRequest {
c_call := _m.On("NewAuthorizeRequest", matchers...)
return &OAuth2Provider_NewAuthorizeRequest{Call: c_call}
}
// NewAuthorizeRequest provides a mock function with given fields: ctx, req
func (_m *OAuth2Provider) NewAuthorizeRequest(ctx context.Context, req *http.Request) (fosite.AuthorizeRequester, error) {
ret := _m.Called(ctx, req)
var r0 fosite.AuthorizeRequester
if rf, ok := ret.Get(0).(func(context.Context, *http.Request) fosite.AuthorizeRequester); ok {
r0 = rf(ctx, req)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(fosite.AuthorizeRequester)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, *http.Request) error); ok {
r1 = rf(ctx, req)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
type OAuth2Provider_NewAuthorizeResponse struct {
*mock.Call
}
func (_m OAuth2Provider_NewAuthorizeResponse) Return(_a0 fosite.AuthorizeResponder, _a1 error) *OAuth2Provider_NewAuthorizeResponse {
return &OAuth2Provider_NewAuthorizeResponse{Call: _m.Call.Return(_a0, _a1)}
}
func (_m *OAuth2Provider) OnNewAuthorizeResponse(ctx context.Context, requester fosite.AuthorizeRequester, session fosite.Session) *OAuth2Provider_NewAuthorizeResponse {
c_call := _m.On("NewAuthorizeResponse", ctx, requester, session)
return &OAuth2Provider_NewAuthorizeResponse{Call: c_call}
}
func (_m *OAuth2Provider) OnNewAuthorizeResponseMatch(matchers ...interface{}) *OAuth2Provider_NewAuthorizeResponse {
c_call := _m.On("NewAuthorizeResponse", matchers...)
return &OAuth2Provider_NewAuthorizeResponse{Call: c_call}
}
// NewAuthorizeResponse provides a mock function with given fields: ctx, requester, session
func (_m *OAuth2Provider) NewAuthorizeResponse(ctx context.Context, requester fosite.AuthorizeRequester, session fosite.Session) (fosite.AuthorizeResponder, error) {
ret := _m.Called(ctx, requester, session)
var r0 fosite.AuthorizeResponder
if rf, ok := ret.Get(0).(func(context.Context, fosite.AuthorizeRequester, fosite.Session) fosite.AuthorizeResponder); ok {
r0 = rf(ctx, requester, session)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(fosite.AuthorizeResponder)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, fosite.AuthorizeRequester, fosite.Session) error); ok {
r1 = rf(ctx, requester, session)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
type OAuth2Provider_NewIntrospectionRequest struct {
*mock.Call
}
func (_m OAuth2Provider_NewIntrospectionRequest) Return(_a0 fosite.IntrospectionResponder, _a1 error) *OAuth2Provider_NewIntrospectionRequest {
return &OAuth2Provider_NewIntrospectionRequest{Call: _m.Call.Return(_a0, _a1)}
}
func (_m *OAuth2Provider) OnNewIntrospectionRequest(ctx context.Context, r *http.Request, session fosite.Session) *OAuth2Provider_NewIntrospectionRequest {
c_call := _m.On("NewIntrospectionRequest", ctx, r, session)
return &OAuth2Provider_NewIntrospectionRequest{Call: c_call}
}
func (_m *OAuth2Provider) OnNewIntrospectionRequestMatch(matchers ...interface{}) *OAuth2Provider_NewIntrospectionRequest {
c_call := _m.On("NewIntrospectionRequest", matchers...)
return &OAuth2Provider_NewIntrospectionRequest{Call: c_call}
}
// NewIntrospectionRequest provides a mock function with given fields: ctx, r, session
func (_m *OAuth2Provider) NewIntrospectionRequest(ctx context.Context, r *http.Request, session fosite.Session) (fosite.IntrospectionResponder, error) {
ret := _m.Called(ctx, r, session)
var r0 fosite.IntrospectionResponder
if rf, ok := ret.Get(0).(func(context.Context, *http.Request, fosite.Session) fosite.IntrospectionResponder); ok {
r0 = rf(ctx, r, session)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(fosite.IntrospectionResponder)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, *http.Request, fosite.Session) error); ok {
r1 = rf(ctx, r, session)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
type OAuth2Provider_NewJWTSessionToken struct {
*mock.Call
}
func (_m OAuth2Provider_NewJWTSessionToken) Return(_a0 *oauth2.JWTSession) *OAuth2Provider_NewJWTSessionToken {
return &OAuth2Provider_NewJWTSessionToken{Call: _m.Call.Return(_a0)}
}
func (_m *OAuth2Provider) OnNewJWTSessionToken(subject string, appID string, issuer string, audience string, userInfoClaims *service.UserInfoResponse) *OAuth2Provider_NewJWTSessionToken {
c_call := _m.On("NewJWTSessionToken", subject, appID, issuer, audience, userInfoClaims)
return &OAuth2Provider_NewJWTSessionToken{Call: c_call}
}
func (_m *OAuth2Provider) OnNewJWTSessionTokenMatch(matchers ...interface{}) *OAuth2Provider_NewJWTSessionToken {
c_call := _m.On("NewJWTSessionToken", matchers...)
return &OAuth2Provider_NewJWTSessionToken{Call: c_call}
}
// NewJWTSessionToken provides a mock function with given fields: subject, appID, issuer, audience, userInfoClaims
func (_m *OAuth2Provider) NewJWTSessionToken(subject string, appID string, issuer string, audience string, userInfoClaims *service.UserInfoResponse) *oauth2.JWTSession {
ret := _m.Called(subject, appID, issuer, audience, userInfoClaims)
var r0 *oauth2.JWTSession
if rf, ok := ret.Get(0).(func(string, string, string, string, *service.UserInfoResponse) *oauth2.JWTSession); ok {
r0 = rf(subject, appID, issuer, audience, userInfoClaims)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*oauth2.JWTSession)
}
}
return r0
}
type OAuth2Provider_NewRevocationRequest struct {
*mock.Call
}
func (_m OAuth2Provider_NewRevocationRequest) Return(_a0 error) *OAuth2Provider_NewRevocationRequest {
return &OAuth2Provider_NewRevocationRequest{Call: _m.Call.Return(_a0)}
}
func (_m *OAuth2Provider) OnNewRevocationRequest(ctx context.Context, r *http.Request) *OAuth2Provider_NewRevocationRequest {
c_call := _m.On("NewRevocationRequest", ctx, r)
return &OAuth2Provider_NewRevocationRequest{Call: c_call}
}
func (_m *OAuth2Provider) OnNewRevocationRequestMatch(matchers ...interface{}) *OAuth2Provider_NewRevocationRequest {
c_call := _m.On("NewRevocationRequest", matchers...)
return &OAuth2Provider_NewRevocationRequest{Call: c_call}
}
// NewRevocationRequest provides a mock function with given fields: ctx, r
func (_m *OAuth2Provider) NewRevocationRequest(ctx context.Context, r *http.Request) error {
ret := _m.Called(ctx, r)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *http.Request) error); ok {
r0 = rf(ctx, r)
} else {
r0 = ret.Error(0)
}
return r0
}
type OAuth2Provider_ValidateAccessToken struct {
*mock.Call
}
func (_m OAuth2Provider_ValidateAccessToken) Return(_a0 interfaces.IdentityContext, _a1 error) *OAuth2Provider_ValidateAccessToken {
return &OAuth2Provider_ValidateAccessToken{Call: _m.Call.Return(_a0, _a1)}
}
func (_m *OAuth2Provider) OnValidateAccessToken(ctx context.Context, expectedAudience string, tokenStr string) *OAuth2Provider_ValidateAccessToken {
c_call := _m.On("ValidateAccessToken", ctx, expectedAudience, tokenStr)
return &OAuth2Provider_ValidateAccessToken{Call: c_call}
}
func (_m *OAuth2Provider) OnValidateAccessTokenMatch(matchers ...interface{}) *OAuth2Provider_ValidateAccessToken {
c_call := _m.On("ValidateAccessToken", matchers...)
return &OAuth2Provider_ValidateAccessToken{Call: c_call}
}
// ValidateAccessToken provides a mock function with given fields: ctx, expectedAudience, tokenStr
func (_m *OAuth2Provider) ValidateAccessToken(ctx context.Context, expectedAudience string, tokenStr string) (interfaces.IdentityContext, error) {
ret := _m.Called(ctx, expectedAudience, tokenStr)
var r0 interfaces.IdentityContext
if rf, ok := ret.Get(0).(func(context.Context, string, string) interfaces.IdentityContext); ok {
r0 = rf(ctx, expectedAudience, tokenStr)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(interfaces.IdentityContext)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
r1 = rf(ctx, expectedAudience, tokenStr)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// WriteAccessError provides a mock function with given fields: rw, requester, err
func (_m *OAuth2Provider) WriteAccessError(rw http.ResponseWriter, requester fosite.AccessRequester, err error) {
_m.Called(rw, requester, err)
}
// WriteAccessResponse provides a mock function with given fields: rw, requester, responder
func (_m *OAuth2Provider) WriteAccessResponse(rw http.ResponseWriter, requester fosite.AccessRequester, responder fosite.AccessResponder) {
_m.Called(rw, requester, responder)
}
// WriteAuthorizeError provides a mock function with given fields: rw, requester, err
func (_m *OAuth2Provider) WriteAuthorizeError(rw http.ResponseWriter, requester fosite.AuthorizeRequester, err error) {
_m.Called(rw, requester, err)
}
// WriteAuthorizeResponse provides a mock function with given fields: rw, requester, responder
func (_m *OAuth2Provider) WriteAuthorizeResponse(rw http.ResponseWriter, requester fosite.AuthorizeRequester, responder fosite.AuthorizeResponder) {
_m.Called(rw, requester, responder)
}
// WriteIntrospectionError provides a mock function with given fields: rw, err
func (_m *OAuth2Provider) WriteIntrospectionError(rw http.ResponseWriter, err error) {
_m.Called(rw, err)
}
// WriteIntrospectionResponse provides a mock function with given fields: rw, r
func (_m *OAuth2Provider) WriteIntrospectionResponse(rw http.ResponseWriter, r fosite.IntrospectionResponder) {
_m.Called(rw, r)
}
// WriteRevocationResponse provides a mock function with given fields: rw, err
func (_m *OAuth2Provider) WriteRevocationResponse(rw http.ResponseWriter, err error) {
_m.Called(rw, err)
}