From 6b790b59fab6c2063e03a096e83af91d29b0fab6 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 26 May 2022 14:56:51 +0100 Subject: [PATCH] Use status endpoint for connectivity check. --- .../bramble/mailbox/OwnMailboxConnectivityChecker.java | 2 +- .../bramble/mailbox/OwnMailboxConnectivityCheckerTest.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/OwnMailboxConnectivityChecker.java b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/OwnMailboxConnectivityChecker.java index ff2f75869..6abe9e607 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/OwnMailboxConnectivityChecker.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/OwnMailboxConnectivityChecker.java @@ -55,7 +55,7 @@ class OwnMailboxConnectivityChecker extends ConnectivityCheckerImpl { private boolean checkConnectivityAndStoreResult( MailboxProperties properties) throws DbException { try { - mailboxApi.getFolders(properties); + if (!mailboxApi.checkStatus(properties)) throw new ApiException(); LOG.info("Own mailbox is reachable"); long now = clock.currentTimeMillis(); db.transaction(false, txn -> mailboxSettingsManager diff --git a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/OwnMailboxConnectivityCheckerTest.java b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/OwnMailboxConnectivityCheckerTest.java index 2f4678b25..c94d87903 100644 --- a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/OwnMailboxConnectivityCheckerTest.java +++ b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/OwnMailboxConnectivityCheckerTest.java @@ -17,7 +17,6 @@ import org.junit.Test; import java.io.IOException; import java.util.concurrent.atomic.AtomicReference; -import static java.util.Collections.emptyList; import static org.briarproject.bramble.mailbox.MailboxApi.CLIENT_SUPPORTS; import static org.briarproject.bramble.test.TestUtils.getMailboxProperties; import static org.junit.Assert.assertFalse; @@ -63,8 +62,8 @@ public class OwnMailboxConnectivityCheckerTest extends BrambleMockTestCase { // When the check succeeds, the success should be recorded in the DB // and the observer should be called context.checking(new DbExpectations() {{ - oneOf(mailboxApi).getFolders(properties); - will(returnValue(emptyList())); + oneOf(mailboxApi).checkStatus(properties); + will(returnValue(true)); oneOf(clock).currentTimeMillis(); will(returnValue(now)); oneOf(db).transaction(with(false), withDbRunnable(txn)); @@ -98,7 +97,7 @@ public class OwnMailboxConnectivityCheckerTest extends BrambleMockTestCase { // When the check fails, the failure should be recorded in the DB and // the observer should not be called context.checking(new DbExpectations() {{ - oneOf(mailboxApi).getFolders(properties); + oneOf(mailboxApi).checkStatus(properties); will(throwException(new IOException())); oneOf(clock).currentTimeMillis(); will(returnValue(now));