tor+healthcheck: fix healthcheck for multiple services

Fixes #6013.
This commit fixes the Tor healthcheck that would previously fail if
there were multiple hidden service registered.
In the controller, we only need to know that our service is contained in
the list of active services. But we can't do a string equality check
since there might be multiple services, comma separated.
This commit is contained in:
Oliver Gugger committed 2021-11-23 09:53:36 +01:00
1 parent ca0266d31b
commit 5155ebc405
4 files changed
+46 -10

No files matched your search

+24 -1
View File
@@ -61,7 +61,30 @@ func TestCheckOnionServiceFailOnServiceIDNotMatch(t *testing.T) {
require.NoError(t, err, "server failed to write")
// Check the error returned from GetServiceInfo is expected.
require.ErrorIs(t, c.CheckOnionService(), ErrServiceIDUnmatch)
require.ErrorIs(t, c.CheckOnionService(), ErrServiceIDMismatch)
}
func TestCheckOnionServiceSucceedOnMultipleServices(t *testing.T) {
t.Parallel()
// Create mock server and client connection.
proxy := createTestProxy(t)
defer proxy.cleanUp()
server := proxy.serverConn
// Assign a fake service ID to the controller.
c := &Controller{conn: proxy.clientConn, activeServiceID: "fakeID"}
// Mock a response with a different serviceID.
serverResp := "250-onions/current=service1,fakeID,service2\n250 OK\n"
// Let the server mocks a given response.
_, err := server.Write([]byte(serverResp))
require.NoError(t, err, "server failed to write")
// No error is expected, the controller's ID is contained within the
// list of active services.
require.NoError(t, c.CheckOnionService())
}
func TestCheckOnionServiceFailOnClosedConnection(t *testing.T) {