From feb8854678f13e64671ec719bacefde04f2db101 Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 23 Jun 2022 14:14:14 +0100 Subject: [PATCH] Add @Inject constructor. --- .../api/mailbox/MailboxProperties.java | 20 ++++++------ .../api/mailbox/MailboxUpdateManager.java | 20 ++++++++++-- .../briarproject/bramble/test/TestUtils.java | 6 ++-- .../bramble/client/ClientHelperImpl.java | 3 +- .../bramble/mailbox/MailboxApiImpl.java | 31 ++++++++++++------- .../bramble/mailbox/MailboxModule.java | 7 ++++- .../mailbox/MailboxPairingTaskImpl.java | 3 +- .../mailbox/MailboxSettingsManagerImpl.java | 2 +- .../mailbox/MailboxUpdateManagerImpl.java | 3 +- .../bramble/mailbox/UrlConverter.java | 17 ++++++++++ .../bramble/mailbox/UrlConverterImpl.java | 18 +++++++++++ .../bramble/mailbox/MailboxApiTest.java | 5 ++- .../mailbox/MailboxIntegrationTest.java | 14 +++++---- .../mailbox/MailboxPairingTaskImplTest.java | 7 ++--- .../MailboxSettingsManagerImplTest.java | 2 +- .../mailbox/MailboxUpdateManagerImplTest.java | 25 +++++++-------- 16 files changed, 122 insertions(+), 61 deletions(-) create mode 100644 bramble-core/src/main/java/org/briarproject/bramble/mailbox/UrlConverter.java create mode 100644 bramble-core/src/main/java/org/briarproject/bramble/mailbox/UrlConverterImpl.java diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/mailbox/MailboxProperties.java b/bramble-api/src/main/java/org/briarproject/bramble/api/mailbox/MailboxProperties.java index 5692c9031..bc9631de2 100644 --- a/bramble-api/src/main/java/org/briarproject/bramble/api/mailbox/MailboxProperties.java +++ b/bramble-api/src/main/java/org/briarproject/bramble/api/mailbox/MailboxProperties.java @@ -11,7 +11,7 @@ import javax.annotation.concurrent.Immutable; @NotNullByDefault public class MailboxProperties { - private final String baseUrl; + private final String onion; private final MailboxAuthToken authToken; private final boolean owner; private final List serverSupports; @@ -23,9 +23,9 @@ public class MailboxProperties { /** * Constructor for properties used by the mailbox's owner. */ - public MailboxProperties(String baseUrl, MailboxAuthToken authToken, + public MailboxProperties(String onion, MailboxAuthToken authToken, List serverSupports) { - this.baseUrl = baseUrl; + this.onion = onion; this.authToken = authToken; this.owner = true; this.serverSupports = serverSupports; @@ -36,10 +36,10 @@ public class MailboxProperties { /** * Constructor for properties used by a contact of the mailbox's owner. */ - public MailboxProperties(String baseUrl, MailboxAuthToken authToken, + public MailboxProperties(String onion, MailboxAuthToken authToken, List serverSupports, MailboxFolderId inboxId, MailboxFolderId outboxId) { - this.baseUrl = baseUrl; + this.onion = onion; this.authToken = authToken; this.owner = false; this.serverSupports = serverSupports; @@ -47,13 +47,11 @@ public class MailboxProperties { this.outboxId = outboxId; } - public String getBaseUrl() { - return baseUrl; - } - + /** + * Returns the onion address of the mailbox, excluding the .onion suffix. + */ public String getOnion() { - return baseUrl.replaceFirst("^http://", "") - .replaceFirst("\\.onion$", ""); + return onion; } public MailboxAuthToken getAuthToken() { diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/mailbox/MailboxUpdateManager.java b/bramble-api/src/main/java/org/briarproject/bramble/api/mailbox/MailboxUpdateManager.java index e9c81237e..7a5cf0e18 100644 --- a/bramble-api/src/main/java/org/briarproject/bramble/api/mailbox/MailboxUpdateManager.java +++ b/bramble-api/src/main/java/org/briarproject/bramble/api/mailbox/MailboxUpdateManager.java @@ -29,19 +29,35 @@ public interface MailboxUpdateManager { /** * The number of properties required for an update message with a mailbox. + *

+ * The required properties are {@link #PROP_KEY_ONION}, + * {@link #PROP_KEY_AUTHTOKEN}, {@link #PROP_KEY_INBOXID} and + * {@link #PROP_KEY_OUTBOXID}. */ int PROP_COUNT = 4; /** - * The required properties of an update message with a mailbox. + * The onion address of the mailbox, excluding the .onion suffix. */ String PROP_KEY_ONION = "onion"; + + /** + * A bearer token for accessing the mailbox (64 hex digits). + */ String PROP_KEY_AUTHTOKEN = "authToken"; + + /** + * A folder ID for downloading messages (64 hex digits). + */ String PROP_KEY_INBOXID = "inboxId"; + + /** + * A folder ID for uploading messages (64 hex digits). + */ String PROP_KEY_OUTBOXID = "outboxId"; /** - * Length of the Onion property. + * Length of the {@link #PROP_KEY_ONION} property. */ int PROP_ONION_LENGTH = 56; diff --git a/bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java b/bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java index 832109779..b9a0d5d56 100644 --- a/bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java +++ b/bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java @@ -230,14 +230,14 @@ public class TestUtils { public static MailboxProperties getMailboxProperties(boolean owner, List serverSupports) { - String baseUrl = "http://" + getRandomString(56) + ".onion"; // TODO + String onion = getRandomString(56); MailboxAuthToken authToken = new MailboxAuthToken(getRandomId()); if (owner) { - return new MailboxProperties(baseUrl, authToken, serverSupports); + return new MailboxProperties(onion, authToken, serverSupports); } MailboxFolderId inboxId = new MailboxFolderId(getRandomId()); MailboxFolderId outboxId = new MailboxFolderId(getRandomId()); - return new MailboxProperties(baseUrl, authToken, serverSupports, + return new MailboxProperties(onion, authToken, serverSupports, inboxId, outboxId); } diff --git a/bramble-core/src/main/java/org/briarproject/bramble/client/ClientHelperImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/client/ClientHelperImpl.java index a13f80fde..c6cbe9efc 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/client/ClientHelperImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/client/ClientHelperImpl.java @@ -456,8 +456,7 @@ class ClientHelperImpl implements ClientHelper { checkLength(inboxId, UniqueId.LENGTH); byte[] outboxId = properties.getRaw(PROP_KEY_OUTBOXID); checkLength(outboxId, UniqueId.LENGTH); - String baseUrl = "http://" + onion + ".onion"; // TODO - MailboxProperties props = new MailboxProperties(baseUrl, + MailboxProperties props = new MailboxProperties(onion, new MailboxAuthToken(authToken), serverSupportsList, new MailboxFolderId(inboxId), new MailboxFolderId(outboxId)); return new MailboxUpdateWithMailbox(clientSupportsList, props); diff --git a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxApiImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxApiImpl.java index d864c7502..06e1306c6 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxApiImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxApiImpl.java @@ -42,18 +42,22 @@ import static org.briarproject.bramble.util.IoUtils.copyAndClose; @NotNullByDefault class MailboxApiImpl implements MailboxApi { - private final WeakSingletonProvider httpClientProvider; - private final JsonMapper mapper = JsonMapper.builder() - .enable(BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES) - .build(); private static final MediaType JSON = requireNonNull(MediaType.parse("application/json; charset=utf-8")); private static final MediaType FILE = requireNonNull(MediaType.parse("application/octet-stream")); + private final WeakSingletonProvider httpClientProvider; + private final JsonMapper mapper = JsonMapper.builder() + .enable(BLOCK_UNSAFE_POLYMORPHIC_BASE_TYPES) + .build(); + private final UrlConverter urlConverter; + @Inject - MailboxApiImpl(WeakSingletonProvider httpClientProvider) { + MailboxApiImpl(WeakSingletonProvider httpClientProvider, + UrlConverter urlConverter) { this.httpClientProvider = httpClientProvider; + this.urlConverter = urlConverter; } @Override @@ -78,7 +82,7 @@ class MailboxApiImpl implements MailboxApi { throws IOException, ApiException { if (!properties.isOwner()) throw new IllegalArgumentException(); Request request = getRequestBuilder(properties.getAuthToken()) - .url(properties.getBaseUrl() + "/setup") + .url(getBaseUrl(properties) + "/setup") .put(EMPTY_REQUEST) .build(); OkHttpClient client = httpClientProvider.get(); @@ -93,7 +97,7 @@ class MailboxApiImpl implements MailboxApi { if (tokenNode == null) { throw new ApiException(); } - return new MailboxProperties(properties.getBaseUrl(), + return new MailboxProperties(properties.getOnion(), MailboxAuthToken.fromString(tokenNode.textValue()), parseServerSupports(node)); } catch (JacksonException | InvalidMailboxIdException e) { @@ -137,7 +141,7 @@ class MailboxApiImpl implements MailboxApi { throws IOException, ApiException { if (!properties.isOwner()) throw new IllegalArgumentException(); Request request = getRequestBuilder(properties.getAuthToken()) - .url(properties.getBaseUrl() + "/") + .url(getBaseUrl(properties) + "/") .delete() .build(); OkHttpClient client = httpClientProvider.get(); @@ -162,7 +166,7 @@ class MailboxApiImpl implements MailboxApi { public void deleteContact(MailboxProperties properties, ContactId contactId) throws IOException, ApiException, TolerableFailureException { if (!properties.isOwner()) throw new IllegalArgumentException(); - String url = properties.getBaseUrl() + "/contacts/" + + String url = getBaseUrl(properties) + "/contacts/" + contactId.getInt(); Request request = getRequestBuilder(properties.getAuthToken()) .delete() @@ -266,7 +270,7 @@ class MailboxApiImpl implements MailboxApi { String path = "/files/" + folderId + "/" + fileId; Request request = getRequestBuilder(properties.getAuthToken()) .delete() - .url(properties.getBaseUrl() + path) + .url(getBaseUrl(properties) + path) .build(); OkHttpClient client = httpClientProvider.get(); Response response = client.newCall(request).execute(); @@ -308,7 +312,7 @@ class MailboxApiImpl implements MailboxApi { private Response sendGetRequest(MailboxProperties properties, String path) throws IOException { Request request = getRequestBuilder(properties.getAuthToken()) - .url(properties.getBaseUrl() + path) + .url(getBaseUrl(properties) + path) .build(); OkHttpClient client = httpClientProvider.get(); return client.newCall(request).execute(); @@ -317,7 +321,7 @@ class MailboxApiImpl implements MailboxApi { private Response sendPostRequest(MailboxProperties properties, String path, RequestBody body) throws IOException { Request request = getRequestBuilder(properties.getAuthToken()) - .url(properties.getBaseUrl() + path) + .url(getBaseUrl(properties) + path) .post(body) .build(); OkHttpClient client = httpClientProvider.get(); @@ -339,4 +343,7 @@ class MailboxApiImpl implements MailboxApi { return (ArrayNode) arrayNode; } + private String getBaseUrl(MailboxProperties properties) { + return urlConverter.convertOnionToBaseUrl(properties.getOnion()); + } } diff --git a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxModule.java b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxModule.java index 3c62ce3a6..73e418ed4 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxModule.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxModule.java @@ -59,7 +59,12 @@ public class MailboxModule { } @Provides - MailboxApi providesMailboxApi(MailboxApiImpl mailboxApi) { + UrlConverter provideUrlConverter(UrlConverterImpl urlConverter) { + return urlConverter; + } + + @Provides + MailboxApi provideMailboxApi(MailboxApiImpl mailboxApi) { return mailboxApi; } diff --git a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxPairingTaskImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxPairingTaskImpl.java index 91f0cd0b0..621e8fa8f 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxPairingTaskImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxPairingTaskImpl.java @@ -177,10 +177,9 @@ class MailboxPairingTaskImpl implements MailboxPairingTask { LOG.info("QR code is valid"); byte[] onionPubKey = Arrays.copyOfRange(bytes, 1, 33); String onion = crypto.encodeOnion(onionPubKey); - String baseUrl = "http://" + onion + ".onion"; // TODO byte[] tokenBytes = Arrays.copyOfRange(bytes, 33, 65); MailboxAuthToken setupToken = new MailboxAuthToken(tokenBytes); - return new MailboxProperties(baseUrl, setupToken, new ArrayList<>()); + return new MailboxProperties(onion, setupToken, new ArrayList<>()); } } diff --git a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxSettingsManagerImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxSettingsManagerImpl.java index 135ff7f29..409750b6f 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxSettingsManagerImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxSettingsManagerImpl.java @@ -74,7 +74,7 @@ class MailboxSettingsManagerImpl implements MailboxSettingsManager { public void setOwnMailboxProperties(Transaction txn, MailboxProperties p) throws DbException { Settings s = new Settings(); - s.put(SETTINGS_KEY_ONION, p.getBaseUrl()); + s.put(SETTINGS_KEY_ONION, p.getOnion()); s.put(SETTINGS_KEY_TOKEN, p.getAuthToken().toString()); List serverSupports = p.getServerSupports(); encodeServerSupports(serverSupports, s); diff --git a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxUpdateManagerImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxUpdateManagerImpl.java index a0794cf94..6a1f95a7b 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxUpdateManagerImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/MailboxUpdateManagerImpl.java @@ -242,8 +242,7 @@ class MailboxUpdateManagerImpl implements MailboxUpdateManager, private void createAndSendUpdateWithMailbox(Transaction txn, Contact c, List serverSupports, String ownOnion) throws DbException { - String baseUrl = "http://" + ownOnion + ".onion"; // TODO - MailboxProperties properties = new MailboxProperties(baseUrl, + MailboxProperties properties = new MailboxProperties(ownOnion, new MailboxAuthToken(crypto.generateUniqueId().getBytes()), serverSupports, new MailboxFolderId(crypto.generateUniqueId().getBytes()), diff --git a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/UrlConverter.java b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/UrlConverter.java new file mode 100644 index 000000000..3be0eae4e --- /dev/null +++ b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/UrlConverter.java @@ -0,0 +1,17 @@ +package org.briarproject.bramble.mailbox; + +import org.briarproject.bramble.api.nullsafety.NotNullByDefault; + +/** + * An interface for converting an onion address to an HTTP URL, allowing the + * conversion to be customised for integration tests. + */ +@NotNullByDefault +interface UrlConverter { + + /** + * Converts a raw onion address, excluding the .onion suffix, into an + * HTTP URL. + */ + String convertOnionToBaseUrl(String onion); +} diff --git a/bramble-core/src/main/java/org/briarproject/bramble/mailbox/UrlConverterImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/UrlConverterImpl.java new file mode 100644 index 000000000..2b293a1a3 --- /dev/null +++ b/bramble-core/src/main/java/org/briarproject/bramble/mailbox/UrlConverterImpl.java @@ -0,0 +1,18 @@ +package org.briarproject.bramble.mailbox; + +import org.briarproject.bramble.api.nullsafety.NotNullByDefault; + +import javax.inject.Inject; + +@NotNullByDefault +class UrlConverterImpl implements UrlConverter { + + @Inject + UrlConverterImpl() { + } + + @Override + public String convertOnionToBaseUrl(String onion) { + return "http://" + onion + ".onion"; + } +} diff --git a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxApiTest.java b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxApiTest.java index cbf5bd851..df921573b 100644 --- a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxApiTest.java +++ b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxApiTest.java @@ -68,7 +68,10 @@ public class MailboxApiTest extends BrambleTestCase { return client; } }; - private final MailboxApiImpl api = new MailboxApiImpl(httpClientProvider); + // We aren't using a real onion address, so use the given address verbatim + private final UrlConverter urlConverter = onion -> onion; + private final MailboxApiImpl api = new MailboxApiImpl(httpClientProvider, + urlConverter); private final MailboxAuthToken token = new MailboxAuthToken(getRandomId()); private final MailboxAuthToken token2 = new MailboxAuthToken(getRandomId()); diff --git a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxIntegrationTest.java b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxIntegrationTest.java index 71ec2198b..21c85131b 100644 --- a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxIntegrationTest.java +++ b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxIntegrationTest.java @@ -49,8 +49,8 @@ public class MailboxIntegrationTest extends BrambleTestCase { @Rule public TemporaryFolder folder = new TemporaryFolder(); - private final static String URL_BASE = "http://127.0.0.1:8000"; - private final static MailboxAuthToken SETUP_TOKEN; + private static final String URL_BASE = "http://127.0.0.1:8000"; + private static final MailboxAuthToken SETUP_TOKEN; static { try { @@ -74,8 +74,10 @@ public class MailboxIntegrationTest extends BrambleTestCase { return client; } }; - private final static MailboxApiImpl api = - new MailboxApiImpl(httpClientProvider); + // We aren't using a real onion address, so use the given address verbatim + private static final UrlConverter urlConverter = onion -> onion; + private static final MailboxApiImpl api = + new MailboxApiImpl(httpClientProvider, urlConverter); // needs to be static to keep values across different tests private static MailboxProperties ownerProperties; @@ -121,7 +123,7 @@ public class MailboxIntegrationTest extends BrambleTestCase { ContactId contactId = new ContactId(1); MailboxContact contact = getMailboxContact(contactId); MailboxProperties contactProperties = new MailboxProperties( - ownerProperties.getBaseUrl(), contact.token, + ownerProperties.getOnion(), contact.token, new ArrayList<>(), contact.inboxId, contact.outboxId); api.addContact(ownerProperties, contact); @@ -167,7 +169,7 @@ public class MailboxIntegrationTest extends BrambleTestCase { ContactId contactId = new ContactId(1); MailboxContact contact = getMailboxContact(contactId); MailboxProperties contactProperties = new MailboxProperties( - ownerProperties.getBaseUrl(), contact.token, + ownerProperties.getOnion(), contact.token, new ArrayList<>(), contact.inboxId, contact.outboxId); api.addContact(ownerProperties, contact); diff --git a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxPairingTaskImplTest.java b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxPairingTaskImplTest.java index abb5e0ddc..5dc7e379c 100644 --- a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxPairingTaskImplTest.java +++ b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxPairingTaskImplTest.java @@ -55,7 +55,6 @@ public class MailboxPairingTaskImplTest extends BrambleMockTestCase { private final String onion = getRandomString(56); private final byte[] onionBytes = getRandomBytes(32); - private final String baseUrl = "http://" + onion + ".onion"; // TODO private final MailboxAuthToken setupToken = new MailboxAuthToken(getRandomId()); private final MailboxAuthToken ownerToken = @@ -63,9 +62,9 @@ public class MailboxPairingTaskImplTest extends BrambleMockTestCase { private final String validPayload = getValidPayload(); private final long time = System.currentTimeMillis(); private final MailboxProperties setupProperties = new MailboxProperties( - baseUrl, setupToken, new ArrayList<>()); + onion, setupToken, new ArrayList<>()); private final MailboxProperties ownerProperties = new MailboxProperties( - baseUrl, ownerToken, new ArrayList<>()); + onion, ownerToken, new ArrayList<>()); @Test public void testInitialQrCodeReceivedState() { @@ -207,7 +206,7 @@ public class MailboxPairingTaskImplTest extends BrambleMockTestCase { private PredicateMatcher matches(MailboxProperties p2) { return new PredicateMatcher<>(MailboxProperties.class, p1 -> p1.getAuthToken().equals(p2.getAuthToken()) && - p1.getBaseUrl().equals(p2.getBaseUrl()) && + p1.getOnion().equals(p2.getOnion()) && p1.isOwner() == p2.isOwner() && p1.getServerSupports().equals(p2.getServerSupports())); } diff --git a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxSettingsManagerImplTest.java b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxSettingsManagerImplTest.java index 8cf7d03e6..4debd8d42 100644 --- a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxSettingsManagerImplTest.java +++ b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxSettingsManagerImplTest.java @@ -84,7 +84,7 @@ public class MailboxSettingsManagerImplTest extends BrambleMockTestCase { MailboxProperties properties = manager.getOwnMailboxProperties(txn); assertNotNull(properties); - assertEquals(onion, properties.getBaseUrl()); + assertEquals(onion, properties.getOnion()); assertEquals(token, properties.getAuthToken()); assertEquals(serverSupports, properties.getServerSupports()); assertTrue(properties.isOwner()); diff --git a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxUpdateManagerImplTest.java b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxUpdateManagerImplTest.java index 4c659d125..9c84a7778 100644 --- a/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxUpdateManagerImplTest.java +++ b/bramble-core/src/test/java/org/briarproject/bramble/mailbox/MailboxUpdateManagerImplTest.java @@ -109,7 +109,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { updateNoMailbox = new MailboxUpdate(someClientSupportsList); updateProps = getMailboxProperties(false, someServerSupportsList); - ownProps = new MailboxProperties(updateProps.getBaseUrl(), + ownProps = new MailboxProperties(updateProps.getOnion(), updateProps.getAuthToken(), someServerSupportsList); updateWithMailbox = new MailboxUpdateWithMailbox(someClientSupportsList, updateProps); @@ -170,7 +170,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(messageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, - emptyServerSupports, emptyPropsDict, true); + emptyServerSupports, emptyPropsDict); oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), sentDict); @@ -225,7 +225,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(messageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, - someServerSupports, propsDict, true); + someServerSupports, propsDict); oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), sentDict); @@ -276,7 +276,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(emptyMessageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, - emptyServerSupports, emptyPropsDict, true); + emptyServerSupports, emptyPropsDict); oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), sentDict); @@ -341,7 +341,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(emptyMessageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, - emptyServerSupports, emptyPropsDict, true); + emptyServerSupports, emptyPropsDict); oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), sentDict); @@ -400,7 +400,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(messageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 2, - newerClientSupports, someServerSupports, propsDict, true); + newerClientSupports, someServerSupports, propsDict); oneOf(db).removeMessage(txn, messageId); oneOf(clientHelper).mergeGroupMetadata(txn, localGroup.getId(), @@ -441,7 +441,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(messageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, - emptyServerSupports, emptyPropsDict, true); + emptyServerSupports, emptyPropsDict); }}); MailboxUpdateManagerImpl t = createInstance(someClientSupportsList); @@ -484,7 +484,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(messageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 1, someClientSupports, - someServerSupports, propsDict, true); + someServerSupports, propsDict); }}); MailboxUpdateManagerImpl t = createInstance(someClientSupportsList); @@ -674,7 +674,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(messageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 2, someClientSupports, - someServerSupports, propsDict, true); + someServerSupports, propsDict); oneOf(db).removeMessage(txn, latestId); }}); @@ -712,7 +712,7 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { contactGroup.getId()); will(returnValue(messageMetadata)); expectStoreMessage(txn, contactGroup.getId(), 2, someClientSupports, - emptyServerSupports, emptyPropsDict, true); + emptyServerSupports, emptyPropsDict); oneOf(db).removeMessage(txn, latestId); }}); @@ -890,15 +890,14 @@ public class MailboxUpdateManagerImplTest extends BrambleMockTestCase { private void expectStoreMessage(Transaction txn, GroupId g, long version, BdfList clientSupports, BdfList serverSupports, - BdfDictionary properties, boolean local) - throws Exception { + BdfDictionary properties) throws Exception { BdfList body = BdfList.of(version, clientSupports, serverSupports, properties); Message message = getMessage(g); long timestamp = message.getTimestamp(); BdfDictionary meta = BdfDictionary.of( new BdfEntry(MSG_KEY_VERSION, version), - new BdfEntry(MSG_KEY_LOCAL, local) + new BdfEntry(MSG_KEY_LOCAL, true) ); context.checking(new Expectations() {{