mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
itest: add custom permissions integration tests
Add a new sub-test case to verify that custom `entity:action` permissions are correctly handled and enforced for LNC custom sessions. The test uses the `info:read` permission to assert that the connection can only query LND's GetInfo endpoint and is blocked on other endpoints. Tests are added for both integrated mode and remote mode suites.
This commit is contained in:
parent
04f06144bd
commit
484d5d789e
2 changed files with 98 additions and 0 deletions
|
|
@ -692,6 +692,55 @@ func integratedTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
|
|||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("lnc auth custom entity action perms", func(tt *testing.T) {
|
||||
cfg := net.Alice.Cfg
|
||||
|
||||
ctx := context.Background()
|
||||
ctxt, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
customPerms := []*litrpc.MacaroonPermission{
|
||||
{
|
||||
Entity: "info",
|
||||
Action: "read",
|
||||
},
|
||||
}
|
||||
|
||||
rawLNCConn := setUpLNCConn(
|
||||
ctxt, t, cfg.LitAddr(), cfg.LitTLSCertPath,
|
||||
cfg.LitMacPath,
|
||||
litrpc.SessionType_TYPE_MACAROON_CUSTOM,
|
||||
customPerms,
|
||||
)
|
||||
defer rawLNCConn.Close()
|
||||
|
||||
for _, endpoint := range endpoints {
|
||||
endpoint := endpoint
|
||||
endpointDisabled := subServersDisabled &&
|
||||
endpoint.canDisable
|
||||
|
||||
expectedErr := "permission denied"
|
||||
if endpoint.noAuth {
|
||||
expectedErr = "unknown service"
|
||||
}
|
||||
|
||||
tt.Run(endpoint.name+" lit port", func(ttt *testing.T) {
|
||||
// Only lnrpc (GetInfo) is allowed, as we
|
||||
// only granted the "info:read" permission.
|
||||
allowed := endpoint.name == "lnrpc"
|
||||
|
||||
runLNCAuthTest(
|
||||
ttt, rawLNCConn, endpoint.requestFn,
|
||||
endpoint.successPattern,
|
||||
allowed, expectedErr,
|
||||
endpointDisabled,
|
||||
endpoint.disabledPattern,
|
||||
endpoint.noAuth,
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func uiPasswordAuthCheck(t *testing.T, cfg *LitNodeConfig, subServersDisabled,
|
||||
|
|
|
|||
|
|
@ -259,6 +259,55 @@ func remoteTestSuite(ctx context.Context, net *NetworkHarness, t *testing.T,
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("lnc auth custom entity action perms", func(tt *testing.T) {
|
||||
cfg := net.Bob.Cfg
|
||||
|
||||
ctx := context.Background()
|
||||
ctxt, cancel := context.WithTimeout(ctx, defaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
customPerms := []*litrpc.MacaroonPermission{
|
||||
{
|
||||
Entity: "info",
|
||||
Action: "read",
|
||||
},
|
||||
}
|
||||
|
||||
rawLNCConn := setUpLNCConn(
|
||||
ctxt, tt, cfg.LitAddr(), cfg.LitTLSCertPath,
|
||||
cfg.LitMacPath,
|
||||
litrpc.SessionType_TYPE_MACAROON_CUSTOM,
|
||||
customPerms,
|
||||
)
|
||||
defer rawLNCConn.Close()
|
||||
|
||||
for _, endpoint := range endpoints {
|
||||
endpoint := endpoint
|
||||
endpointDisabled := subServersDisabled &&
|
||||
endpoint.canDisable
|
||||
|
||||
expectedErr := "permission denied"
|
||||
if endpoint.noAuth {
|
||||
expectedErr = "unknown service"
|
||||
}
|
||||
|
||||
tt.Run(endpoint.name+" lit port", func(ttt *testing.T) {
|
||||
// Only lnrpc (GetInfo) is allowed, as we
|
||||
// only granted the "info:read" permission.
|
||||
allowed := endpoint.name == "lnrpc"
|
||||
|
||||
runLNCAuthTest(
|
||||
ttt, rawLNCConn, endpoint.requestFn,
|
||||
endpoint.successPattern,
|
||||
allowed, expectedErr,
|
||||
endpointDisabled,
|
||||
endpoint.disabledPattern,
|
||||
endpoint.noAuth,
|
||||
)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("gRPC super macaroon account system test", func(tt *testing.T) {
|
||||
cfg := net.Bob.Cfg
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue