Skip to content

Commit 294e9d0

Browse files
itest: add disable test for accounts endpoint
1 parent 20fa2c0 commit 294e9d0

File tree

2 files changed

+56
-16
lines changed

2 files changed

+56
-16
lines changed

itest/litd_mode_integrated_test.go

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,21 @@ var (
213213
}
214214

215215
endpoints = []struct {
216-
name string
217-
macaroonFn macaroonFn
218-
requestFn requestFn
219-
successPattern string
216+
name string
217+
macaroonFn macaroonFn
218+
requestFn requestFn
219+
successPattern string
220+
221+
// disabledPattern represents a substring that is expected to be
222+
// part of the error returned when a gRPC request is made to the
223+
// disabled endpoint.
224+
// TODO: once we have a subsystem manager, we can unify the
225+
// returned for disabled endpoints for both subsystems and
226+
// subservers by not registering the subsystem URIs to the
227+
// permsMgr if it has been disabled. This field will then be
228+
// unnecessary and can be removed.
229+
disabledPattern string
230+
220231
allowedThroughLNC bool
221232
grpcWebURI string
222233
restWebURI string
@@ -269,6 +280,7 @@ var (
269280
macaroonFn: faradayMacaroonFn,
270281
requestFn: faradayRequestFn,
271282
successPattern: "\"reports\":[]",
283+
disabledPattern: "unknown request",
272284
allowedThroughLNC: true,
273285
grpcWebURI: "/frdrpc.FaradayServer/RevenueReport",
274286
restWebURI: "/v1/faraday/revenue",
@@ -278,6 +290,7 @@ var (
278290
macaroonFn: loopMacaroonFn,
279291
requestFn: loopRequestFn,
280292
successPattern: "\"swaps\":[]",
293+
disabledPattern: "unknown request",
281294
allowedThroughLNC: true,
282295
grpcWebURI: "/looprpc.SwapClient/ListSwaps",
283296
restWebURI: "/v1/loop/swaps",
@@ -287,6 +300,7 @@ var (
287300
macaroonFn: poolMacaroonFn,
288301
requestFn: poolRequestFn,
289302
successPattern: "\"accounts_active\":0",
303+
disabledPattern: "unknown request",
290304
allowedThroughLNC: true,
291305
grpcWebURI: "/poolrpc.Trader/GetInfo",
292306
restWebURI: "/v1/pool/info",
@@ -296,6 +310,7 @@ var (
296310
macaroonFn: tapMacaroonFn,
297311
requestFn: tapRequestFn,
298312
successPattern: "\"assets\":[]",
313+
disabledPattern: "unknown request",
299314
allowedThroughLNC: true,
300315
grpcWebURI: "/taprpc.TaprootAssets/ListAssets",
301316
restWebURI: "/v1/taproot-assets/assets",
@@ -305,6 +320,7 @@ var (
305320
macaroonFn: emptyMacaroonFn,
306321
requestFn: tapUniverseRequestFn,
307322
successPattern: "\"num_assets\":",
323+
disabledPattern: "unknown request",
308324
allowedThroughLNC: true,
309325
grpcWebURI: "/universerpc.Universe/Info",
310326
restWebURI: "/v1/taproot-assets/universe/info",
@@ -326,9 +342,11 @@ var (
326342
macaroonFn: litMacaroonFn,
327343
requestFn: litAccountRequestFn,
328344
successPattern: "\"accounts\":[",
345+
disabledPattern: "accounts has been disabled",
329346
allowedThroughLNC: false,
330347
grpcWebURI: "/litrpc.Accounts/ListAccounts",
331348
restWebURI: "/v1/accounts",
349+
canDisable: true,
332350
}, {
333351
name: "litrpc-autopilot",
334352
macaroonFn: litMacaroonFn,
@@ -384,6 +402,7 @@ func testDisablingSubServers(ctx context.Context, net *NetworkHarness,
384402
WithLitArg("loop-mode", "disable"),
385403
WithLitArg("pool-mode", "disable"),
386404
WithLitArg("faraday-mode", "disable"),
405+
WithLitArg("accounts.disable", ""),
387406
},
388407
)
389408
require.NoError(t, err)
@@ -494,7 +513,7 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
494513
endpoint.requestFn,
495514
endpoint.successPattern,
496515
endpointDisabled,
497-
"unknown request",
516+
endpoint.disabledPattern,
498517
)
499518
})
500519
}
@@ -532,7 +551,7 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
532551
shouldFailWithoutMacaroon,
533552
endpoint.successPattern,
534553
endpointDisabled,
535-
"unknown request",
554+
endpoint.disabledPattern,
536555
)
537556
})
538557
}
@@ -557,7 +576,8 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
557576
ttt, cfg.LitAddr(), cfg.UIPassword,
558577
endpoint.grpcWebURI,
559578
withoutUIPassword, endpointDisabled,
560-
"unknown request", endpoint.noAuth,
579+
endpoint.disabledPattern,
580+
endpoint.noAuth,
561581
)
562582
})
563583
}
@@ -596,7 +616,7 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
596616
endpoint.requestFn,
597617
endpoint.successPattern,
598618
endpointDisabled,
599-
"unknown request",
619+
endpoint.disabledPattern,
600620
)
601621
})
602622
}
@@ -649,7 +669,9 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
649669
endpoint.successPattern,
650670
endpoint.allowedThroughLNC,
651671
"unknown service",
652-
endpointDisabled, endpoint.noAuth,
672+
endpointDisabled,
673+
endpoint.disabledPattern,
674+
endpoint.noAuth,
653675
)
654676
})
655677
}
@@ -658,6 +680,12 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
658680
t.Run("gRPC super macaroon account system test", func(tt *testing.T) {
659681
cfg := net.Alice.Cfg
660682

683+
// If the accounts service is disabled, we skip this test as it
684+
// will fail due to the accounts service being disabled.
685+
if subServersDisabled {
686+
return
687+
}
688+
661689
superMacFile, err := bakeSuperMacaroon(cfg, false)
662690
require.NoError(tt, err)
663691

@@ -722,6 +750,7 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
722750
endpoint.successPattern,
723751
allowed, expectedErr,
724752
endpointDisabled,
753+
endpoint.disabledPattern,
725754
endpoint.noAuth,
726755
)
727756
})
@@ -1169,7 +1198,8 @@ func runRESTAuthTest(t *testing.T, hostPort, uiPassword, macaroonPath, restURI,
11691198
// through Lightning Node Connect.
11701199
func runLNCAuthTest(t *testing.T, rawLNCConn grpc.ClientConnInterface,
11711200
makeRequest requestFn, successContent string, callAllowed bool,
1172-
expectErrContains string, disabled, noMac bool) {
1201+
expectErrContains string, disabled bool, disabledPattern string,
1202+
noMac bool) {
11731203

11741204
ctxt, cancel := context.WithTimeout(
11751205
context.Background(), defaultTimeout,
@@ -1186,7 +1216,7 @@ func runLNCAuthTest(t *testing.T, rawLNCConn grpc.ClientConnInterface,
11861216
// The call should be allowed, so we expect no error unless this is
11871217
// for a disabled sub-server.
11881218
case disabled:
1189-
require.ErrorContains(t, err, "unknown request")
1219+
require.ErrorContains(t, err, disabledPattern)
11901220
return
11911221

11921222
case noMac:

itest/litd_mode_remote_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
6767
endpoint.requestFn,
6868
endpoint.successPattern,
6969
endpointEnabled,
70-
"unknown request",
70+
endpoint.disabledPattern,
7171
)
7272
})
7373
}
@@ -94,7 +94,7 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
9494
shouldFailWithoutMacaroon,
9595
endpoint.successPattern,
9696
endpointEnabled,
97-
"unknown request",
97+
endpoint.disabledPattern,
9898
)
9999
})
100100
}
@@ -117,7 +117,8 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
117117
ttt, cfg.LitAddr(), cfg.UIPassword,
118118
endpoint.grpcWebURI, withoutUIPassword,
119119
endpointEnabled,
120-
"unknown request", endpoint.noAuth,
120+
endpoint.disabledPattern,
121+
endpoint.noAuth,
121122
)
122123
})
123124
}
@@ -145,7 +146,7 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
145146
endpoint.requestFn,
146147
endpoint.successPattern,
147148
endpointEnabled,
148-
"unknown request",
149+
endpoint.disabledPattern,
149150
)
150151
})
151152
}
@@ -197,7 +198,9 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
197198
endpoint.successPattern,
198199
endpoint.allowedThroughLNC,
199200
"unknown service",
200-
endpointDisabled, endpoint.noAuth,
201+
endpointDisabled,
202+
endpoint.disabledPattern,
203+
endpoint.noAuth,
201204
)
202205
})
203206
}
@@ -248,6 +251,7 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
248251
endpoint.successPattern,
249252
allowed, expectedErr,
250253
endpointDisabled,
254+
endpoint.disabledPattern,
251255
endpoint.noAuth,
252256
)
253257
})
@@ -257,6 +261,12 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
257261
t.Run("gRPC super macaroon account system test", func(tt *testing.T) {
258262
cfg := net.Bob.Cfg
259263

264+
// If the accounts service is disabled, we skip this test as it
265+
// will fail due to the accounts service being disabled.
266+
if subServersDisabled {
267+
return
268+
}
269+
260270
superMacFile, err := bakeSuperMacaroon(cfg, false)
261271
require.NoError(tt, err)
262272

0 commit comments

Comments
 (0)