Skip to content

Commit 014140d

Browse files
committed
itest: add test for Status server endpoint
1 parent cb80489 commit 014140d

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

itest/litd_mode_integrated_test.go

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ var (
200200
litConn := litrpc.NewProxyClient(c)
201201
return litConn.GetInfo(ctx, &litrpc.GetInfoRequest{})
202202
}
203+
statusRequestFn = func(ctx context.Context,
204+
c grpc.ClientConnInterface) (proto.Message, error) {
205+
206+
litConn := litrpc.NewStatusClient(c)
207+
return litConn.SubServerStatus(
208+
ctx, &litrpc.SubServerStatusReq{},
209+
)
210+
}
203211
litMacaroonFn = func(cfg *LitNodeConfig) string {
204212
return cfg.LitMacPath
205213
}
@@ -338,6 +346,16 @@ var (
338346
grpcWebURI: "/litrpc.Proxy/GetInfo",
339347
restWebURI: "/v1/proxy/info",
340348
litOnly: true,
349+
}, {
350+
name: "litrpc-status",
351+
macaroonFn: emptyMacaroonFn,
352+
requestFn: statusRequestFn,
353+
successPattern: "\"sub_servers\":",
354+
allowedThroughLNC: true,
355+
grpcWebURI: "/litrpc.Status/SubServerStatus",
356+
restWebURI: "/v1/status",
357+
noAuth: true,
358+
litOnly: true,
341359
}}
342360

343361
// customURIs is a map of endpoint URIs that we want to allow via a
@@ -691,13 +709,20 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
691709
endpointDisabled := subServersDisabled &&
692710
endpoint.canDisable
693711

712+
expectedErr := "permission denied"
713+
if endpoint.noAuth {
714+
expectedErr = "unknown service"
715+
}
716+
694717
tt.Run(endpoint.name+" lit port", func(ttt *testing.T) {
695718
allowed := customURIs[endpoint.grpcWebURI]
719+
696720
runLNCAuthTest(
697721
ttt, rawLNCConn, endpoint.requestFn,
698722
endpoint.successPattern,
699-
allowed, "permission denied",
700-
endpointDisabled, endpoint.noAuth,
723+
allowed, expectedErr,
724+
endpointDisabled,
725+
endpoint.noAuth,
701726
)
702727
})
703728
}
@@ -817,6 +842,10 @@ func runGRPCAuthTest(t *testing.T, hostPort, tlsCertPath, macPath string,
817842
require.NoError(t, err)
818843
ctxm = macaroonContext(ctxt, macBytes)
819844
resp, err = makeRequest(ctxm, rawConn)
845+
if disabled {
846+
require.ErrorContains(t, err, disabledErr)
847+
return
848+
}
820849
require.NoError(t, err)
821850

822851
json, err := marshalOptions.Marshal(resp)

itest/litd_mode_remote_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,19 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
236236
endpointDisabled := subServersDisabled &&
237237
endpoint.canDisable
238238

239+
expectedErr := "permission denied"
240+
if endpoint.noAuth {
241+
expectedErr = "unknown service"
242+
}
243+
239244
tt.Run(endpoint.name+" lit port", func(ttt *testing.T) {
240245
allowed := customURIs[endpoint.grpcWebURI]
241246
runLNCAuthTest(
242247
ttt, rawLNCConn, endpoint.requestFn,
243248
endpoint.successPattern,
244-
allowed, "permission denied",
245-
endpointDisabled, endpoint.noAuth,
249+
allowed, expectedErr,
250+
endpointDisabled,
251+
endpoint.noAuth,
246252
)
247253
})
248254
}

0 commit comments

Comments
 (0)