@@ -134,81 +134,60 @@ var (
134
134
ctx , & litrpc.ListSessionsRequest {},
135
135
)
136
136
}
137
+ litMacaroonFn = func (cfg * LitNodeConfig ) string {
138
+ return cfg .LitMacPath
139
+ }
137
140
138
141
endpoints = []struct {
139
- name string
140
- macaroonFn macaroonFn
141
- requestFn requestFn
142
- successPattern string
143
- supportsMacAuthOnLndPort bool
144
- supportsMacAuthOnLitPort bool
145
- supportsUIPasswordOnLndPort bool
146
- supportsUIPasswordOnLitPort bool
147
- allowedThroughLNC bool
148
- grpcWebURI string
149
- restWebURI string
142
+ name string
143
+ macaroonFn macaroonFn
144
+ requestFn requestFn
145
+ successPattern string
146
+ allowedThroughLNC bool
147
+ grpcWebURI string
148
+ restWebURI string
150
149
}{{
151
- name : "lnrpc" ,
152
- macaroonFn : lndMacaroonFn ,
153
- requestFn : lndRequestFn ,
154
- successPattern : "\" identity_pubkey\" :\" 0" ,
155
- supportsMacAuthOnLndPort : true ,
156
- supportsMacAuthOnLitPort : true ,
157
- supportsUIPasswordOnLndPort : false ,
158
- supportsUIPasswordOnLitPort : true ,
159
- allowedThroughLNC : true ,
160
- grpcWebURI : "/lnrpc.Lightning/GetInfo" ,
161
- restWebURI : "/v1/getinfo" ,
150
+ name : "lnrpc" ,
151
+ macaroonFn : lndMacaroonFn ,
152
+ requestFn : lndRequestFn ,
153
+ successPattern : "\" identity_pubkey\" :\" 0" ,
154
+ allowedThroughLNC : true ,
155
+ grpcWebURI : "/lnrpc.Lightning/GetInfo" ,
156
+ restWebURI : "/v1/getinfo" ,
162
157
}, {
163
- name : "frdrpc" ,
164
- macaroonFn : faradayMacaroonFn ,
165
- requestFn : faradayRequestFn ,
166
- successPattern : "\" reports\" :[]" ,
167
- supportsMacAuthOnLndPort : true ,
168
- supportsMacAuthOnLitPort : true ,
169
- supportsUIPasswordOnLndPort : false ,
170
- supportsUIPasswordOnLitPort : true ,
171
- allowedThroughLNC : true ,
172
- grpcWebURI : "/frdrpc.FaradayServer/RevenueReport" ,
173
- restWebURI : "/v1/faraday/revenue" ,
158
+ name : "frdrpc" ,
159
+ macaroonFn : faradayMacaroonFn ,
160
+ requestFn : faradayRequestFn ,
161
+ successPattern : "\" reports\" :[]" ,
162
+ allowedThroughLNC : true ,
163
+ grpcWebURI : "/frdrpc.FaradayServer/RevenueReport" ,
164
+ restWebURI : "/v1/faraday/revenue" ,
174
165
}, {
175
- name : "looprpc" ,
176
- macaroonFn : loopMacaroonFn ,
177
- requestFn : loopRequestFn ,
178
- successPattern : "\" swaps\" :[]" ,
179
- supportsMacAuthOnLndPort : true ,
180
- supportsMacAuthOnLitPort : true ,
181
- supportsUIPasswordOnLndPort : false ,
182
- supportsUIPasswordOnLitPort : true ,
183
- allowedThroughLNC : true ,
184
- grpcWebURI : "/looprpc.SwapClient/ListSwaps" ,
185
- restWebURI : "/v1/loop/swaps" ,
166
+ name : "looprpc" ,
167
+ macaroonFn : loopMacaroonFn ,
168
+ requestFn : loopRequestFn ,
169
+ successPattern : "\" swaps\" :[]" ,
170
+ allowedThroughLNC : true ,
171
+ grpcWebURI : "/looprpc.SwapClient/ListSwaps" ,
172
+ restWebURI : "/v1/loop/swaps" ,
186
173
}, {
187
- name : "poolrpc" ,
188
- macaroonFn : poolMacaroonFn ,
189
- requestFn : poolRequestFn ,
190
- successPattern : "\" accounts_active\" :0" ,
191
- supportsMacAuthOnLndPort : true ,
192
- supportsMacAuthOnLitPort : true ,
193
- supportsUIPasswordOnLndPort : false ,
194
- supportsUIPasswordOnLitPort : true ,
195
- allowedThroughLNC : true ,
196
- grpcWebURI : "/poolrpc.Trader/GetInfo" ,
197
- restWebURI : "/v1/pool/info" ,
174
+ name : "poolrpc" ,
175
+ macaroonFn : poolMacaroonFn ,
176
+ requestFn : poolRequestFn ,
177
+ successPattern : "\" accounts_active\" :0" ,
178
+ allowedThroughLNC : true ,
179
+ grpcWebURI : "/poolrpc.Trader/GetInfo" ,
180
+ restWebURI : "/v1/pool/info" ,
198
181
}, {
199
182
name : "litrpc" ,
200
- macaroonFn : nil ,
183
+ macaroonFn : litMacaroonFn ,
201
184
requestFn : litRequestFn ,
202
185
// In some test cases we actually expect some sessions, so we
203
186
// don't explicitly check for an empty array but just the
204
187
// existence of the array in the response.
205
- successPattern : "\" sessions\" :[" ,
206
- supportsMacAuthOnLndPort : false ,
207
- supportsMacAuthOnLitPort : false ,
208
- supportsUIPasswordOnLndPort : true ,
209
- supportsUIPasswordOnLitPort : true ,
210
- allowedThroughLNC : false ,
211
- grpcWebURI : "/litrpc.Sessions/ListSessions" ,
188
+ successPattern : "\" sessions\" :[" ,
189
+ allowedThroughLNC : false ,
190
+ grpcWebURI : "/litrpc.Sessions/ListSessions" ,
212
191
}}
213
192
)
214
193
@@ -236,10 +215,6 @@ func testModeIntegrated(net *NetworkHarness, t *harnessTest) {
236
215
for _ , endpoint := range endpoints {
237
216
endpoint := endpoint
238
217
tt .Run (endpoint .name + " lnd port" , func (ttt * testing.T ) {
239
- if ! endpoint .supportsMacAuthOnLndPort {
240
- return
241
- }
242
-
243
218
runGRPCAuthTest (
244
219
ttt , cfg .RPCAddr (), cfg .TLSCertPath ,
245
220
endpoint .macaroonFn (cfg ),
@@ -249,10 +224,6 @@ func testModeIntegrated(net *NetworkHarness, t *harnessTest) {
249
224
})
250
225
251
226
tt .Run (endpoint .name + " lit port" , func (ttt * testing.T ) {
252
- if ! endpoint .supportsMacAuthOnLitPort {
253
- return
254
- }
255
-
256
227
runGRPCAuthTest (
257
228
ttt , cfg .LitAddr (), cfg .TLSCertPath ,
258
229
endpoint .macaroonFn (cfg ),
@@ -271,20 +242,16 @@ func testModeIntegrated(net *NetworkHarness, t *harnessTest) {
271
242
tt .Run (endpoint .name + " lnd port" , func (ttt * testing.T ) {
272
243
runUIPasswordCheck (
273
244
ttt , cfg .RPCAddr (), cfg .TLSCertPath ,
274
- cfg .UIPassword ,
275
- endpoint .requestFn , true ,
276
- ! endpoint .supportsUIPasswordOnLndPort ,
277
- endpoint .successPattern ,
245
+ cfg .UIPassword , endpoint .requestFn ,
246
+ true , endpoint .successPattern ,
278
247
)
279
248
})
280
249
281
250
tt .Run (endpoint .name + " lit port" , func (ttt * testing.T ) {
282
251
runUIPasswordCheck (
283
252
ttt , cfg .LitAddr (), cfg .TLSCertPath ,
284
- cfg .UIPassword ,
285
- endpoint .requestFn , false ,
286
- ! endpoint .supportsUIPasswordOnLitPort ,
287
- endpoint .successPattern ,
253
+ cfg .UIPassword , endpoint .requestFn ,
254
+ false , endpoint .successPattern ,
288
255
)
289
256
})
290
257
}
@@ -321,10 +288,6 @@ func testModeIntegrated(net *NetworkHarness, t *harnessTest) {
321
288
for _ , endpoint := range endpoints {
322
289
endpoint := endpoint
323
290
tt .Run (endpoint .name + " lnd port" , func (ttt * testing.T ) {
324
- if ! endpoint .supportsMacAuthOnLndPort {
325
- return
326
- }
327
-
328
291
runGRPCAuthTest (
329
292
ttt , cfg .RPCAddr (), cfg .TLSCertPath ,
330
293
superMacFile ,
@@ -334,10 +297,6 @@ func testModeIntegrated(net *NetworkHarness, t *harnessTest) {
334
297
})
335
298
336
299
tt .Run (endpoint .name + " lit port" , func (ttt * testing.T ) {
337
- if ! endpoint .supportsMacAuthOnLitPort {
338
- return
339
- }
340
-
341
300
runGRPCAuthTest (
342
301
ttt , cfg .LitAddr (), cfg .TLSCertPath ,
343
302
superMacFile ,
@@ -454,8 +413,8 @@ func runGRPCAuthTest(t *testing.T, hostPort, tlsCertPath, macPath string,
454
413
455
414
// runUIPasswordCheck tests UI password authentication.
456
415
func runUIPasswordCheck (t * testing.T , hostPort , tlsCertPath , uiPassword string ,
457
- makeRequest requestFn , shouldFailWithoutMacaroon ,
458
- shouldFailWithDummyMacaroon bool , successContent string ) {
416
+ makeRequest requestFn , shouldFailWithoutMacaroon bool ,
417
+ successContent string ) {
459
418
460
419
ctxb := context .Background ()
461
420
ctxt , cancel := context .WithTimeout (ctxb , defaultTimeout )
@@ -503,13 +462,11 @@ func runUIPasswordCheck(t *testing.T, hostPort, tlsCertPath, uiPassword string,
503
462
ctxm = uiPasswordContext (ctxt , uiPassword , true )
504
463
resp , err = makeRequest (ctxm , rawConn )
505
464
506
- if shouldFailWithDummyMacaroon {
507
- require .Error (t , err )
508
- require .Contains (
509
- t , err .Error (), "cannot get macaroon: root" ,
510
- )
511
- return
512
- }
465
+ require .Error (t , err )
466
+ require .Contains (
467
+ t , err .Error (), "cannot get macaroon: root" ,
468
+ )
469
+ return
513
470
}
514
471
515
472
// We expect the call to succeed.
0 commit comments