forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fake_repository.go
255 lines (229 loc) · 8.09 KB
/
fake_repository.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
// This file was generated by counterfeiter
package authenticationfakes
import (
"net/http"
"sync"
"code.cloudfoundry.org/cli/cf/api/authentication"
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
)
type FakeRepository struct {
DumpRequestStub func(*http.Request)
dumpRequestMutex sync.RWMutex
dumpRequestArgsForCall []struct {
arg1 *http.Request
}
DumpResponseStub func(*http.Response)
dumpResponseMutex sync.RWMutex
dumpResponseArgsForCall []struct {
arg1 *http.Response
}
RefreshAuthTokenStub func() (updatedToken string, apiErr error)
refreshAuthTokenMutex sync.RWMutex
refreshAuthTokenArgsForCall []struct{}
refreshAuthTokenReturns struct {
result1 string
result2 error
}
AuthenticateStub func(credentials map[string]string) (apiErr error)
authenticateMutex sync.RWMutex
authenticateArgsForCall []struct {
credentials map[string]string
}
authenticateReturns struct {
result1 error
}
AuthorizeStub func(token string) (string, error)
authorizeMutex sync.RWMutex
authorizeArgsForCall []struct {
token string
}
authorizeReturns struct {
result1 string
result2 error
}
GetLoginPromptsAndSaveUAAServerURLStub func() (map[string]coreconfig.AuthPrompt, error)
getLoginPromptsAndSaveUAAServerURLMutex sync.RWMutex
getLoginPromptsAndSaveUAAServerURLArgsForCall []struct{}
getLoginPromptsAndSaveUAAServerURLReturns struct {
result1 map[string]coreconfig.AuthPrompt
result2 error
}
invocations map[string][][]interface{}
invocationsMutex sync.RWMutex
}
func (fake *FakeRepository) DumpRequest(arg1 *http.Request) {
fake.dumpRequestMutex.Lock()
fake.dumpRequestArgsForCall = append(fake.dumpRequestArgsForCall, struct {
arg1 *http.Request
}{arg1})
fake.recordInvocation("DumpRequest", []interface{}{arg1})
fake.dumpRequestMutex.Unlock()
if fake.DumpRequestStub != nil {
fake.DumpRequestStub(arg1)
}
}
func (fake *FakeRepository) DumpRequestCallCount() int {
fake.dumpRequestMutex.RLock()
defer fake.dumpRequestMutex.RUnlock()
return len(fake.dumpRequestArgsForCall)
}
func (fake *FakeRepository) DumpRequestArgsForCall(i int) *http.Request {
fake.dumpRequestMutex.RLock()
defer fake.dumpRequestMutex.RUnlock()
return fake.dumpRequestArgsForCall[i].arg1
}
func (fake *FakeRepository) DumpResponse(arg1 *http.Response) {
fake.dumpResponseMutex.Lock()
fake.dumpResponseArgsForCall = append(fake.dumpResponseArgsForCall, struct {
arg1 *http.Response
}{arg1})
fake.recordInvocation("DumpResponse", []interface{}{arg1})
fake.dumpResponseMutex.Unlock()
if fake.DumpResponseStub != nil {
fake.DumpResponseStub(arg1)
}
}
func (fake *FakeRepository) DumpResponseCallCount() int {
fake.dumpResponseMutex.RLock()
defer fake.dumpResponseMutex.RUnlock()
return len(fake.dumpResponseArgsForCall)
}
func (fake *FakeRepository) DumpResponseArgsForCall(i int) *http.Response {
fake.dumpResponseMutex.RLock()
defer fake.dumpResponseMutex.RUnlock()
return fake.dumpResponseArgsForCall[i].arg1
}
func (fake *FakeRepository) RefreshAuthToken() (updatedToken string, apiErr error) {
fake.refreshAuthTokenMutex.Lock()
fake.refreshAuthTokenArgsForCall = append(fake.refreshAuthTokenArgsForCall, struct{}{})
fake.recordInvocation("RefreshAuthToken", []interface{}{})
fake.refreshAuthTokenMutex.Unlock()
if fake.RefreshAuthTokenStub != nil {
return fake.RefreshAuthTokenStub()
} else {
return fake.refreshAuthTokenReturns.result1, fake.refreshAuthTokenReturns.result2
}
}
func (fake *FakeRepository) RefreshAuthTokenCallCount() int {
fake.refreshAuthTokenMutex.RLock()
defer fake.refreshAuthTokenMutex.RUnlock()
return len(fake.refreshAuthTokenArgsForCall)
}
func (fake *FakeRepository) RefreshAuthTokenReturns(result1 string, result2 error) {
fake.RefreshAuthTokenStub = nil
fake.refreshAuthTokenReturns = struct {
result1 string
result2 error
}{result1, result2}
}
func (fake *FakeRepository) Authenticate(credentials map[string]string) (apiErr error) {
fake.authenticateMutex.Lock()
fake.authenticateArgsForCall = append(fake.authenticateArgsForCall, struct {
credentials map[string]string
}{credentials})
fake.recordInvocation("Authenticate", []interface{}{credentials})
fake.authenticateMutex.Unlock()
if fake.AuthenticateStub != nil {
return fake.AuthenticateStub(credentials)
} else {
return fake.authenticateReturns.result1
}
}
func (fake *FakeRepository) AuthenticateCallCount() int {
fake.authenticateMutex.RLock()
defer fake.authenticateMutex.RUnlock()
return len(fake.authenticateArgsForCall)
}
func (fake *FakeRepository) AuthenticateArgsForCall(i int) map[string]string {
fake.authenticateMutex.RLock()
defer fake.authenticateMutex.RUnlock()
return fake.authenticateArgsForCall[i].credentials
}
func (fake *FakeRepository) AuthenticateReturns(result1 error) {
fake.AuthenticateStub = nil
fake.authenticateReturns = struct {
result1 error
}{result1}
}
func (fake *FakeRepository) Authorize(token string) (string, error) {
fake.authorizeMutex.Lock()
fake.authorizeArgsForCall = append(fake.authorizeArgsForCall, struct {
token string
}{token})
fake.recordInvocation("Authorize", []interface{}{token})
fake.authorizeMutex.Unlock()
if fake.AuthorizeStub != nil {
return fake.AuthorizeStub(token)
} else {
return fake.authorizeReturns.result1, fake.authorizeReturns.result2
}
}
func (fake *FakeRepository) AuthorizeCallCount() int {
fake.authorizeMutex.RLock()
defer fake.authorizeMutex.RUnlock()
return len(fake.authorizeArgsForCall)
}
func (fake *FakeRepository) AuthorizeArgsForCall(i int) string {
fake.authorizeMutex.RLock()
defer fake.authorizeMutex.RUnlock()
return fake.authorizeArgsForCall[i].token
}
func (fake *FakeRepository) AuthorizeReturns(result1 string, result2 error) {
fake.AuthorizeStub = nil
fake.authorizeReturns = struct {
result1 string
result2 error
}{result1, result2}
}
func (fake *FakeRepository) GetLoginPromptsAndSaveUAAServerURL() (map[string]coreconfig.AuthPrompt, error) {
fake.getLoginPromptsAndSaveUAAServerURLMutex.Lock()
fake.getLoginPromptsAndSaveUAAServerURLArgsForCall = append(fake.getLoginPromptsAndSaveUAAServerURLArgsForCall, struct{}{})
fake.recordInvocation("GetLoginPromptsAndSaveUAAServerURL", []interface{}{})
fake.getLoginPromptsAndSaveUAAServerURLMutex.Unlock()
if fake.GetLoginPromptsAndSaveUAAServerURLStub != nil {
return fake.GetLoginPromptsAndSaveUAAServerURLStub()
} else {
return fake.getLoginPromptsAndSaveUAAServerURLReturns.result1, fake.getLoginPromptsAndSaveUAAServerURLReturns.result2
}
}
func (fake *FakeRepository) GetLoginPromptsAndSaveUAAServerURLCallCount() int {
fake.getLoginPromptsAndSaveUAAServerURLMutex.RLock()
defer fake.getLoginPromptsAndSaveUAAServerURLMutex.RUnlock()
return len(fake.getLoginPromptsAndSaveUAAServerURLArgsForCall)
}
func (fake *FakeRepository) GetLoginPromptsAndSaveUAAServerURLReturns(result1 map[string]coreconfig.AuthPrompt, result2 error) {
fake.GetLoginPromptsAndSaveUAAServerURLStub = nil
fake.getLoginPromptsAndSaveUAAServerURLReturns = struct {
result1 map[string]coreconfig.AuthPrompt
result2 error
}{result1, result2}
}
func (fake *FakeRepository) Invocations() map[string][][]interface{} {
fake.invocationsMutex.RLock()
defer fake.invocationsMutex.RUnlock()
fake.dumpRequestMutex.RLock()
defer fake.dumpRequestMutex.RUnlock()
fake.dumpResponseMutex.RLock()
defer fake.dumpResponseMutex.RUnlock()
fake.refreshAuthTokenMutex.RLock()
defer fake.refreshAuthTokenMutex.RUnlock()
fake.authenticateMutex.RLock()
defer fake.authenticateMutex.RUnlock()
fake.authorizeMutex.RLock()
defer fake.authorizeMutex.RUnlock()
fake.getLoginPromptsAndSaveUAAServerURLMutex.RLock()
defer fake.getLoginPromptsAndSaveUAAServerURLMutex.RUnlock()
return fake.invocations
}
func (fake *FakeRepository) recordInvocation(key string, args []interface{}) {
fake.invocationsMutex.Lock()
defer fake.invocationsMutex.Unlock()
if fake.invocations == nil {
fake.invocations = map[string][][]interface{}{}
}
if fake.invocations[key] == nil {
fake.invocations[key] = [][]interface{}{}
}
fake.invocations[key] = append(fake.invocations[key], args)
}
var _ authentication.Repository = new(FakeRepository)