-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock.go
968 lines (810 loc) · 37.8 KB
/
mock.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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
// generated by "charlatan -output=./mock/mock.go -package=validatorMock Validator". DO NOT EDIT.
package validatorMock
import "reflect"
import "crypto/rsa"
import (
"github.com/24COMS/go.openid/validator"
"github.com/SermoDigital/jose/jwt"
)
// ValidatorUpdateKeysInvocation represents a single call of FakeValidator.UpdateKeys
type ValidatorUpdateKeysInvocation struct {
Results struct {
Ident1 error
}
}
// ValidatorGetRSAPubKeysInvocation represents a single call of FakeValidator.GetRSAPubKeys
type ValidatorGetRSAPubKeysInvocation struct {
Results struct {
Ident1 []*rsa.PublicKey
}
}
// ValidatorValidateApplicationTokenInvocation represents a single call of FakeValidator.ValidateApplicationToken
type ValidatorValidateApplicationTokenInvocation struct {
Parameters struct {
AccessToken string
RequiredScopes []string
}
Results struct {
Ident1 bool
Ident2 error
}
}
// NewValidatorValidateApplicationTokenInvocation creates a new instance of ValidatorValidateApplicationTokenInvocation
func NewValidatorValidateApplicationTokenInvocation(accessToken string, requiredScopes []string, ident1 bool, ident2 error) *ValidatorValidateApplicationTokenInvocation {
invocation := new(ValidatorValidateApplicationTokenInvocation)
invocation.Parameters.AccessToken = accessToken
invocation.Parameters.RequiredScopes = requiredScopes
invocation.Results.Ident1 = ident1
invocation.Results.Ident2 = ident2
return invocation
}
// ValidatorGetAndValidateTokenInvocation represents a single call of FakeValidator.GetAndValidateToken
type ValidatorGetAndValidateTokenInvocation struct {
Parameters struct {
AccessToken string
RequiredScopes []string
}
Results struct {
Ident1 jwt.JWT
Ident2 error
}
}
// NewValidatorGetAndValidateTokenInvocation creates a new instance of ValidatorGetAndValidateTokenInvocation
func NewValidatorGetAndValidateTokenInvocation(accessToken string, requiredScopes []string, ident1 jwt.JWT, ident2 error) *ValidatorGetAndValidateTokenInvocation {
invocation := new(ValidatorGetAndValidateTokenInvocation)
invocation.Parameters.AccessToken = accessToken
invocation.Parameters.RequiredScopes = requiredScopes
invocation.Results.Ident1 = ident1
invocation.Results.Ident2 = ident2
return invocation
}
// ValidatorValidateUserTokenInvocation represents a single call of FakeValidator.ValidateUserToken
type ValidatorValidateUserTokenInvocation struct {
Parameters struct {
AccessToken string
RequiredScopes []string
}
Results struct {
Ident1 uint64
Ident2 uint64
Ident3 bool
Ident4 error
}
}
// NewValidatorValidateUserTokenInvocation creates a new instance of ValidatorValidateUserTokenInvocation
func NewValidatorValidateUserTokenInvocation(accessToken string, requiredScopes []string, ident1 uint64, ident2 uint64, ident3 bool, ident4 error) *ValidatorValidateUserTokenInvocation {
invocation := new(ValidatorValidateUserTokenInvocation)
invocation.Parameters.AccessToken = accessToken
invocation.Parameters.RequiredScopes = requiredScopes
invocation.Results.Ident1 = ident1
invocation.Results.Ident2 = ident2
invocation.Results.Ident3 = ident3
invocation.Results.Ident4 = ident4
return invocation
}
// ValidatorGetOpenIDConfigInvocation represents a single call of FakeValidator.GetOpenIDConfig
type ValidatorGetOpenIDConfigInvocation struct {
Results struct {
Ident1 access.OpenIDConfig
}
}
// ValidatorTestingT represents the methods of "testing".T used by charlatan Fakes. It avoids importing the testing package.
type ValidatorTestingT interface {
Error(...interface{})
Errorf(string, ...interface{})
Fatal(...interface{})
Helper()
}
/*
FakeValidator is a mock implementation of Validator for testing.
Use it in your tests as in this example:
package example
func TestWithValidator(t *testing.T) {
f := &validatorMock.FakeValidator{
UpdateKeysHook: func() (ident1 error) {
// ensure parameters meet expections, signal errors using t, etc
return
},
}
// test code goes here ...
// assert state of FakeUpdateKeys ...
f.AssertUpdateKeysCalledOnce(t)
}
Create anonymous function implementations for only those interface methods that
should be called in the code under test. This will force a panic if any
unexpected calls are made to FakeUpdateKeys.
*/
type FakeValidator struct {
UpdateKeysHook func() error
GetRSAPubKeysHook func() []*rsa.PublicKey
ValidateApplicationTokenHook func(string, ...string) (bool, error)
GetAndValidateTokenHook func(string, ...string) (jwt.JWT, error)
ValidateUserTokenHook func(string, ...string) (uint64, uint64, bool, error)
GetOpenIDConfigHook func() access.OpenIDConfig
UpdateKeysCalls []*ValidatorUpdateKeysInvocation
GetRSAPubKeysCalls []*ValidatorGetRSAPubKeysInvocation
ValidateApplicationTokenCalls []*ValidatorValidateApplicationTokenInvocation
GetAndValidateTokenCalls []*ValidatorGetAndValidateTokenInvocation
ValidateUserTokenCalls []*ValidatorValidateUserTokenInvocation
GetOpenIDConfigCalls []*ValidatorGetOpenIDConfigInvocation
}
// NewFakeValidatorDefaultPanic returns an instance of FakeValidator with all hooks configured to panic
func NewFakeValidatorDefaultPanic() *FakeValidator {
return &FakeValidator{
UpdateKeysHook: func() (ident1 error) {
panic("Unexpected call to Validator.UpdateKeys")
},
GetRSAPubKeysHook: func() (ident1 []*rsa.PublicKey) {
panic("Unexpected call to Validator.GetRSAPubKeys")
},
ValidateApplicationTokenHook: func(string, ...string) (ident1 bool, ident2 error) {
panic("Unexpected call to Validator.ValidateApplicationToken")
},
GetAndValidateTokenHook: func(string, ...string) (ident1 jwt.JWT, ident2 error) {
panic("Unexpected call to Validator.GetAndValidateToken")
},
ValidateUserTokenHook: func(string, ...string) (ident1 uint64, ident2 uint64, ident3 bool, ident4 error) {
panic("Unexpected call to Validator.ValidateUserToken")
},
GetOpenIDConfigHook: func() (ident1 access.OpenIDConfig) {
panic("Unexpected call to Validator.GetOpenIDConfig")
},
}
}
// NewFakeValidatorDefaultFatal returns an instance of FakeValidator with all hooks configured to call t.Fatal
func NewFakeValidatorDefaultFatal(t_sym1 ValidatorTestingT) *FakeValidator {
return &FakeValidator{
UpdateKeysHook: func() (ident1 error) {
t_sym1.Fatal("Unexpected call to Validator.UpdateKeys")
return
},
GetRSAPubKeysHook: func() (ident1 []*rsa.PublicKey) {
t_sym1.Fatal("Unexpected call to Validator.GetRSAPubKeys")
return
},
ValidateApplicationTokenHook: func(string, ...string) (ident1 bool, ident2 error) {
t_sym1.Fatal("Unexpected call to Validator.ValidateApplicationToken")
return
},
GetAndValidateTokenHook: func(string, ...string) (ident1 jwt.JWT, ident2 error) {
t_sym1.Fatal("Unexpected call to Validator.GetAndValidateToken")
return
},
ValidateUserTokenHook: func(string, ...string) (ident1 uint64, ident2 uint64, ident3 bool, ident4 error) {
t_sym1.Fatal("Unexpected call to Validator.ValidateUserToken")
return
},
GetOpenIDConfigHook: func() (ident1 access.OpenIDConfig) {
t_sym1.Fatal("Unexpected call to Validator.GetOpenIDConfig")
return
},
}
}
// NewFakeValidatorDefaultError returns an instance of FakeValidator with all hooks configured to call t.Error
func NewFakeValidatorDefaultError(t_sym2 ValidatorTestingT) *FakeValidator {
return &FakeValidator{
UpdateKeysHook: func() (ident1 error) {
t_sym2.Error("Unexpected call to Validator.UpdateKeys")
return
},
GetRSAPubKeysHook: func() (ident1 []*rsa.PublicKey) {
t_sym2.Error("Unexpected call to Validator.GetRSAPubKeys")
return
},
ValidateApplicationTokenHook: func(string, ...string) (ident1 bool, ident2 error) {
t_sym2.Error("Unexpected call to Validator.ValidateApplicationToken")
return
},
GetAndValidateTokenHook: func(string, ...string) (ident1 jwt.JWT, ident2 error) {
t_sym2.Error("Unexpected call to Validator.GetAndValidateToken")
return
},
ValidateUserTokenHook: func(string, ...string) (ident1 uint64, ident2 uint64, ident3 bool, ident4 error) {
t_sym2.Error("Unexpected call to Validator.ValidateUserToken")
return
},
GetOpenIDConfigHook: func() (ident1 access.OpenIDConfig) {
t_sym2.Error("Unexpected call to Validator.GetOpenIDConfig")
return
},
}
}
func (f *FakeValidator) Reset() {
f.UpdateKeysCalls = []*ValidatorUpdateKeysInvocation{}
f.GetRSAPubKeysCalls = []*ValidatorGetRSAPubKeysInvocation{}
f.ValidateApplicationTokenCalls = []*ValidatorValidateApplicationTokenInvocation{}
f.GetAndValidateTokenCalls = []*ValidatorGetAndValidateTokenInvocation{}
f.ValidateUserTokenCalls = []*ValidatorValidateUserTokenInvocation{}
f.GetOpenIDConfigCalls = []*ValidatorGetOpenIDConfigInvocation{}
}
func (f_sym3 *FakeValidator) UpdateKeys() (ident1 error) {
if f_sym3.UpdateKeysHook == nil {
panic("Validator.UpdateKeys() called but FakeValidator.UpdateKeysHook is nil")
}
invocation_sym3 := new(ValidatorUpdateKeysInvocation)
f_sym3.UpdateKeysCalls = append(f_sym3.UpdateKeysCalls, invocation_sym3)
ident1 = f_sym3.UpdateKeysHook()
invocation_sym3.Results.Ident1 = ident1
return
}
// SetUpdateKeysStub configures Validator.UpdateKeys to always return the given values
func (f_sym4 *FakeValidator) SetUpdateKeysStub(ident1 error) {
f_sym4.UpdateKeysHook = func() error {
return ident1
}
}
// UpdateKeysCalled returns true if FakeValidator.UpdateKeys was called
func (f *FakeValidator) UpdateKeysCalled() bool {
return len(f.UpdateKeysCalls) != 0
}
// AssertUpdateKeysCalled calls t.Error if FakeValidator.UpdateKeys was not called
func (f *FakeValidator) AssertUpdateKeysCalled(t ValidatorTestingT) {
t.Helper()
if len(f.UpdateKeysCalls) == 0 {
t.Error("FakeValidator.UpdateKeys not called, expected at least one")
}
}
// UpdateKeysNotCalled returns true if FakeValidator.UpdateKeys was not called
func (f *FakeValidator) UpdateKeysNotCalled() bool {
return len(f.UpdateKeysCalls) == 0
}
// AssertUpdateKeysNotCalled calls t.Error if FakeValidator.UpdateKeys was called
func (f *FakeValidator) AssertUpdateKeysNotCalled(t ValidatorTestingT) {
t.Helper()
if len(f.UpdateKeysCalls) != 0 {
t.Error("FakeValidator.UpdateKeys called, expected none")
}
}
// UpdateKeysCalledOnce returns true if FakeValidator.UpdateKeys was called exactly once
func (f *FakeValidator) UpdateKeysCalledOnce() bool {
return len(f.UpdateKeysCalls) == 1
}
// AssertUpdateKeysCalledOnce calls t.Error if FakeValidator.UpdateKeys was not called exactly once
func (f *FakeValidator) AssertUpdateKeysCalledOnce(t ValidatorTestingT) {
t.Helper()
if len(f.UpdateKeysCalls) != 1 {
t.Errorf("FakeValidator.UpdateKeys called %d times, expected 1", len(f.UpdateKeysCalls))
}
}
// UpdateKeysCalledN returns true if FakeValidator.UpdateKeys was called at least n times
func (f *FakeValidator) UpdateKeysCalledN(n int) bool {
return len(f.UpdateKeysCalls) >= n
}
// AssertUpdateKeysCalledN calls t.Error if FakeValidator.UpdateKeys was called less than n times
func (f *FakeValidator) AssertUpdateKeysCalledN(t ValidatorTestingT, n int) {
t.Helper()
if len(f.UpdateKeysCalls) < n {
t.Errorf("FakeValidator.UpdateKeys called %d times, expected >= %d", len(f.UpdateKeysCalls), n)
}
}
func (f_sym5 *FakeValidator) GetRSAPubKeys() (ident1 []*rsa.PublicKey) {
if f_sym5.GetRSAPubKeysHook == nil {
panic("Validator.GetRSAPubKeys() called but FakeValidator.GetRSAPubKeysHook is nil")
}
invocation_sym5 := new(ValidatorGetRSAPubKeysInvocation)
f_sym5.GetRSAPubKeysCalls = append(f_sym5.GetRSAPubKeysCalls, invocation_sym5)
ident1 = f_sym5.GetRSAPubKeysHook()
invocation_sym5.Results.Ident1 = ident1
return
}
// SetGetRSAPubKeysStub configures Validator.GetRSAPubKeys to always return the given values
func (f_sym6 *FakeValidator) SetGetRSAPubKeysStub(ident1 []*rsa.PublicKey) {
f_sym6.GetRSAPubKeysHook = func() []*rsa.PublicKey {
return ident1
}
}
// GetRSAPubKeysCalled returns true if FakeValidator.GetRSAPubKeys was called
func (f *FakeValidator) GetRSAPubKeysCalled() bool {
return len(f.GetRSAPubKeysCalls) != 0
}
// AssertGetRSAPubKeysCalled calls t.Error if FakeValidator.GetRSAPubKeys was not called
func (f *FakeValidator) AssertGetRSAPubKeysCalled(t ValidatorTestingT) {
t.Helper()
if len(f.GetRSAPubKeysCalls) == 0 {
t.Error("FakeValidator.GetRSAPubKeys not called, expected at least one")
}
}
// GetRSAPubKeysNotCalled returns true if FakeValidator.GetRSAPubKeys was not called
func (f *FakeValidator) GetRSAPubKeysNotCalled() bool {
return len(f.GetRSAPubKeysCalls) == 0
}
// AssertGetRSAPubKeysNotCalled calls t.Error if FakeValidator.GetRSAPubKeys was called
func (f *FakeValidator) AssertGetRSAPubKeysNotCalled(t ValidatorTestingT) {
t.Helper()
if len(f.GetRSAPubKeysCalls) != 0 {
t.Error("FakeValidator.GetRSAPubKeys called, expected none")
}
}
// GetRSAPubKeysCalledOnce returns true if FakeValidator.GetRSAPubKeys was called exactly once
func (f *FakeValidator) GetRSAPubKeysCalledOnce() bool {
return len(f.GetRSAPubKeysCalls) == 1
}
// AssertGetRSAPubKeysCalledOnce calls t.Error if FakeValidator.GetRSAPubKeys was not called exactly once
func (f *FakeValidator) AssertGetRSAPubKeysCalledOnce(t ValidatorTestingT) {
t.Helper()
if len(f.GetRSAPubKeysCalls) != 1 {
t.Errorf("FakeValidator.GetRSAPubKeys called %d times, expected 1", len(f.GetRSAPubKeysCalls))
}
}
// GetRSAPubKeysCalledN returns true if FakeValidator.GetRSAPubKeys was called at least n times
func (f *FakeValidator) GetRSAPubKeysCalledN(n int) bool {
return len(f.GetRSAPubKeysCalls) >= n
}
// AssertGetRSAPubKeysCalledN calls t.Error if FakeValidator.GetRSAPubKeys was called less than n times
func (f *FakeValidator) AssertGetRSAPubKeysCalledN(t ValidatorTestingT, n int) {
t.Helper()
if len(f.GetRSAPubKeysCalls) < n {
t.Errorf("FakeValidator.GetRSAPubKeys called %d times, expected >= %d", len(f.GetRSAPubKeysCalls), n)
}
}
func (f_sym7 *FakeValidator) ValidateApplicationToken(accessToken string, requiredScopes ...string) (ident1 bool, ident2 error) {
if f_sym7.ValidateApplicationTokenHook == nil {
panic("Validator.ValidateApplicationToken() called but FakeValidator.ValidateApplicationTokenHook is nil")
}
invocation_sym7 := new(ValidatorValidateApplicationTokenInvocation)
f_sym7.ValidateApplicationTokenCalls = append(f_sym7.ValidateApplicationTokenCalls, invocation_sym7)
invocation_sym7.Parameters.AccessToken = accessToken
invocation_sym7.Parameters.RequiredScopes = requiredScopes
ident1, ident2 = f_sym7.ValidateApplicationTokenHook(accessToken, requiredScopes...)
invocation_sym7.Results.Ident1 = ident1
invocation_sym7.Results.Ident2 = ident2
return
}
// SetValidateApplicationTokenStub configures Validator.ValidateApplicationToken to always return the given values
func (f_sym8 *FakeValidator) SetValidateApplicationTokenStub(ident1 bool, ident2 error) {
f_sym8.ValidateApplicationTokenHook = func(string, ...string) (bool, error) {
return ident1, ident2
}
}
// SetValidateApplicationTokenInvocation configures Validator.ValidateApplicationToken to return the given results when called with the given parameters
// If no match is found for an invocation the result(s) of the fallback function are returned
func (f_sym9 *FakeValidator) SetValidateApplicationTokenInvocation(calls_sym9 []*ValidatorValidateApplicationTokenInvocation, fallback_sym9 func() (bool, error)) {
f_sym9.ValidateApplicationTokenHook = func(accessToken string, requiredScopes ...string) (ident1 bool, ident2 error) {
for _, call_sym9 := range calls_sym9 {
if reflect.DeepEqual(call_sym9.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym9.Parameters.RequiredScopes, requiredScopes) {
ident1 = call_sym9.Results.Ident1
ident2 = call_sym9.Results.Ident2
return
}
}
return fallback_sym9()
}
}
// ValidateApplicationTokenCalled returns true if FakeValidator.ValidateApplicationToken was called
func (f *FakeValidator) ValidateApplicationTokenCalled() bool {
return len(f.ValidateApplicationTokenCalls) != 0
}
// AssertValidateApplicationTokenCalled calls t.Error if FakeValidator.ValidateApplicationToken was not called
func (f *FakeValidator) AssertValidateApplicationTokenCalled(t ValidatorTestingT) {
t.Helper()
if len(f.ValidateApplicationTokenCalls) == 0 {
t.Error("FakeValidator.ValidateApplicationToken not called, expected at least one")
}
}
// ValidateApplicationTokenNotCalled returns true if FakeValidator.ValidateApplicationToken was not called
func (f *FakeValidator) ValidateApplicationTokenNotCalled() bool {
return len(f.ValidateApplicationTokenCalls) == 0
}
// AssertValidateApplicationTokenNotCalled calls t.Error if FakeValidator.ValidateApplicationToken was called
func (f *FakeValidator) AssertValidateApplicationTokenNotCalled(t ValidatorTestingT) {
t.Helper()
if len(f.ValidateApplicationTokenCalls) != 0 {
t.Error("FakeValidator.ValidateApplicationToken called, expected none")
}
}
// ValidateApplicationTokenCalledOnce returns true if FakeValidator.ValidateApplicationToken was called exactly once
func (f *FakeValidator) ValidateApplicationTokenCalledOnce() bool {
return len(f.ValidateApplicationTokenCalls) == 1
}
// AssertValidateApplicationTokenCalledOnce calls t.Error if FakeValidator.ValidateApplicationToken was not called exactly once
func (f *FakeValidator) AssertValidateApplicationTokenCalledOnce(t ValidatorTestingT) {
t.Helper()
if len(f.ValidateApplicationTokenCalls) != 1 {
t.Errorf("FakeValidator.ValidateApplicationToken called %d times, expected 1", len(f.ValidateApplicationTokenCalls))
}
}
// ValidateApplicationTokenCalledN returns true if FakeValidator.ValidateApplicationToken was called at least n times
func (f *FakeValidator) ValidateApplicationTokenCalledN(n int) bool {
return len(f.ValidateApplicationTokenCalls) >= n
}
// AssertValidateApplicationTokenCalledN calls t.Error if FakeValidator.ValidateApplicationToken was called less than n times
func (f *FakeValidator) AssertValidateApplicationTokenCalledN(t ValidatorTestingT, n int) {
t.Helper()
if len(f.ValidateApplicationTokenCalls) < n {
t.Errorf("FakeValidator.ValidateApplicationToken called %d times, expected >= %d", len(f.ValidateApplicationTokenCalls), n)
}
}
// ValidateApplicationTokenCalledWith returns true if FakeValidator.ValidateApplicationToken was called with the given values
func (f_sym10 *FakeValidator) ValidateApplicationTokenCalledWith(accessToken string, requiredScopes ...string) bool {
for _, call_sym10 := range f_sym10.ValidateApplicationTokenCalls {
if reflect.DeepEqual(call_sym10.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym10.Parameters.RequiredScopes, requiredScopes) {
return true
}
}
return false
}
// AssertValidateApplicationTokenCalledWith calls t.Error if FakeValidator.ValidateApplicationToken was not called with the given values
func (f_sym11 *FakeValidator) AssertValidateApplicationTokenCalledWith(t ValidatorTestingT, accessToken string, requiredScopes ...string) {
t.Helper()
var found_sym11 bool
for _, call_sym11 := range f_sym11.ValidateApplicationTokenCalls {
if reflect.DeepEqual(call_sym11.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym11.Parameters.RequiredScopes, requiredScopes) {
found_sym11 = true
break
}
}
if !found_sym11 {
t.Error("FakeValidator.ValidateApplicationToken not called with expected parameters")
}
}
// ValidateApplicationTokenCalledOnceWith returns true if FakeValidator.ValidateApplicationToken was called exactly once with the given values
func (f_sym12 *FakeValidator) ValidateApplicationTokenCalledOnceWith(accessToken string, requiredScopes ...string) bool {
var count_sym12 int
for _, call_sym12 := range f_sym12.ValidateApplicationTokenCalls {
if reflect.DeepEqual(call_sym12.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym12.Parameters.RequiredScopes, requiredScopes) {
count_sym12++
}
}
return count_sym12 == 1
}
// AssertValidateApplicationTokenCalledOnceWith calls t.Error if FakeValidator.ValidateApplicationToken was not called exactly once with the given values
func (f_sym13 *FakeValidator) AssertValidateApplicationTokenCalledOnceWith(t ValidatorTestingT, accessToken string, requiredScopes ...string) {
t.Helper()
var count_sym13 int
for _, call_sym13 := range f_sym13.ValidateApplicationTokenCalls {
if reflect.DeepEqual(call_sym13.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym13.Parameters.RequiredScopes, requiredScopes) {
count_sym13++
}
}
if count_sym13 != 1 {
t.Errorf("FakeValidator.ValidateApplicationToken called %d times with expected parameters, expected one", count_sym13)
}
}
// ValidateApplicationTokenResultsForCall returns the result values for the first call to FakeValidator.ValidateApplicationToken with the given values
func (f_sym14 *FakeValidator) ValidateApplicationTokenResultsForCall(accessToken string, requiredScopes ...string) (ident1 bool, ident2 error, found_sym14 bool) {
for _, call_sym14 := range f_sym14.ValidateApplicationTokenCalls {
if reflect.DeepEqual(call_sym14.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym14.Parameters.RequiredScopes, requiredScopes) {
ident1 = call_sym14.Results.Ident1
ident2 = call_sym14.Results.Ident2
found_sym14 = true
break
}
}
return
}
func (f_sym15 *FakeValidator) GetAndValidateToken(accessToken string, requiredScopes ...string) (ident1 jwt.JWT, ident2 error) {
if f_sym15.GetAndValidateTokenHook == nil {
panic("Validator.GetAndValidateToken() called but FakeValidator.GetAndValidateTokenHook is nil")
}
invocation_sym15 := new(ValidatorGetAndValidateTokenInvocation)
f_sym15.GetAndValidateTokenCalls = append(f_sym15.GetAndValidateTokenCalls, invocation_sym15)
invocation_sym15.Parameters.AccessToken = accessToken
invocation_sym15.Parameters.RequiredScopes = requiredScopes
ident1, ident2 = f_sym15.GetAndValidateTokenHook(accessToken, requiredScopes...)
invocation_sym15.Results.Ident1 = ident1
invocation_sym15.Results.Ident2 = ident2
return
}
// SetGetAndValidateTokenStub configures Validator.GetAndValidateToken to always return the given values
func (f_sym16 *FakeValidator) SetGetAndValidateTokenStub(ident1 jwt.JWT, ident2 error) {
f_sym16.GetAndValidateTokenHook = func(string, ...string) (jwt.JWT, error) {
return ident1, ident2
}
}
// SetGetAndValidateTokenInvocation configures Validator.GetAndValidateToken to return the given results when called with the given parameters
// If no match is found for an invocation the result(s) of the fallback function are returned
func (f_sym17 *FakeValidator) SetGetAndValidateTokenInvocation(calls_sym17 []*ValidatorGetAndValidateTokenInvocation, fallback_sym17 func() (jwt.JWT, error)) {
f_sym17.GetAndValidateTokenHook = func(accessToken string, requiredScopes ...string) (ident1 jwt.JWT, ident2 error) {
for _, call_sym17 := range calls_sym17 {
if reflect.DeepEqual(call_sym17.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym17.Parameters.RequiredScopes, requiredScopes) {
ident1 = call_sym17.Results.Ident1
ident2 = call_sym17.Results.Ident2
return
}
}
return fallback_sym17()
}
}
// GetAndValidateTokenCalled returns true if FakeValidator.GetAndValidateToken was called
func (f *FakeValidator) GetAndValidateTokenCalled() bool {
return len(f.GetAndValidateTokenCalls) != 0
}
// AssertGetAndValidateTokenCalled calls t.Error if FakeValidator.GetAndValidateToken was not called
func (f *FakeValidator) AssertGetAndValidateTokenCalled(t ValidatorTestingT) {
t.Helper()
if len(f.GetAndValidateTokenCalls) == 0 {
t.Error("FakeValidator.GetAndValidateToken not called, expected at least one")
}
}
// GetAndValidateTokenNotCalled returns true if FakeValidator.GetAndValidateToken was not called
func (f *FakeValidator) GetAndValidateTokenNotCalled() bool {
return len(f.GetAndValidateTokenCalls) == 0
}
// AssertGetAndValidateTokenNotCalled calls t.Error if FakeValidator.GetAndValidateToken was called
func (f *FakeValidator) AssertGetAndValidateTokenNotCalled(t ValidatorTestingT) {
t.Helper()
if len(f.GetAndValidateTokenCalls) != 0 {
t.Error("FakeValidator.GetAndValidateToken called, expected none")
}
}
// GetAndValidateTokenCalledOnce returns true if FakeValidator.GetAndValidateToken was called exactly once
func (f *FakeValidator) GetAndValidateTokenCalledOnce() bool {
return len(f.GetAndValidateTokenCalls) == 1
}
// AssertGetAndValidateTokenCalledOnce calls t.Error if FakeValidator.GetAndValidateToken was not called exactly once
func (f *FakeValidator) AssertGetAndValidateTokenCalledOnce(t ValidatorTestingT) {
t.Helper()
if len(f.GetAndValidateTokenCalls) != 1 {
t.Errorf("FakeValidator.GetAndValidateToken called %d times, expected 1", len(f.GetAndValidateTokenCalls))
}
}
// GetAndValidateTokenCalledN returns true if FakeValidator.GetAndValidateToken was called at least n times
func (f *FakeValidator) GetAndValidateTokenCalledN(n int) bool {
return len(f.GetAndValidateTokenCalls) >= n
}
// AssertGetAndValidateTokenCalledN calls t.Error if FakeValidator.GetAndValidateToken was called less than n times
func (f *FakeValidator) AssertGetAndValidateTokenCalledN(t ValidatorTestingT, n int) {
t.Helper()
if len(f.GetAndValidateTokenCalls) < n {
t.Errorf("FakeValidator.GetAndValidateToken called %d times, expected >= %d", len(f.GetAndValidateTokenCalls), n)
}
}
// GetAndValidateTokenCalledWith returns true if FakeValidator.GetAndValidateToken was called with the given values
func (f_sym18 *FakeValidator) GetAndValidateTokenCalledWith(accessToken string, requiredScopes ...string) bool {
for _, call_sym18 := range f_sym18.GetAndValidateTokenCalls {
if reflect.DeepEqual(call_sym18.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym18.Parameters.RequiredScopes, requiredScopes) {
return true
}
}
return false
}
// AssertGetAndValidateTokenCalledWith calls t.Error if FakeValidator.GetAndValidateToken was not called with the given values
func (f_sym19 *FakeValidator) AssertGetAndValidateTokenCalledWith(t ValidatorTestingT, accessToken string, requiredScopes ...string) {
t.Helper()
var found_sym19 bool
for _, call_sym19 := range f_sym19.GetAndValidateTokenCalls {
if reflect.DeepEqual(call_sym19.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym19.Parameters.RequiredScopes, requiredScopes) {
found_sym19 = true
break
}
}
if !found_sym19 {
t.Error("FakeValidator.GetAndValidateToken not called with expected parameters")
}
}
// GetAndValidateTokenCalledOnceWith returns true if FakeValidator.GetAndValidateToken was called exactly once with the given values
func (f_sym20 *FakeValidator) GetAndValidateTokenCalledOnceWith(accessToken string, requiredScopes ...string) bool {
var count_sym20 int
for _, call_sym20 := range f_sym20.GetAndValidateTokenCalls {
if reflect.DeepEqual(call_sym20.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym20.Parameters.RequiredScopes, requiredScopes) {
count_sym20++
}
}
return count_sym20 == 1
}
// AssertGetAndValidateTokenCalledOnceWith calls t.Error if FakeValidator.GetAndValidateToken was not called exactly once with the given values
func (f_sym21 *FakeValidator) AssertGetAndValidateTokenCalledOnceWith(t ValidatorTestingT, accessToken string, requiredScopes ...string) {
t.Helper()
var count_sym21 int
for _, call_sym21 := range f_sym21.GetAndValidateTokenCalls {
if reflect.DeepEqual(call_sym21.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym21.Parameters.RequiredScopes, requiredScopes) {
count_sym21++
}
}
if count_sym21 != 1 {
t.Errorf("FakeValidator.GetAndValidateToken called %d times with expected parameters, expected one", count_sym21)
}
}
// GetAndValidateTokenResultsForCall returns the result values for the first call to FakeValidator.GetAndValidateToken with the given values
func (f_sym22 *FakeValidator) GetAndValidateTokenResultsForCall(accessToken string, requiredScopes ...string) (ident1 jwt.JWT, ident2 error, found_sym22 bool) {
for _, call_sym22 := range f_sym22.GetAndValidateTokenCalls {
if reflect.DeepEqual(call_sym22.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym22.Parameters.RequiredScopes, requiredScopes) {
ident1 = call_sym22.Results.Ident1
ident2 = call_sym22.Results.Ident2
found_sym22 = true
break
}
}
return
}
func (f_sym23 *FakeValidator) ValidateUserToken(accessToken string, requiredScopes ...string) (ident1 uint64, ident2 uint64, ident3 bool, ident4 error) {
if f_sym23.ValidateUserTokenHook == nil {
panic("Validator.ValidateUserToken() called but FakeValidator.ValidateUserTokenHook is nil")
}
invocation_sym23 := new(ValidatorValidateUserTokenInvocation)
f_sym23.ValidateUserTokenCalls = append(f_sym23.ValidateUserTokenCalls, invocation_sym23)
invocation_sym23.Parameters.AccessToken = accessToken
invocation_sym23.Parameters.RequiredScopes = requiredScopes
ident1, ident2, ident3, ident4 = f_sym23.ValidateUserTokenHook(accessToken, requiredScopes...)
invocation_sym23.Results.Ident1 = ident1
invocation_sym23.Results.Ident2 = ident2
invocation_sym23.Results.Ident3 = ident3
invocation_sym23.Results.Ident4 = ident4
return
}
// SetValidateUserTokenStub configures Validator.ValidateUserToken to always return the given values
func (f_sym24 *FakeValidator) SetValidateUserTokenStub(ident1 uint64, ident2 uint64, ident3 bool, ident4 error) {
f_sym24.ValidateUserTokenHook = func(string, ...string) (uint64, uint64, bool, error) {
return ident1, ident2, ident3, ident4
}
}
// SetValidateUserTokenInvocation configures Validator.ValidateUserToken to return the given results when called with the given parameters
// If no match is found for an invocation the result(s) of the fallback function are returned
func (f_sym25 *FakeValidator) SetValidateUserTokenInvocation(calls_sym25 []*ValidatorValidateUserTokenInvocation, fallback_sym25 func() (uint64, uint64, bool, error)) {
f_sym25.ValidateUserTokenHook = func(accessToken string, requiredScopes ...string) (ident1 uint64, ident2 uint64, ident3 bool, ident4 error) {
for _, call_sym25 := range calls_sym25 {
if reflect.DeepEqual(call_sym25.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym25.Parameters.RequiredScopes, requiredScopes) {
ident1 = call_sym25.Results.Ident1
ident2 = call_sym25.Results.Ident2
ident3 = call_sym25.Results.Ident3
ident4 = call_sym25.Results.Ident4
return
}
}
return fallback_sym25()
}
}
// ValidateUserTokenCalled returns true if FakeValidator.ValidateUserToken was called
func (f *FakeValidator) ValidateUserTokenCalled() bool {
return len(f.ValidateUserTokenCalls) != 0
}
// AssertValidateUserTokenCalled calls t.Error if FakeValidator.ValidateUserToken was not called
func (f *FakeValidator) AssertValidateUserTokenCalled(t ValidatorTestingT) {
t.Helper()
if len(f.ValidateUserTokenCalls) == 0 {
t.Error("FakeValidator.ValidateUserToken not called, expected at least one")
}
}
// ValidateUserTokenNotCalled returns true if FakeValidator.ValidateUserToken was not called
func (f *FakeValidator) ValidateUserTokenNotCalled() bool {
return len(f.ValidateUserTokenCalls) == 0
}
// AssertValidateUserTokenNotCalled calls t.Error if FakeValidator.ValidateUserToken was called
func (f *FakeValidator) AssertValidateUserTokenNotCalled(t ValidatorTestingT) {
t.Helper()
if len(f.ValidateUserTokenCalls) != 0 {
t.Error("FakeValidator.ValidateUserToken called, expected none")
}
}
// ValidateUserTokenCalledOnce returns true if FakeValidator.ValidateUserToken was called exactly once
func (f *FakeValidator) ValidateUserTokenCalledOnce() bool {
return len(f.ValidateUserTokenCalls) == 1
}
// AssertValidateUserTokenCalledOnce calls t.Error if FakeValidator.ValidateUserToken was not called exactly once
func (f *FakeValidator) AssertValidateUserTokenCalledOnce(t ValidatorTestingT) {
t.Helper()
if len(f.ValidateUserTokenCalls) != 1 {
t.Errorf("FakeValidator.ValidateUserToken called %d times, expected 1", len(f.ValidateUserTokenCalls))
}
}
// ValidateUserTokenCalledN returns true if FakeValidator.ValidateUserToken was called at least n times
func (f *FakeValidator) ValidateUserTokenCalledN(n int) bool {
return len(f.ValidateUserTokenCalls) >= n
}
// AssertValidateUserTokenCalledN calls t.Error if FakeValidator.ValidateUserToken was called less than n times
func (f *FakeValidator) AssertValidateUserTokenCalledN(t ValidatorTestingT, n int) {
t.Helper()
if len(f.ValidateUserTokenCalls) < n {
t.Errorf("FakeValidator.ValidateUserToken called %d times, expected >= %d", len(f.ValidateUserTokenCalls), n)
}
}
// ValidateUserTokenCalledWith returns true if FakeValidator.ValidateUserToken was called with the given values
func (f_sym26 *FakeValidator) ValidateUserTokenCalledWith(accessToken string, requiredScopes ...string) bool {
for _, call_sym26 := range f_sym26.ValidateUserTokenCalls {
if reflect.DeepEqual(call_sym26.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym26.Parameters.RequiredScopes, requiredScopes) {
return true
}
}
return false
}
// AssertValidateUserTokenCalledWith calls t.Error if FakeValidator.ValidateUserToken was not called with the given values
func (f_sym27 *FakeValidator) AssertValidateUserTokenCalledWith(t ValidatorTestingT, accessToken string, requiredScopes ...string) {
t.Helper()
var found_sym27 bool
for _, call_sym27 := range f_sym27.ValidateUserTokenCalls {
if reflect.DeepEqual(call_sym27.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym27.Parameters.RequiredScopes, requiredScopes) {
found_sym27 = true
break
}
}
if !found_sym27 {
t.Error("FakeValidator.ValidateUserToken not called with expected parameters")
}
}
// ValidateUserTokenCalledOnceWith returns true if FakeValidator.ValidateUserToken was called exactly once with the given values
func (f_sym28 *FakeValidator) ValidateUserTokenCalledOnceWith(accessToken string, requiredScopes ...string) bool {
var count_sym28 int
for _, call_sym28 := range f_sym28.ValidateUserTokenCalls {
if reflect.DeepEqual(call_sym28.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym28.Parameters.RequiredScopes, requiredScopes) {
count_sym28++
}
}
return count_sym28 == 1
}
// AssertValidateUserTokenCalledOnceWith calls t.Error if FakeValidator.ValidateUserToken was not called exactly once with the given values
func (f_sym29 *FakeValidator) AssertValidateUserTokenCalledOnceWith(t ValidatorTestingT, accessToken string, requiredScopes ...string) {
t.Helper()
var count_sym29 int
for _, call_sym29 := range f_sym29.ValidateUserTokenCalls {
if reflect.DeepEqual(call_sym29.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym29.Parameters.RequiredScopes, requiredScopes) {
count_sym29++
}
}
if count_sym29 != 1 {
t.Errorf("FakeValidator.ValidateUserToken called %d times with expected parameters, expected one", count_sym29)
}
}
// ValidateUserTokenResultsForCall returns the result values for the first call to FakeValidator.ValidateUserToken with the given values
func (f_sym30 *FakeValidator) ValidateUserTokenResultsForCall(accessToken string, requiredScopes ...string) (ident1 uint64, ident2 uint64, ident3 bool, ident4 error, found_sym30 bool) {
for _, call_sym30 := range f_sym30.ValidateUserTokenCalls {
if reflect.DeepEqual(call_sym30.Parameters.AccessToken, accessToken) && reflect.DeepEqual(call_sym30.Parameters.RequiredScopes, requiredScopes) {
ident1 = call_sym30.Results.Ident1
ident2 = call_sym30.Results.Ident2
ident3 = call_sym30.Results.Ident3
ident4 = call_sym30.Results.Ident4
found_sym30 = true
break
}
}
return
}
func (f_sym31 *FakeValidator) GetOpenIDConfig() (ident1 access.OpenIDConfig) {
if f_sym31.GetOpenIDConfigHook == nil {
panic("Validator.GetOpenIDConfig() called but FakeValidator.GetOpenIDConfigHook is nil")
}
invocation_sym31 := new(ValidatorGetOpenIDConfigInvocation)
f_sym31.GetOpenIDConfigCalls = append(f_sym31.GetOpenIDConfigCalls, invocation_sym31)
ident1 = f_sym31.GetOpenIDConfigHook()
invocation_sym31.Results.Ident1 = ident1
return
}
// SetGetOpenIDConfigStub configures Validator.GetOpenIDConfig to always return the given values
func (f_sym32 *FakeValidator) SetGetOpenIDConfigStub(ident1 access.OpenIDConfig) {
f_sym32.GetOpenIDConfigHook = func() access.OpenIDConfig {
return ident1
}
}
// GetOpenIDConfigCalled returns true if FakeValidator.GetOpenIDConfig was called
func (f *FakeValidator) GetOpenIDConfigCalled() bool {
return len(f.GetOpenIDConfigCalls) != 0
}
// AssertGetOpenIDConfigCalled calls t.Error if FakeValidator.GetOpenIDConfig was not called
func (f *FakeValidator) AssertGetOpenIDConfigCalled(t ValidatorTestingT) {
t.Helper()
if len(f.GetOpenIDConfigCalls) == 0 {
t.Error("FakeValidator.GetOpenIDConfig not called, expected at least one")
}
}
// GetOpenIDConfigNotCalled returns true if FakeValidator.GetOpenIDConfig was not called
func (f *FakeValidator) GetOpenIDConfigNotCalled() bool {
return len(f.GetOpenIDConfigCalls) == 0
}
// AssertGetOpenIDConfigNotCalled calls t.Error if FakeValidator.GetOpenIDConfig was called
func (f *FakeValidator) AssertGetOpenIDConfigNotCalled(t ValidatorTestingT) {
t.Helper()
if len(f.GetOpenIDConfigCalls) != 0 {
t.Error("FakeValidator.GetOpenIDConfig called, expected none")
}
}
// GetOpenIDConfigCalledOnce returns true if FakeValidator.GetOpenIDConfig was called exactly once
func (f *FakeValidator) GetOpenIDConfigCalledOnce() bool {
return len(f.GetOpenIDConfigCalls) == 1
}
// AssertGetOpenIDConfigCalledOnce calls t.Error if FakeValidator.GetOpenIDConfig was not called exactly once
func (f *FakeValidator) AssertGetOpenIDConfigCalledOnce(t ValidatorTestingT) {
t.Helper()
if len(f.GetOpenIDConfigCalls) != 1 {
t.Errorf("FakeValidator.GetOpenIDConfig called %d times, expected 1", len(f.GetOpenIDConfigCalls))
}
}
// GetOpenIDConfigCalledN returns true if FakeValidator.GetOpenIDConfig was called at least n times
func (f *FakeValidator) GetOpenIDConfigCalledN(n int) bool {
return len(f.GetOpenIDConfigCalls) >= n
}
// AssertGetOpenIDConfigCalledN calls t.Error if FakeValidator.GetOpenIDConfig was called less than n times
func (f *FakeValidator) AssertGetOpenIDConfigCalledN(t ValidatorTestingT, n int) {
t.Helper()
if len(f.GetOpenIDConfigCalls) < n {
t.Errorf("FakeValidator.GetOpenIDConfig called %d times, expected >= %d", len(f.GetOpenIDConfigCalls), n)
}
}