Compare commits
342 Commits
beta-2016-
...
377_replac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cef4c31e0b | ||
|
|
62527a62c1 | ||
|
|
89ab4dd04e | ||
|
|
f3ea731565 | ||
|
|
bf023874f0 | ||
|
|
16ac73d002 | ||
|
|
cc439aa74f | ||
|
|
7a1003178d | ||
|
|
cab667ef6a | ||
|
|
7035d8063c | ||
|
|
2fbbb663a3 | ||
|
|
b4714b5360 | ||
|
|
8a3e5bfb50 | ||
|
|
fd4275733f | ||
|
|
af5b246d7b | ||
|
|
49e9ee2b6d | ||
|
|
1a611d55be | ||
|
|
7c5945de01 | ||
|
|
ccc49df08e | ||
|
|
ac325d4423 | ||
|
|
0a0e1b4280 | ||
|
|
cb64740916 | ||
|
|
73bc86df4a | ||
|
|
307e124ee8 | ||
|
|
60b4c5649a | ||
|
|
e0e46a726e | ||
|
|
668eaf45f6 | ||
|
|
fb9d743d11 | ||
|
|
fc2213c042 | ||
|
|
34f9311f43 | ||
|
|
28fd84b261 | ||
|
|
448bf86379 | ||
|
|
91e529a9e9 | ||
|
|
74f9a0dd73 | ||
|
|
54290bc374 | ||
|
|
3e39ad8a68 | ||
|
|
07445ada41 | ||
|
|
5281d8b468 | ||
|
|
0deac1d1b6 | ||
|
|
387e44d114 | ||
|
|
bb00412187 | ||
|
|
bb0a2a5b32 | ||
|
|
6d7e0aab07 | ||
|
|
da08072409 | ||
|
|
9664aea520 | ||
|
|
636b587b9c | ||
|
|
0afab09fdf | ||
|
|
fe4f71fe0f | ||
|
|
6f0ffa8439 | ||
|
|
69dd399bd2 | ||
|
|
8b7304f4cb | ||
|
|
e023e5d8fc | ||
|
|
042050453a | ||
|
|
1c15e690e1 | ||
|
|
61c05c1dd4 | ||
|
|
d8a9d83caf | ||
|
|
70a44e8a27 | ||
|
|
fc5a7290e3 | ||
|
|
7db0e4472a | ||
|
|
65bdd5558e | ||
|
|
3dd3a18694 | ||
|
|
743fc7dd1f | ||
|
|
eb3da2aac9 | ||
|
|
4518f59a54 | ||
|
|
11c0cb667f | ||
|
|
132a03d0a9 | ||
|
|
c666b0493c | ||
|
|
625276067a | ||
|
|
30f2c192c6 | ||
|
|
55602ed76a | ||
|
|
4ad0df2640 | ||
|
|
d93f59b4ef | ||
|
|
c5f0272621 | ||
|
|
419aa2e97e | ||
|
|
015e45752e | ||
|
|
743053930a | ||
|
|
cc7602e566 | ||
|
|
8b56e082b3 | ||
|
|
b4889fe293 | ||
|
|
ca094620d8 | ||
|
|
83be5c766e | ||
|
|
72fb4e9bc7 | ||
|
|
e10f68b496 | ||
|
|
22e7ec5b27 | ||
|
|
3bccdfa947 | ||
|
|
ef02908082 | ||
|
|
3aa3811d1b | ||
|
|
00240bfa57 | ||
|
|
1f5de42844 | ||
|
|
17f9972a56 | ||
|
|
18dd7d7aa9 | ||
|
|
bc6557e82d | ||
|
|
5f86dd0207 | ||
|
|
659cf85ca1 | ||
|
|
294bc0bdd2 | ||
|
|
be84afc543 | ||
|
|
c6c62cab6c | ||
|
|
d24e18a5d9 | ||
|
|
34a4a3f3c6 | ||
|
|
48e1a65a24 | ||
|
|
28be7d5de3 | ||
|
|
dbdf567d4e | ||
|
|
98337a16ec | ||
|
|
d34afa5f30 | ||
|
|
746fce1b95 | ||
|
|
c3a14d9275 | ||
|
|
e690bcb3cc | ||
|
|
70b311db13 | ||
|
|
caee7fe61b | ||
|
|
84d4bf2205 | ||
|
|
bcf7488afd | ||
|
|
71196e3494 | ||
|
|
9defb099dd | ||
|
|
b3d6e7d12d | ||
|
|
739e8b4511 | ||
|
|
cb9a85eb88 | ||
|
|
7e086d0f4e | ||
|
|
dccc2e6ded | ||
|
|
72906acaee | ||
|
|
6fc7e69849 | ||
|
|
30092550c7 | ||
|
|
b17fbcb135 | ||
|
|
060860bea5 | ||
|
|
f8337d09ae | ||
|
|
4055bbfcd4 | ||
|
|
44d13ef28e | ||
|
|
1ec56fa3ef | ||
|
|
fce104487a | ||
|
|
17db03d40a | ||
|
|
3bbc8dcc4e | ||
|
|
930194accf | ||
|
|
b04bde4f41 | ||
|
|
054a0d467c | ||
|
|
adc85dab7e | ||
|
|
55b7e95d35 | ||
|
|
36d15358a1 | ||
|
|
d15d82ccec | ||
|
|
7be17668c1 | ||
|
|
f8f1c7f0d4 | ||
|
|
dd0d23359b | ||
|
|
1a32458783 | ||
|
|
a4cf91fba5 | ||
|
|
16da3f2cab | ||
|
|
a3b2358164 | ||
|
|
e4f5d8e6e7 | ||
|
|
a69a4028b0 | ||
|
|
a552d1b6a6 | ||
|
|
2f7d188a07 | ||
|
|
4a4366078a | ||
|
|
9a32a13767 | ||
|
|
50d2742cae | ||
|
|
747ed023e4 | ||
|
|
e8c398e996 | ||
|
|
85c9b48196 | ||
|
|
2a2966bd6c | ||
|
|
62c1c3e08d | ||
|
|
6454acdaa5 | ||
|
|
8d1a26ba72 | ||
|
|
e527e30712 | ||
|
|
4af5dbb45b | ||
|
|
7132c88644 | ||
|
|
a452060b41 | ||
|
|
60a381430e | ||
|
|
827fd0aebb | ||
|
|
23eb5acafa | ||
|
|
2170d291a2 | ||
|
|
31cd6e8958 | ||
|
|
a51d2f47af | ||
|
|
0d9cbb2793 | ||
|
|
c17ef86968 | ||
|
|
ff28ae296e | ||
|
|
ce2cb01558 | ||
|
|
d096c1fead | ||
|
|
36dd9c30f8 | ||
|
|
2c993b62c2 | ||
|
|
737f0dac1e | ||
|
|
5a2fd2018f | ||
|
|
15d139afd4 | ||
|
|
2577b2ab2a | ||
|
|
04af39f567 | ||
|
|
64b596d0f9 | ||
|
|
8bbb2184ff | ||
|
|
bca12bb0e5 | ||
|
|
32578e2cab | ||
|
|
0ffbc28792 | ||
|
|
38979ef504 | ||
|
|
5c186db4e4 | ||
|
|
49437522f6 | ||
|
|
6511c13752 | ||
|
|
1bfa1016b4 | ||
|
|
f3d0ffa09f | ||
|
|
d8272d875b | ||
|
|
e782e699fe | ||
|
|
bdb876552d | ||
|
|
e1bdede4f5 | ||
|
|
9ff4758683 | ||
|
|
fa0639d220 | ||
|
|
cf6aa01905 | ||
|
|
3d22d43868 | ||
|
|
bbf12ca0c4 | ||
|
|
04d2ede2e1 | ||
|
|
c47171c06e | ||
|
|
7318aa562e | ||
|
|
ddbac36913 | ||
|
|
c019d8ecf0 | ||
|
|
c12c60d000 | ||
|
|
8504cfa88b | ||
|
|
dd1eed5aa7 | ||
|
|
39d91e026b | ||
|
|
67aa7c3269 | ||
|
|
85f96d8865 | ||
|
|
89469f9d35 | ||
|
|
55601bc2c3 | ||
|
|
9a4bf598ae | ||
|
|
ee68e35b36 | ||
|
|
8f02cf8307 | ||
|
|
193cdc42d9 | ||
|
|
91492c3068 | ||
|
|
412bf162ce | ||
|
|
3a3d717884 | ||
|
|
6301b2a9a2 | ||
|
|
c577efacbe | ||
|
|
fa5304c145 | ||
|
|
f0a784b4af | ||
|
|
b2b97f31f3 | ||
|
|
e9789435cc | ||
|
|
ba86690ce0 | ||
|
|
db2d965006 | ||
|
|
b99650b070 | ||
|
|
bc0b226fff | ||
|
|
3ae3fdab63 | ||
|
|
d8b5710a42 | ||
|
|
fd7278b488 | ||
|
|
e0d2d09bdd | ||
|
|
761525ad85 | ||
|
|
f7d5c1f63c | ||
|
|
365fbb45ad | ||
|
|
d05237d2c1 | ||
|
|
4c4f4ad2d5 | ||
|
|
37a5d884b8 | ||
|
|
759b1c7448 | ||
|
|
57ce7e3f63 | ||
|
|
f84bba5d79 | ||
|
|
bb6e249980 | ||
|
|
d8df9c9955 | ||
|
|
ebe80c773d | ||
|
|
123f59cd96 | ||
|
|
f7965edc71 | ||
|
|
66a1f85859 | ||
|
|
7a9290e3a6 | ||
|
|
f270624f39 | ||
|
|
94927c2f60 | ||
|
|
ecbf5621f2 | ||
|
|
4d3a333915 | ||
|
|
9ac1a13711 | ||
|
|
946d7cb3e7 | ||
|
|
b71a303bf8 | ||
|
|
a9996b4fb1 | ||
|
|
9c2250277b | ||
|
|
4176f592df | ||
|
|
91aa81041e | ||
|
|
a8f51fcb8a | ||
|
|
30fe9f6e2a | ||
|
|
5a9615265e | ||
|
|
59320f02b7 | ||
|
|
3e4be038f2 | ||
|
|
a2a5b746c5 | ||
|
|
08cc5500ef | ||
|
|
ee0c4c07a7 | ||
|
|
ac8c1c0eee | ||
|
|
8a29207bd0 | ||
|
|
192ee41600 | ||
|
|
13e3eec6b3 | ||
|
|
9ae64124d3 | ||
|
|
5df2776dc2 | ||
|
|
19fdf3ffd0 | ||
|
|
e7dce02709 | ||
|
|
f823b8ba4c | ||
|
|
dc048187f5 | ||
|
|
da68ef78f1 | ||
|
|
bbed673150 | ||
|
|
69b0bec033 | ||
|
|
a11e30c2b3 | ||
|
|
c5708ee3ce | ||
|
|
e96838e731 | ||
|
|
6697b06530 | ||
|
|
1bb17a3979 | ||
|
|
9d826631e9 | ||
|
|
b26acdf228 | ||
|
|
69fba1aa17 | ||
|
|
1a1dd80810 | ||
|
|
02f432c04e | ||
|
|
3f838b0472 | ||
|
|
5d06f42000 | ||
|
|
4acb59b22a | ||
|
|
bba7083660 | ||
|
|
e3fc015ec3 | ||
|
|
441fce8500 | ||
|
|
a58fb72ab1 | ||
|
|
86039b81c0 | ||
|
|
661140f623 | ||
|
|
19b6afa69f | ||
|
|
7ac7fae30e | ||
|
|
d3b83a50a6 | ||
|
|
5561532c5d | ||
|
|
b03d0a206b | ||
|
|
512940e82b | ||
|
|
d2ba7c9b7f | ||
|
|
a652f1a5d7 | ||
|
|
21b237a629 | ||
|
|
2a7990f5c4 | ||
|
|
92d3e02c82 | ||
|
|
0d16dd0358 | ||
|
|
3f2b85ac0d | ||
|
|
d0852d2265 | ||
|
|
9149b82cc4 | ||
|
|
b13bf66165 | ||
|
|
8c2fd905a1 | ||
|
|
38a4f73cdc | ||
|
|
1a175beac9 | ||
|
|
7e9ff40837 | ||
|
|
bd01c3732e | ||
|
|
9532a60f43 | ||
|
|
d2722eed92 | ||
|
|
886c8feb34 | ||
|
|
c7f73f9247 | ||
|
|
35156d698f | ||
|
|
1366972449 | ||
|
|
3d25c41e7a | ||
|
|
ba928875df | ||
|
|
cac0f30816 | ||
|
|
aad9f5142b | ||
|
|
9d686e16e0 | ||
|
|
2880043c07 | ||
|
|
fb85345392 | ||
|
|
0b67ec9201 | ||
|
|
fcf21b7ed7 | ||
|
|
6e545d0100 | ||
|
|
69026054cd | ||
|
|
db4b79fcae | ||
|
|
7412ca59ac | ||
|
|
ec083d617e |
6
.idea/codeStyleSettings.xml
generated
@@ -68,6 +68,12 @@
|
|||||||
<XML>
|
<XML>
|
||||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||||
</XML>
|
</XML>
|
||||||
|
<codeStyleSettings language="Groovy">
|
||||||
|
<indentOptions>
|
||||||
|
<option name="USE_TAB_CHARACTER" value="true" />
|
||||||
|
<option name="SMART_TABS" value="true" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
<codeStyleSettings language="JAVA">
|
<codeStyleSettings language="JAVA">
|
||||||
<option name="RIGHT_MARGIN" value="80" />
|
<option name="RIGHT_MARGIN" value="80" />
|
||||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||||
|
|||||||
@@ -1,30 +1,20 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
apply plugin: 'witness'
|
|
||||||
apply plugin: 'com.neenbedankt.android-apt'
|
apply plugin: 'com.neenbedankt.android-apt'
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven { url 'http://repo1.maven.org/maven2' }
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 23
|
compileSdkVersion 23
|
||||||
buildToolsVersion "23.0.3"
|
buildToolsVersion "23.0.3"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 9
|
minSdkVersion 14
|
||||||
targetSdkVersion 22
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../briar-android/proguard-rules.txt'
|
||||||
versionCode 1
|
consumerProguardFiles getDefaultProguardFile('proguard-android.txt'), '../briar-android/proguard-rules.txt'
|
||||||
versionName "1.0"
|
|
||||||
}
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dexOptions {
|
dexOptions {
|
||||||
incremental true
|
incremental true
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_7
|
sourceCompatibility JavaVersion.VERSION_1_7
|
||||||
targetCompatibility JavaVersion.VERSION_1_7
|
targetCompatibility JavaVersion.VERSION_1_7
|
||||||
@@ -32,23 +22,12 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
testCompile project(':briar-api')
|
||||||
compile project(':briar-api')
|
testCompile project(':briar-core')
|
||||||
compile project(':briar-core')
|
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
testCompile 'net.jodah:concurrentunit:0.4.2'
|
testCompile 'net.jodah:concurrentunit:0.4.2'
|
||||||
compile 'com.android.support:appcompat-v7:23.2.1'
|
testCompile 'com.android.support:appcompat-v7:23.2.1'
|
||||||
testApt 'com.google.dagger:dagger-compiler:2.0.2'
|
testApt 'com.google.dagger:dagger-compiler:2.0.2'
|
||||||
provided 'javax.annotation:jsr250-api:1.0'
|
provided 'javax.annotation:jsr250-api:1.0'
|
||||||
testCompile project(':briar-tests')
|
testCompile project(':briar-tests')
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyVerification {
|
|
||||||
verify = [
|
|
||||||
'com.android.support:appcompat-v7:00f9d93acacd6731f309724054bf51492814b4b2869f16d7d5c0038dcb8c9a0d',
|
|
||||||
'com.android.support:support-v4:81ce890f26d35c75ad17d0f998a7e3230330c3b41e0b629566bc744bee89e448',
|
|
||||||
'com.android.support:animated-vector-drawable:06d1963b85aa917099d7757e6a7b3e4dc06889413dc747f625ae8683606db3a1',
|
|
||||||
'com.android.support:support-vector-drawable:799bafe4c3de812386f0b291f744d5d6876452722dd40189b9ab87dbbf594ea1',
|
|
||||||
'com.android.support:support-annotations:786ab0d060774fb95cfdaf4878771e14b85733b1af9d72a4aae762dc7c1dff9f',
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|||||||
17
briar-android-tests/proguard-rules.pro
vendored
@@ -1,17 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# By default, the flags in this file are appended to flags specified
|
|
||||||
# in /home/ernir/dev/sdk/tools/proguard/proguard-android.txt
|
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
|
||||||
# directive in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
@@ -0,0 +1,656 @@
|
|||||||
|
package org.briarproject;
|
||||||
|
|
||||||
|
import net.jodah.concurrentunit.Waiter;
|
||||||
|
|
||||||
|
import org.briarproject.api.blogs.Blog;
|
||||||
|
import org.briarproject.api.blogs.BlogCommentHeader;
|
||||||
|
import org.briarproject.api.blogs.BlogFactory;
|
||||||
|
import org.briarproject.api.blogs.BlogManager;
|
||||||
|
import org.briarproject.api.blogs.BlogPost;
|
||||||
|
import org.briarproject.api.blogs.BlogPostFactory;
|
||||||
|
import org.briarproject.api.blogs.BlogPostHeader;
|
||||||
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
|
import org.briarproject.api.crypto.KeyPair;
|
||||||
|
import org.briarproject.api.crypto.SecretKey;
|
||||||
|
import org.briarproject.api.db.DbException;
|
||||||
|
import org.briarproject.api.event.Event;
|
||||||
|
import org.briarproject.api.event.EventListener;
|
||||||
|
import org.briarproject.api.event.MessageStateChangedEvent;
|
||||||
|
import org.briarproject.api.identity.AuthorFactory;
|
||||||
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
|
import org.briarproject.api.identity.LocalAuthor;
|
||||||
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.sync.SyncSession;
|
||||||
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
|
import org.briarproject.api.system.Clock;
|
||||||
|
import org.briarproject.blogs.BlogsModule;
|
||||||
|
import org.briarproject.contact.ContactModule;
|
||||||
|
import org.briarproject.crypto.CryptoModule;
|
||||||
|
import org.briarproject.lifecycle.LifecycleModule;
|
||||||
|
import org.briarproject.properties.PropertiesModule;
|
||||||
|
import org.briarproject.sync.SyncModule;
|
||||||
|
import org.briarproject.transport.TransportModule;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertFalse;
|
||||||
|
import static org.briarproject.TestPluginsModule.MAX_LATENCY;
|
||||||
|
import static org.briarproject.api.blogs.MessageType.COMMENT;
|
||||||
|
import static org.briarproject.api.blogs.MessageType.POST;
|
||||||
|
import static org.briarproject.api.blogs.MessageType.WRAPPED_COMMENT;
|
||||||
|
import static org.briarproject.api.blogs.MessageType.WRAPPED_POST;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.INVALID;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.PENDING;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class BlogManagerTest {
|
||||||
|
|
||||||
|
private LifecycleManager lifecycleManager0, lifecycleManager1;
|
||||||
|
private SyncSessionFactory sync0, sync1;
|
||||||
|
private BlogManager blogManager0, blogManager1;
|
||||||
|
private ContactManager contactManager0, contactManager1;
|
||||||
|
private ContactId contactId0,contactId1;
|
||||||
|
private IdentityManager identityManager0, identityManager1;
|
||||||
|
private LocalAuthor author0, author1;
|
||||||
|
private Blog blog0, blog1;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Clock clock;
|
||||||
|
@Inject
|
||||||
|
AuthorFactory authorFactory;
|
||||||
|
@Inject
|
||||||
|
CryptoComponent crypto;
|
||||||
|
@Inject
|
||||||
|
BlogFactory blogFactory;
|
||||||
|
@Inject
|
||||||
|
BlogPostFactory blogPostFactory;
|
||||||
|
|
||||||
|
// objects accessed from background threads need to be volatile
|
||||||
|
private volatile Waiter validationWaiter;
|
||||||
|
private volatile Waiter deliveryWaiter;
|
||||||
|
|
||||||
|
private final File testDir = TestUtils.getTestDirectory();
|
||||||
|
private final SecretKey master = TestUtils.getSecretKey();
|
||||||
|
private final int TIMEOUT = 15000;
|
||||||
|
private final String AUTHOR1 = "Author 1";
|
||||||
|
private final String AUTHOR2 = "Author 2";
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
Logger.getLogger(ForumSharingIntegrationTest.class.getName());
|
||||||
|
|
||||||
|
private BlogManagerTestComponent t0, t1;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
BlogManagerTestComponent component =
|
||||||
|
DaggerBlogManagerTestComponent.builder().build();
|
||||||
|
component.inject(this);
|
||||||
|
injectEagerSingletons(component);
|
||||||
|
|
||||||
|
assertTrue(testDir.mkdirs());
|
||||||
|
File t0Dir = new File(testDir, AUTHOR1);
|
||||||
|
t0 = DaggerBlogManagerTestComponent.builder()
|
||||||
|
.testDatabaseModule(new TestDatabaseModule(t0Dir)).build();
|
||||||
|
injectEagerSingletons(t0);
|
||||||
|
File t1Dir = new File(testDir, AUTHOR2);
|
||||||
|
t1 = DaggerBlogManagerTestComponent.builder()
|
||||||
|
.testDatabaseModule(new TestDatabaseModule(t1Dir)).build();
|
||||||
|
injectEagerSingletons(t1);
|
||||||
|
|
||||||
|
identityManager0 = t0.getIdentityManager();
|
||||||
|
identityManager1 = t1.getIdentityManager();
|
||||||
|
contactManager0 = t0.getContactManager();
|
||||||
|
contactManager1 = t1.getContactManager();
|
||||||
|
blogManager0 = t0.getBlogManager();
|
||||||
|
blogManager1 = t1.getBlogManager();
|
||||||
|
sync0 = t0.getSyncSessionFactory();
|
||||||
|
sync1 = t1.getSyncSessionFactory();
|
||||||
|
|
||||||
|
// initialize waiters fresh for each test
|
||||||
|
validationWaiter = new Waiter();
|
||||||
|
deliveryWaiter = new Waiter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPersonalBlogInitialisation() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
Collection<Blog> blogs0 = blogManager0.getBlogs();
|
||||||
|
assertEquals(2, blogs0.size());
|
||||||
|
Iterator<Blog> i0 = blogs0.iterator();
|
||||||
|
assertEquals(author0, i0.next().getAuthor());
|
||||||
|
assertEquals(author1, i0.next().getAuthor());
|
||||||
|
|
||||||
|
Collection<Blog> blogs1 = blogManager1.getBlogs();
|
||||||
|
assertEquals(2, blogs1.size());
|
||||||
|
Iterator<Blog> i1 = blogs1.iterator();
|
||||||
|
assertEquals(author1, i1.next().getAuthor());
|
||||||
|
assertEquals(author0, i1.next().getAuthor());
|
||||||
|
|
||||||
|
assertEquals(blog0, blogManager0.getPersonalBlog(author0));
|
||||||
|
assertEquals(blog0, blogManager1.getPersonalBlog(author0));
|
||||||
|
assertEquals(blog1, blogManager0.getPersonalBlog(author1));
|
||||||
|
assertEquals(blog1, blogManager1.getPersonalBlog(author1));
|
||||||
|
|
||||||
|
assertEquals(blog0, blogManager0.getBlog(blog0.getId()));
|
||||||
|
assertEquals(blog0, blogManager1.getBlog(blog0.getId()));
|
||||||
|
assertEquals(blog1, blogManager0.getBlog(blog1.getId()));
|
||||||
|
assertEquals(blog1, blogManager1.getBlog(blog1.getId()));
|
||||||
|
|
||||||
|
assertEquals(1, blogManager0.getBlogs(author0).size());
|
||||||
|
assertEquals(1, blogManager1.getBlogs(author0).size());
|
||||||
|
assertEquals(1, blogManager0.getBlogs(author1).size());
|
||||||
|
assertEquals(1, blogManager1.getBlogs(author1).size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBlogPost() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// check that blog0 has no posts
|
||||||
|
final String body = TestUtils.getRandomString(42);
|
||||||
|
Collection<BlogPostHeader> headers0 =
|
||||||
|
blogManager0.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(0, headers0.size());
|
||||||
|
|
||||||
|
// add a post to blog0
|
||||||
|
BlogPost p = blogPostFactory
|
||||||
|
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
||||||
|
author0, body);
|
||||||
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
|
// check that post is now in blog0
|
||||||
|
headers0 = blogManager0.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(1, headers0.size());
|
||||||
|
|
||||||
|
// check that body is there
|
||||||
|
assertEquals(body, blogManager0.getPostBody(p.getMessage().getId()));
|
||||||
|
|
||||||
|
// make sure that blog0 at author1 doesn't have the post yet
|
||||||
|
Collection<BlogPostHeader> headers1 =
|
||||||
|
blogManager1.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(0, headers1.size());
|
||||||
|
|
||||||
|
// sync the post over
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// make sure post arrived
|
||||||
|
headers1 = blogManager1.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(1, headers1.size());
|
||||||
|
assertEquals(POST, headers1.iterator().next().getType());
|
||||||
|
|
||||||
|
// check that body is there
|
||||||
|
assertEquals(body, blogManager1.getPostBody(p.getMessage().getId()));
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBlogPostInWrongBlog() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// add a post to blog1
|
||||||
|
final String body = TestUtils.getRandomString(42);
|
||||||
|
BlogPost p = blogPostFactory
|
||||||
|
.createBlogPost(blog1.getId(), clock.currentTimeMillis(), null,
|
||||||
|
author0, body);
|
||||||
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
|
// check that post is now in blog1
|
||||||
|
Collection<BlogPostHeader> headers0 =
|
||||||
|
blogManager0.getPostHeaders(blog1.getId());
|
||||||
|
assertEquals(1, headers0.size());
|
||||||
|
|
||||||
|
// sync the post over
|
||||||
|
sync0To1();
|
||||||
|
validationWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// make sure post did not arrive, because of wrong signature
|
||||||
|
Collection<BlogPostHeader> headers1 =
|
||||||
|
blogManager1.getPostHeaders(blog1.getId());
|
||||||
|
assertEquals(0, headers1.size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddAndRemoveBlog() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
String name = "Test Blog";
|
||||||
|
String desc = "Description";
|
||||||
|
|
||||||
|
// add blog
|
||||||
|
Blog blog = blogManager0.addBlog(author0, name, desc);
|
||||||
|
Collection<Blog> blogs0 = blogManager0.getBlogs();
|
||||||
|
assertEquals(3, blogs0.size());
|
||||||
|
assertTrue(blogs0.contains(blog));
|
||||||
|
assertEquals(2, blogManager0.getBlogs(author0).size());
|
||||||
|
assertTrue(blogManager0.canBeRemoved(blog.getId()));
|
||||||
|
|
||||||
|
// remove blog
|
||||||
|
blogManager0.removeBlog(blog);
|
||||||
|
blogs0 = blogManager0.getBlogs();
|
||||||
|
assertEquals(2, blogs0.size());
|
||||||
|
assertFalse(blogs0.contains(blog));
|
||||||
|
assertEquals(1, blogManager0.getBlogs(author0).size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCanNotRemoveContactsPersonalBlog() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
assertFalse(blogManager0.canBeRemoved(blog1.getId()));
|
||||||
|
assertFalse(blogManager1.canBeRemoved(blog0.getId()));
|
||||||
|
|
||||||
|
// the following two calls should throw a DbException now
|
||||||
|
thrown.expect(DbException.class);
|
||||||
|
|
||||||
|
blogManager0.removeBlog(blog1);
|
||||||
|
blogManager1.removeBlog(blog0);
|
||||||
|
|
||||||
|
// blogs have not been removed
|
||||||
|
assertEquals(2, blogManager0.getBlogs().size());
|
||||||
|
assertEquals(2, blogManager1.getBlogs().size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBlogComment() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// add a post to blog0
|
||||||
|
final String body = TestUtils.getRandomString(42);
|
||||||
|
BlogPost p = blogPostFactory
|
||||||
|
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
||||||
|
author0, body);
|
||||||
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
|
// sync the post over
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// make sure post arrived
|
||||||
|
Collection<BlogPostHeader> headers1 =
|
||||||
|
blogManager1.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(1, headers1.size());
|
||||||
|
assertEquals(POST, headers1.iterator().next().getType());
|
||||||
|
|
||||||
|
// 1 adds a comment to that blog post
|
||||||
|
String comment = "This is a comment on a blog post!";
|
||||||
|
blogManager1
|
||||||
|
.addLocalComment(author1, blog1.getId(), comment,
|
||||||
|
headers1.iterator().next());
|
||||||
|
|
||||||
|
// sync comment over
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 2);
|
||||||
|
|
||||||
|
// make sure comment and wrapped post arrived
|
||||||
|
Collection<BlogPostHeader> headers0 =
|
||||||
|
blogManager0.getPostHeaders(blog1.getId());
|
||||||
|
assertEquals(1, headers0.size());
|
||||||
|
assertEquals(COMMENT, headers0.iterator().next().getType());
|
||||||
|
BlogCommentHeader h = (BlogCommentHeader) headers0.iterator().next();
|
||||||
|
assertEquals(author0, h.getParent().getAuthor());
|
||||||
|
|
||||||
|
// ensure that body can be retrieved from wrapped post
|
||||||
|
assertEquals(body, blogManager0.getPostBody(h.getParentId()));
|
||||||
|
|
||||||
|
// 1 has only their own comment in their blog
|
||||||
|
headers1 = blogManager1.getPostHeaders(blog1.getId());
|
||||||
|
assertEquals(1, headers1.size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBlogCommentOnOwnPost() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// add a post to blog0
|
||||||
|
final String body = TestUtils.getRandomString(42);
|
||||||
|
BlogPost p = blogPostFactory
|
||||||
|
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
||||||
|
author0, body);
|
||||||
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
|
// get header of own post
|
||||||
|
Collection<BlogPostHeader> headers0 =
|
||||||
|
blogManager0.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(1, headers0.size());
|
||||||
|
BlogPostHeader header = headers0.iterator().next();
|
||||||
|
|
||||||
|
// add a comment on own post
|
||||||
|
String comment = "This is a comment on my own blog post!";
|
||||||
|
blogManager0
|
||||||
|
.addLocalComment(author0, blog0.getId(), comment, header);
|
||||||
|
|
||||||
|
// sync the post and comment over
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 2);
|
||||||
|
|
||||||
|
// make sure post arrived
|
||||||
|
Collection<BlogPostHeader> headers1 =
|
||||||
|
blogManager1.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(2, headers1.size());
|
||||||
|
for (BlogPostHeader h : headers1) {
|
||||||
|
if (h.getType() == POST) {
|
||||||
|
assertEquals(body, blogManager1.getPostBody(h.getId()));
|
||||||
|
} else {
|
||||||
|
assertEquals(comment, ((BlogCommentHeader)h).getComment());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCommentOnComment() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// add a post to blog0
|
||||||
|
final String body = TestUtils.getRandomString(42);
|
||||||
|
BlogPost p = blogPostFactory
|
||||||
|
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
||||||
|
author0, body);
|
||||||
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
|
// sync the post over
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// make sure post arrived
|
||||||
|
Collection<BlogPostHeader> headers1 =
|
||||||
|
blogManager1.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(1, headers1.size());
|
||||||
|
assertEquals(POST, headers1.iterator().next().getType());
|
||||||
|
|
||||||
|
// 1 reblogs that blog post
|
||||||
|
blogManager1
|
||||||
|
.addLocalComment(author1, blog1.getId(), null,
|
||||||
|
headers1.iterator().next());
|
||||||
|
|
||||||
|
// sync comment over
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 2);
|
||||||
|
|
||||||
|
// make sure comment and wrapped post arrived
|
||||||
|
Collection<BlogPostHeader> headers0 =
|
||||||
|
blogManager0.getPostHeaders(blog1.getId());
|
||||||
|
assertEquals(1, headers0.size());
|
||||||
|
|
||||||
|
// get header of comment
|
||||||
|
BlogPostHeader cHeader = headers0.iterator().next();
|
||||||
|
assertEquals(COMMENT, cHeader.getType());
|
||||||
|
|
||||||
|
// comment on the comment
|
||||||
|
String comment = "This is a comment on a reblogged post.";
|
||||||
|
blogManager0
|
||||||
|
.addLocalComment(author0, blog0.getId(), comment, cHeader);
|
||||||
|
|
||||||
|
// sync comment over
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 3);
|
||||||
|
|
||||||
|
// check that comment arrived
|
||||||
|
headers1 =
|
||||||
|
blogManager1.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(2, headers1.size());
|
||||||
|
|
||||||
|
// get header of comment
|
||||||
|
cHeader = null;
|
||||||
|
for (BlogPostHeader h : headers1) {
|
||||||
|
if (h.getType() == COMMENT) {
|
||||||
|
cHeader = h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(cHeader != null);
|
||||||
|
|
||||||
|
// another comment on the comment
|
||||||
|
String comment2 = "This is a comment on a comment.";
|
||||||
|
blogManager1.addLocalComment(author1, blog1.getId(), comment2, cHeader);
|
||||||
|
|
||||||
|
// sync comment over
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 4);
|
||||||
|
|
||||||
|
// make sure new comment arrived
|
||||||
|
headers0 =
|
||||||
|
blogManager0.getPostHeaders(blog1.getId());
|
||||||
|
assertEquals(2, headers0.size());
|
||||||
|
boolean satisfied = false;
|
||||||
|
for (BlogPostHeader h : headers0) {
|
||||||
|
assertEquals(COMMENT, h.getType());
|
||||||
|
BlogCommentHeader c = (BlogCommentHeader) h;
|
||||||
|
if (c.getComment() != null && c.getComment().equals(comment2)) {
|
||||||
|
assertEquals(author0, c.getParent().getAuthor());
|
||||||
|
assertEquals(WRAPPED_COMMENT, c.getParent().getType());
|
||||||
|
assertEquals(comment,
|
||||||
|
((BlogCommentHeader) c.getParent()).getComment());
|
||||||
|
assertEquals(WRAPPED_COMMENT,
|
||||||
|
((BlogCommentHeader) c.getParent()).getParent()
|
||||||
|
.getType());
|
||||||
|
assertEquals(WRAPPED_POST,
|
||||||
|
((BlogCommentHeader) ((BlogCommentHeader) c
|
||||||
|
.getParent()).getParent()).getParent()
|
||||||
|
.getType());
|
||||||
|
satisfied = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(satisfied);
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCommentOnOwnComment() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// add a post to blog0
|
||||||
|
final String body = TestUtils.getRandomString(42);
|
||||||
|
BlogPost p = blogPostFactory
|
||||||
|
.createBlogPost(blog0.getId(), clock.currentTimeMillis(), null,
|
||||||
|
author0, body);
|
||||||
|
blogManager0.addLocalPost(p);
|
||||||
|
|
||||||
|
// sync the post over
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// make sure post arrived
|
||||||
|
Collection<BlogPostHeader> headers1 =
|
||||||
|
blogManager1.getPostHeaders(blog0.getId());
|
||||||
|
assertEquals(1, headers1.size());
|
||||||
|
assertEquals(POST, headers1.iterator().next().getType());
|
||||||
|
|
||||||
|
// 1 reblogs that blog post with a comment
|
||||||
|
String comment = "This is a comment on a post.";
|
||||||
|
blogManager1
|
||||||
|
.addLocalComment(author1, blog1.getId(), comment,
|
||||||
|
headers1.iterator().next());
|
||||||
|
|
||||||
|
// get comment from own blog
|
||||||
|
headers1 = blogManager1.getPostHeaders(blog1.getId());
|
||||||
|
assertEquals(1, headers1.size());
|
||||||
|
assertEquals(COMMENT, headers1.iterator().next().getType());
|
||||||
|
BlogCommentHeader ch = (BlogCommentHeader) headers1.iterator().next();
|
||||||
|
assertEquals(comment, ch.getComment());
|
||||||
|
|
||||||
|
comment = "This is a comment on a post with a comment.";
|
||||||
|
blogManager1.addLocalComment(author1, blog1.getId(), comment, ch);
|
||||||
|
|
||||||
|
// sync both comments over (2 comments + 1 wrapped post)
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 3);
|
||||||
|
|
||||||
|
// make sure both comments arrived
|
||||||
|
Collection<BlogPostHeader> headers0 =
|
||||||
|
blogManager0.getPostHeaders(blog1.getId());
|
||||||
|
assertEquals(2, headers0.size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
TestUtils.deleteTestDirectory(testDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Listener implements EventListener {
|
||||||
|
@Override
|
||||||
|
public void eventOccurred(Event e) {
|
||||||
|
if (e instanceof MessageStateChangedEvent) {
|
||||||
|
MessageStateChangedEvent event = (MessageStateChangedEvent) e;
|
||||||
|
if (!event.isLocal()) {
|
||||||
|
if (event.getState() == DELIVERED) {
|
||||||
|
deliveryWaiter.resume();
|
||||||
|
} else if (event.getState() == INVALID ||
|
||||||
|
event.getState() == PENDING) {
|
||||||
|
validationWaiter.resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void defaultInit() throws DbException {
|
||||||
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
listenToEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDefaultIdentities() throws DbException {
|
||||||
|
KeyPair keyPair0 = crypto.generateSignatureKeyPair();
|
||||||
|
byte[] publicKey0 = keyPair0.getPublic().getEncoded();
|
||||||
|
byte[] privateKey0 = keyPair0.getPrivate().getEncoded();
|
||||||
|
author0 = authorFactory
|
||||||
|
.createLocalAuthor(AUTHOR1, publicKey0, privateKey0);
|
||||||
|
identityManager0.addLocalAuthor(author0);
|
||||||
|
blog0 = blogFactory.createPersonalBlog(author0);
|
||||||
|
|
||||||
|
KeyPair keyPair1 = crypto.generateSignatureKeyPair();
|
||||||
|
byte[] publicKey1 = keyPair1.getPublic().getEncoded();
|
||||||
|
byte[] privateKey1 = keyPair1.getPrivate().getEncoded();
|
||||||
|
author1 = authorFactory
|
||||||
|
.createLocalAuthor(AUTHOR2, publicKey1, privateKey1);
|
||||||
|
identityManager1.addLocalAuthor(author1);
|
||||||
|
blog1 = blogFactory.createPersonalBlog(author1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDefaultContacts() throws DbException {
|
||||||
|
// sharer adds invitee as contact
|
||||||
|
contactId1 = contactManager0.addContact(author1,
|
||||||
|
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
// invitee adds sharer back
|
||||||
|
contactId0 = contactManager1.addContact(author0,
|
||||||
|
author1.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void listenToEvents() {
|
||||||
|
Listener listener0 = new Listener();
|
||||||
|
t0.getEventBus().addListener(listener0);
|
||||||
|
Listener listener1 = new Listener();
|
||||||
|
t1.getEventBus().addListener(listener1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sync0To1() throws IOException, TimeoutException {
|
||||||
|
deliverMessage(sync0, contactId0, sync1, contactId1, "0 to 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sync1To0() throws IOException, TimeoutException {
|
||||||
|
deliverMessage(sync1, contactId1, sync0, contactId0, "1 to 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
||||||
|
SyncSessionFactory toSync, ContactId toId, String debug)
|
||||||
|
throws IOException, TimeoutException {
|
||||||
|
|
||||||
|
if (debug != null) LOG.info("TEST: Sending message from " + debug);
|
||||||
|
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
// Create an outgoing sync session
|
||||||
|
SyncSession sessionFrom =
|
||||||
|
fromSync.createSimplexOutgoingSession(toId, MAX_LATENCY, out);
|
||||||
|
// Write whatever needs to be written
|
||||||
|
sessionFrom.run();
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||||
|
// Create an incoming sync session
|
||||||
|
SyncSession sessionTo = toSync.createIncomingSession(fromId, in);
|
||||||
|
// Read whatever needs to be read
|
||||||
|
sessionTo.run();
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startLifecycles() throws InterruptedException {
|
||||||
|
// Start the lifecycle manager and wait for it to finish
|
||||||
|
lifecycleManager0 = t0.getLifecycleManager();
|
||||||
|
lifecycleManager1 = t1.getLifecycleManager();
|
||||||
|
lifecycleManager0.startServices();
|
||||||
|
lifecycleManager1.startServices();
|
||||||
|
lifecycleManager0.waitForStartup();
|
||||||
|
lifecycleManager1.waitForStartup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopLifecycles() throws InterruptedException {
|
||||||
|
// Clean up
|
||||||
|
lifecycleManager0.stopServices();
|
||||||
|
lifecycleManager1.stopServices();
|
||||||
|
lifecycleManager0.waitForShutdown();
|
||||||
|
lifecycleManager1.waitForShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectEagerSingletons(BlogManagerTestComponent component) {
|
||||||
|
component.inject(new LifecycleModule.EagerSingletons());
|
||||||
|
component.inject(new BlogsModule.EagerSingletons());
|
||||||
|
component.inject(new CryptoModule.EagerSingletons());
|
||||||
|
component.inject(new ContactModule.EagerSingletons());
|
||||||
|
component.inject(new TransportModule.EagerSingletons());
|
||||||
|
component.inject(new SyncModule.EagerSingletons());
|
||||||
|
component.inject(new PropertiesModule.EagerSingletons());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package org.briarproject;
|
||||||
|
|
||||||
|
import org.briarproject.api.blogs.BlogManager;
|
||||||
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.event.EventBus;
|
||||||
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
|
import org.briarproject.blogs.BlogsModule;
|
||||||
|
import org.briarproject.clients.ClientsModule;
|
||||||
|
import org.briarproject.contact.ContactModule;
|
||||||
|
import org.briarproject.crypto.CryptoModule;
|
||||||
|
import org.briarproject.data.DataModule;
|
||||||
|
import org.briarproject.db.DatabaseModule;
|
||||||
|
import org.briarproject.event.EventModule;
|
||||||
|
import org.briarproject.identity.IdentityModule;
|
||||||
|
import org.briarproject.lifecycle.LifecycleModule;
|
||||||
|
import org.briarproject.properties.PropertiesModule;
|
||||||
|
import org.briarproject.sharing.SharingModule;
|
||||||
|
import org.briarproject.sync.SyncModule;
|
||||||
|
import org.briarproject.system.SystemModule;
|
||||||
|
import org.briarproject.transport.TransportModule;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Component;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Component(modules = {
|
||||||
|
TestDatabaseModule.class,
|
||||||
|
TestPluginsModule.class,
|
||||||
|
TestSeedProviderModule.class,
|
||||||
|
ClientsModule.class,
|
||||||
|
ContactModule.class,
|
||||||
|
CryptoModule.class,
|
||||||
|
DataModule.class,
|
||||||
|
DatabaseModule.class,
|
||||||
|
EventModule.class,
|
||||||
|
BlogsModule.class,
|
||||||
|
IdentityModule.class,
|
||||||
|
LifecycleModule.class,
|
||||||
|
PropertiesModule.class,
|
||||||
|
SharingModule.class,
|
||||||
|
SyncModule.class,
|
||||||
|
SystemModule.class,
|
||||||
|
TransportModule.class
|
||||||
|
})
|
||||||
|
interface BlogManagerTestComponent {
|
||||||
|
|
||||||
|
void inject(BlogManagerTest testCase);
|
||||||
|
|
||||||
|
void inject(ContactModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(CryptoModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(BlogsModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(LifecycleModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(PropertiesModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(SyncModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(TransportModule.EagerSingletons init);
|
||||||
|
|
||||||
|
LifecycleManager getLifecycleManager();
|
||||||
|
|
||||||
|
EventBus getEventBus();
|
||||||
|
|
||||||
|
IdentityManager getIdentityManager();
|
||||||
|
|
||||||
|
ContactManager getContactManager();
|
||||||
|
|
||||||
|
BlogManager getBlogManager();
|
||||||
|
|
||||||
|
SyncSessionFactory getSyncSessionFactory();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,744 @@
|
|||||||
|
package org.briarproject;
|
||||||
|
|
||||||
|
import net.jodah.concurrentunit.Waiter;
|
||||||
|
|
||||||
|
import org.briarproject.api.blogs.Blog;
|
||||||
|
import org.briarproject.api.blogs.BlogInvitationRequest;
|
||||||
|
import org.briarproject.api.blogs.BlogInvitationResponse;
|
||||||
|
import org.briarproject.api.blogs.BlogManager;
|
||||||
|
import org.briarproject.api.blogs.BlogPostFactory;
|
||||||
|
import org.briarproject.api.blogs.BlogSharingManager;
|
||||||
|
import org.briarproject.api.contact.Contact;
|
||||||
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
|
import org.briarproject.api.crypto.KeyPair;
|
||||||
|
import org.briarproject.api.crypto.SecretKey;
|
||||||
|
import org.briarproject.api.db.DbException;
|
||||||
|
import org.briarproject.api.event.BlogInvitationReceivedEvent;
|
||||||
|
import org.briarproject.api.event.BlogInvitationResponseReceivedEvent;
|
||||||
|
import org.briarproject.api.event.Event;
|
||||||
|
import org.briarproject.api.event.EventListener;
|
||||||
|
import org.briarproject.api.event.MessageStateChangedEvent;
|
||||||
|
import org.briarproject.api.identity.AuthorFactory;
|
||||||
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
|
import org.briarproject.api.identity.LocalAuthor;
|
||||||
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.sharing.InvitationMessage;
|
||||||
|
import org.briarproject.api.sync.SyncSession;
|
||||||
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
|
import org.briarproject.api.sync.ValidationManager.State;
|
||||||
|
import org.briarproject.api.system.Clock;
|
||||||
|
import org.briarproject.blogs.BlogsModule;
|
||||||
|
import org.briarproject.contact.ContactModule;
|
||||||
|
import org.briarproject.crypto.CryptoModule;
|
||||||
|
import org.briarproject.lifecycle.LifecycleModule;
|
||||||
|
import org.briarproject.properties.PropertiesModule;
|
||||||
|
import org.briarproject.sharing.SharingModule;
|
||||||
|
import org.briarproject.sync.SyncModule;
|
||||||
|
import org.briarproject.transport.TransportModule;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static org.briarproject.TestPluginsModule.MAX_LATENCY;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.INVALID;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class BlogSharingIntegrationTest extends BriarTestCase {
|
||||||
|
|
||||||
|
private LifecycleManager lifecycleManager0, lifecycleManager1,
|
||||||
|
lifecycleManager2;
|
||||||
|
private SyncSessionFactory sync0, sync1, sync2;
|
||||||
|
private BlogManager blogManager0, blogManager1, blogManager2;
|
||||||
|
private ContactManager contactManager0, contactManager1, contactManager2;
|
||||||
|
private Contact contact1, contact2, contact01, contact02;
|
||||||
|
private ContactId contactId1, contactId2, contactId01, contactId02;
|
||||||
|
private IdentityManager identityManager0, identityManager1,
|
||||||
|
identityManager2;
|
||||||
|
private LocalAuthor author0, author1, author2;
|
||||||
|
private Blog blog0, blog1, blog2;
|
||||||
|
private SharerListener listener0, listener2;
|
||||||
|
private InviteeListener listener1;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Clock clock;
|
||||||
|
@Inject
|
||||||
|
AuthorFactory authorFactory;
|
||||||
|
@Inject
|
||||||
|
BlogPostFactory blogPostFactory;
|
||||||
|
@Inject
|
||||||
|
CryptoComponent cryptoComponent;
|
||||||
|
|
||||||
|
// objects accessed from background threads need to be volatile
|
||||||
|
private volatile BlogSharingManager blogSharingManager0;
|
||||||
|
private volatile BlogSharingManager blogSharingManager1;
|
||||||
|
private volatile BlogSharingManager blogSharingManager2;
|
||||||
|
private volatile Waiter eventWaiter;
|
||||||
|
private volatile Waiter msgWaiter;
|
||||||
|
|
||||||
|
private final File testDir = TestUtils.getTestDirectory();
|
||||||
|
private final SecretKey master = TestUtils.getSecretKey();
|
||||||
|
private final int TIMEOUT = 15000;
|
||||||
|
private final String SHARER = "Sharer";
|
||||||
|
private final String INVITEE = "Invitee";
|
||||||
|
private final String CONTACT2 = "Contact2";
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
Logger.getLogger(BlogSharingIntegrationTest.class.getName());
|
||||||
|
|
||||||
|
private BlogSharingIntegrationTestComponent t0, t1, t2;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
BlogSharingIntegrationTestComponent component =
|
||||||
|
DaggerBlogSharingIntegrationTestComponent.builder().build();
|
||||||
|
component.inject(this);
|
||||||
|
injectEagerSingletons(component);
|
||||||
|
|
||||||
|
assertTrue(testDir.mkdirs());
|
||||||
|
File t0Dir = new File(testDir, SHARER);
|
||||||
|
t0 = DaggerBlogSharingIntegrationTestComponent.builder()
|
||||||
|
.testDatabaseModule(new TestDatabaseModule(t0Dir)).build();
|
||||||
|
injectEagerSingletons(t0);
|
||||||
|
File t1Dir = new File(testDir, INVITEE);
|
||||||
|
t1 = DaggerBlogSharingIntegrationTestComponent.builder()
|
||||||
|
.testDatabaseModule(new TestDatabaseModule(t1Dir)).build();
|
||||||
|
injectEagerSingletons(t1);
|
||||||
|
File t2Dir = new File(testDir, CONTACT2);
|
||||||
|
t2 = DaggerBlogSharingIntegrationTestComponent.builder()
|
||||||
|
.testDatabaseModule(new TestDatabaseModule(t2Dir)).build();
|
||||||
|
injectEagerSingletons(t2);
|
||||||
|
|
||||||
|
identityManager0 = t0.getIdentityManager();
|
||||||
|
identityManager1 = t1.getIdentityManager();
|
||||||
|
identityManager2 = t2.getIdentityManager();
|
||||||
|
contactManager0 = t0.getContactManager();
|
||||||
|
contactManager1 = t1.getContactManager();
|
||||||
|
contactManager2 = t2.getContactManager();
|
||||||
|
blogManager0 = t0.getBlogManager();
|
||||||
|
blogManager1 = t1.getBlogManager();
|
||||||
|
blogManager2 = t2.getBlogManager();
|
||||||
|
blogSharingManager0 = t0.getBlogSharingManager();
|
||||||
|
blogSharingManager1 = t1.getBlogSharingManager();
|
||||||
|
blogSharingManager2 = t2.getBlogSharingManager();
|
||||||
|
sync0 = t0.getSyncSessionFactory();
|
||||||
|
sync1 = t1.getSyncSessionFactory();
|
||||||
|
sync2 = t2.getSyncSessionFactory();
|
||||||
|
|
||||||
|
// initialize waiters fresh for each test
|
||||||
|
eventWaiter = new Waiter();
|
||||||
|
msgWaiter = new Waiter();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPersonalBlogCannotBeSharedWithOwner() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit(true);
|
||||||
|
|
||||||
|
assertFalse(blogSharingManager0.canBeShared(blog1.getId(), contact1));
|
||||||
|
assertFalse(blogSharingManager0.canBeShared(blog2.getId(), contact2));
|
||||||
|
assertFalse(blogSharingManager1.canBeShared(blog0.getId(), contact01));
|
||||||
|
assertFalse(blogSharingManager2.canBeShared(blog0.getId(), contact02));
|
||||||
|
|
||||||
|
// create invitation
|
||||||
|
blogSharingManager0
|
||||||
|
.sendInvitation(blog1.getId(), contactId1, "Hi!");
|
||||||
|
|
||||||
|
// sync invitation
|
||||||
|
sync0To1();
|
||||||
|
// make sure the invitee ignored the request for their own blog
|
||||||
|
assertFalse(listener1.requestReceived);
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSuccessfulSharing() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
|
||||||
|
// initialize and let invitee accept all requests
|
||||||
|
defaultInit(true);
|
||||||
|
|
||||||
|
// send invitation
|
||||||
|
blogSharingManager0
|
||||||
|
.sendInvitation(blog2.getId(), contactId1, "Hi!");
|
||||||
|
|
||||||
|
// invitee has own blog and that of the sharer
|
||||||
|
assertEquals(2, blogManager1.getBlogs().size());
|
||||||
|
|
||||||
|
// sync first request message
|
||||||
|
sync0To1();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
|
// sync response back
|
||||||
|
sync1To0();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener0.responseReceived);
|
||||||
|
|
||||||
|
// blog was added successfully
|
||||||
|
assertEquals(0, blogSharingManager0.getInvitations().size());
|
||||||
|
assertEquals(3, blogManager1.getBlogs().size());
|
||||||
|
|
||||||
|
// invitee has one invitation message from sharer
|
||||||
|
List<InvitationMessage> list =
|
||||||
|
new ArrayList<>(blogSharingManager1
|
||||||
|
.getInvitationMessages(contactId01));
|
||||||
|
assertEquals(2, list.size());
|
||||||
|
// check other things are alright with the message
|
||||||
|
for (InvitationMessage m : list) {
|
||||||
|
if (m instanceof BlogInvitationRequest) {
|
||||||
|
BlogInvitationRequest invitation =
|
||||||
|
(BlogInvitationRequest) m;
|
||||||
|
assertFalse(invitation.isAvailable());
|
||||||
|
assertEquals(blog2.getAuthor().getName(),
|
||||||
|
invitation.getBlogAuthorName());
|
||||||
|
assertEquals(contactId1, invitation.getContactId());
|
||||||
|
assertEquals("Hi!", invitation.getMessage());
|
||||||
|
} else {
|
||||||
|
BlogInvitationResponse response =
|
||||||
|
(BlogInvitationResponse) m;
|
||||||
|
assertEquals(contactId01, response.getContactId());
|
||||||
|
assertTrue(response.wasAccepted());
|
||||||
|
assertTrue(response.isLocal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// sharer has own invitation message and response
|
||||||
|
assertEquals(2,
|
||||||
|
blogSharingManager0.getInvitationMessages(contactId1)
|
||||||
|
.size());
|
||||||
|
// blog can not be shared again
|
||||||
|
assertFalse(blogSharingManager0.canBeShared(blog2.getId(), contact1));
|
||||||
|
assertFalse(blogSharingManager1.canBeShared(blog2.getId(), contact01));
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeclinedSharing() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
|
||||||
|
// initialize and let invitee deny all requests
|
||||||
|
defaultInit(false);
|
||||||
|
|
||||||
|
// send invitation
|
||||||
|
blogSharingManager0
|
||||||
|
.sendInvitation(blog2.getId(), contactId1, null);
|
||||||
|
|
||||||
|
// sync first request message
|
||||||
|
sync0To1();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
|
// sync response back
|
||||||
|
sync1To0();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener0.responseReceived);
|
||||||
|
|
||||||
|
// blog was not added
|
||||||
|
assertEquals(0, blogSharingManager0.getInvitations().size());
|
||||||
|
assertEquals(2, blogManager1.getBlogs().size());
|
||||||
|
// blog is no longer available to invitee who declined
|
||||||
|
assertEquals(0, blogSharingManager1.getInvitations().size());
|
||||||
|
|
||||||
|
// invitee has one invitation message from sharer and one response
|
||||||
|
List<InvitationMessage> list =
|
||||||
|
new ArrayList<>(blogSharingManager1
|
||||||
|
.getInvitationMessages(contactId01));
|
||||||
|
assertEquals(2, list.size());
|
||||||
|
// check things are alright with the message
|
||||||
|
for (InvitationMessage m : list) {
|
||||||
|
if (m instanceof BlogInvitationRequest) {
|
||||||
|
BlogInvitationRequest invitation =
|
||||||
|
(BlogInvitationRequest) m;
|
||||||
|
assertFalse(invitation.isAvailable());
|
||||||
|
assertEquals(blog2.getAuthor().getName(),
|
||||||
|
invitation.getBlogAuthorName());
|
||||||
|
assertEquals(contactId1, invitation.getContactId());
|
||||||
|
assertEquals(null, invitation.getMessage());
|
||||||
|
} else {
|
||||||
|
BlogInvitationResponse response =
|
||||||
|
(BlogInvitationResponse) m;
|
||||||
|
assertEquals(contactId01, response.getContactId());
|
||||||
|
assertFalse(response.wasAccepted());
|
||||||
|
assertTrue(response.isLocal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// sharer has own invitation message and response
|
||||||
|
assertEquals(2,
|
||||||
|
blogSharingManager0.getInvitationMessages(contactId1)
|
||||||
|
.size());
|
||||||
|
// blog can be shared again
|
||||||
|
assertTrue(blogSharingManager0.canBeShared(blog2.getId(), contact1));
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInviteeLeavesAfterFinished() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
|
||||||
|
// initialize and let invitee accept all requests
|
||||||
|
defaultInit(true);
|
||||||
|
|
||||||
|
// send invitation
|
||||||
|
blogSharingManager0
|
||||||
|
.sendInvitation(blog2.getId(), contactId1, "Hi!");
|
||||||
|
|
||||||
|
// sync first request message
|
||||||
|
sync0To1();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
|
// sync response back
|
||||||
|
sync1To0();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener0.responseReceived);
|
||||||
|
|
||||||
|
// blog was added successfully
|
||||||
|
assertEquals(0, blogSharingManager0.getInvitations().size());
|
||||||
|
assertEquals(3, blogManager1.getBlogs().size());
|
||||||
|
assertTrue(blogManager1.getBlogs().contains(blog2));
|
||||||
|
|
||||||
|
// sharer shares blog with invitee
|
||||||
|
assertTrue(blogSharingManager0.getSharedWith(blog2.getId())
|
||||||
|
.contains(contact1));
|
||||||
|
// invitee gets blog shared by sharer
|
||||||
|
assertTrue(blogSharingManager1.getSharedBy(blog2.getId())
|
||||||
|
.contains(contact01));
|
||||||
|
|
||||||
|
// invitee un-subscribes from blog
|
||||||
|
blogManager1.removeBlog(blog2);
|
||||||
|
|
||||||
|
// send leave message to sharer
|
||||||
|
sync1To0();
|
||||||
|
|
||||||
|
// blog is gone
|
||||||
|
assertEquals(0, blogSharingManager0.getInvitations().size());
|
||||||
|
assertEquals(2, blogManager1.getBlogs().size());
|
||||||
|
|
||||||
|
// sharer no longer shares blog with invitee
|
||||||
|
assertFalse(blogSharingManager0.getSharedWith(blog2.getId())
|
||||||
|
.contains(contact1));
|
||||||
|
// invitee no longer gets blog shared by sharer
|
||||||
|
assertFalse(blogSharingManager1.getSharedBy(blog2.getId())
|
||||||
|
.contains(contact01));
|
||||||
|
// blog can be shared again
|
||||||
|
assertTrue(blogSharingManager0.canBeShared(blog2.getId(), contact1));
|
||||||
|
assertTrue(blogSharingManager1.canBeShared(blog2.getId(), contact01));
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInvitationForExistingBlog() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
|
||||||
|
// initialize and let invitee accept all requests
|
||||||
|
defaultInit(true);
|
||||||
|
|
||||||
|
// 1 and 2 are adding each other
|
||||||
|
contactManager1.addContact(author2,
|
||||||
|
author1.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
contactManager2.addContact(author1,
|
||||||
|
author2.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
assertEquals(3, blogManager1.getBlogs().size());
|
||||||
|
|
||||||
|
// sharer sends invitation for 2's blog to 1
|
||||||
|
blogSharingManager0
|
||||||
|
.sendInvitation(blog2.getId(), contactId1, "Hi!");
|
||||||
|
|
||||||
|
// sync first request message
|
||||||
|
sync0To1();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
|
// make sure blog2 is shared by 0
|
||||||
|
Collection<Contact> contacts =
|
||||||
|
blogSharingManager1.getSharedBy(blog2.getId());
|
||||||
|
assertEquals(1, contacts.size());
|
||||||
|
assertTrue(contacts.contains(contact01));
|
||||||
|
|
||||||
|
// make sure 1 knows that they have blog2 already
|
||||||
|
Collection<InvitationMessage> messages =
|
||||||
|
blogSharingManager1.getInvitationMessages(contactId01);
|
||||||
|
assertEquals(2, messages.size());
|
||||||
|
assertEquals(blog2, blogManager1.getBlog(blog2.getId()));
|
||||||
|
|
||||||
|
// sync response back
|
||||||
|
sync1To0();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener0.responseReceived);
|
||||||
|
|
||||||
|
// blog was not added, because it was there already
|
||||||
|
assertEquals(0, blogSharingManager0.getInvitations().size());
|
||||||
|
assertEquals(3, blogManager1.getBlogs().size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRemovingSharedBlog() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
|
||||||
|
// initialize and let invitee accept all requests
|
||||||
|
defaultInit(true);
|
||||||
|
|
||||||
|
// send invitation
|
||||||
|
blogSharingManager0
|
||||||
|
.sendInvitation(blog2.getId(), contactId1, "Hi!");
|
||||||
|
|
||||||
|
// sync first request message
|
||||||
|
sync0To1();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
|
// sync response back
|
||||||
|
sync1To0();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener0.responseReceived);
|
||||||
|
|
||||||
|
// blog was added successfully and is shared both ways
|
||||||
|
assertEquals(3, blogManager1.getBlogs().size());
|
||||||
|
Collection<Contact> sharedWith =
|
||||||
|
blogSharingManager0.getSharedWith(blog2.getId());
|
||||||
|
assertEquals(1, sharedWith.size());
|
||||||
|
assertEquals(contact1, sharedWith.iterator().next());
|
||||||
|
Collection<Contact> sharedBy =
|
||||||
|
blogSharingManager1.getSharedBy(blog2.getId());
|
||||||
|
assertEquals(1, sharedBy.size());
|
||||||
|
assertEquals(contact01, sharedBy.iterator().next());
|
||||||
|
|
||||||
|
// shared blog can be removed
|
||||||
|
assertTrue(blogManager1.canBeRemoved(blog2.getId()));
|
||||||
|
|
||||||
|
// invitee removes blog again
|
||||||
|
blogManager1.removeBlog(blog2);
|
||||||
|
|
||||||
|
// sync LEAVE message
|
||||||
|
sync1To0();
|
||||||
|
|
||||||
|
// sharer does not share this blog anymore with invitee
|
||||||
|
sharedWith =
|
||||||
|
blogSharingManager0.getSharedWith(blog2.getId());
|
||||||
|
assertEquals(0, sharedWith.size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSharedBlogBecomesPermanent() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
|
||||||
|
// initialize and let invitee accept all requests
|
||||||
|
defaultInit(true);
|
||||||
|
|
||||||
|
// invitee only sees two blogs
|
||||||
|
assertEquals(2, blogManager1.getBlogs().size());
|
||||||
|
|
||||||
|
// sharer sends invitation for 2's blog to 1
|
||||||
|
blogSharingManager0
|
||||||
|
.sendInvitation(blog2.getId(), contactId1, "Hi!");
|
||||||
|
|
||||||
|
// sync first request message
|
||||||
|
sync0To1();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
|
// make sure blog2 is shared by 0
|
||||||
|
Collection<Contact> contacts =
|
||||||
|
blogSharingManager1.getSharedBy(blog2.getId());
|
||||||
|
assertEquals(1, contacts.size());
|
||||||
|
assertTrue(contacts.contains(contact01));
|
||||||
|
|
||||||
|
// sync response back
|
||||||
|
sync1To0();
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener0.responseReceived);
|
||||||
|
|
||||||
|
// blog was added and can be removed
|
||||||
|
assertEquals(3, blogManager1.getBlogs().size());
|
||||||
|
assertTrue(blogManager1.canBeRemoved(blog2.getId()));
|
||||||
|
|
||||||
|
// 1 and 2 are adding each other
|
||||||
|
contactManager1.addContact(author2,
|
||||||
|
author1.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
contactManager2.addContact(author1,
|
||||||
|
author2.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
assertEquals(3, blogManager1.getBlogs().size());
|
||||||
|
|
||||||
|
// now blog can not be removed anymore
|
||||||
|
assertFalse(blogManager1.canBeRemoved(blog2.getId()));
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() throws InterruptedException {
|
||||||
|
TestUtils.deleteTestDirectory(testDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SharerListener implements EventListener {
|
||||||
|
|
||||||
|
volatile boolean requestReceived = false;
|
||||||
|
volatile boolean responseReceived = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void eventOccurred(Event e) {
|
||||||
|
if (e instanceof MessageStateChangedEvent) {
|
||||||
|
MessageStateChangedEvent event = (MessageStateChangedEvent) e;
|
||||||
|
State s = event.getState();
|
||||||
|
if ((s == DELIVERED || s == INVALID) && !event.isLocal()) {
|
||||||
|
LOG.info("TEST: Sharer received message");
|
||||||
|
msgWaiter.resume();
|
||||||
|
}
|
||||||
|
} else if (e instanceof BlogInvitationResponseReceivedEvent) {
|
||||||
|
BlogInvitationResponseReceivedEvent event =
|
||||||
|
(BlogInvitationResponseReceivedEvent) e;
|
||||||
|
eventWaiter.assertEquals(contactId1, event.getContactId());
|
||||||
|
responseReceived = true;
|
||||||
|
eventWaiter.resume();
|
||||||
|
}
|
||||||
|
// this is only needed for tests where a blog is re-shared
|
||||||
|
else if (e instanceof BlogInvitationReceivedEvent) {
|
||||||
|
BlogInvitationReceivedEvent event =
|
||||||
|
(BlogInvitationReceivedEvent) e;
|
||||||
|
eventWaiter.assertEquals(contactId1, event.getContactId());
|
||||||
|
requestReceived = true;
|
||||||
|
Blog b = event.getBlog();
|
||||||
|
try {
|
||||||
|
Contact c = contactManager0.getContact(contactId1);
|
||||||
|
blogSharingManager0.respondToInvitation(b, c, true);
|
||||||
|
} catch (DbException ex) {
|
||||||
|
eventWaiter.rethrow(ex);
|
||||||
|
} finally {
|
||||||
|
eventWaiter.resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class InviteeListener implements EventListener {
|
||||||
|
|
||||||
|
volatile boolean requestReceived = false;
|
||||||
|
volatile boolean responseReceived = false;
|
||||||
|
|
||||||
|
private final boolean accept, answer;
|
||||||
|
|
||||||
|
InviteeListener(boolean accept, boolean answer) {
|
||||||
|
this.accept = accept;
|
||||||
|
this.answer = answer;
|
||||||
|
}
|
||||||
|
|
||||||
|
InviteeListener(boolean accept) {
|
||||||
|
this(accept, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void eventOccurred(Event e) {
|
||||||
|
if (e instanceof MessageStateChangedEvent) {
|
||||||
|
MessageStateChangedEvent event = (MessageStateChangedEvent) e;
|
||||||
|
State s = event.getState();
|
||||||
|
if ((s == DELIVERED || s == INVALID) && !event.isLocal()) {
|
||||||
|
LOG.info("TEST: Invitee received message");
|
||||||
|
msgWaiter.resume();
|
||||||
|
}
|
||||||
|
} else if (e instanceof BlogInvitationReceivedEvent) {
|
||||||
|
BlogInvitationReceivedEvent event =
|
||||||
|
(BlogInvitationReceivedEvent) e;
|
||||||
|
requestReceived = true;
|
||||||
|
if (!answer) return;
|
||||||
|
Blog b = event.getBlog();
|
||||||
|
try {
|
||||||
|
eventWaiter.assertEquals(1,
|
||||||
|
blogSharingManager1.getInvitations().size());
|
||||||
|
Contact c =
|
||||||
|
contactManager1.getContact(event.getContactId());
|
||||||
|
blogSharingManager1.respondToInvitation(b, c, accept);
|
||||||
|
} catch (DbException ex) {
|
||||||
|
eventWaiter.rethrow(ex);
|
||||||
|
} finally {
|
||||||
|
eventWaiter.resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// this is only needed for tests where a blog is re-shared
|
||||||
|
else if (e instanceof BlogInvitationResponseReceivedEvent) {
|
||||||
|
BlogInvitationResponseReceivedEvent event =
|
||||||
|
(BlogInvitationResponseReceivedEvent) e;
|
||||||
|
eventWaiter.assertEquals(contactId01, event.getContactId());
|
||||||
|
responseReceived = true;
|
||||||
|
eventWaiter.resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startLifecycles() throws InterruptedException {
|
||||||
|
// Start the lifecycle manager and wait for it to finish
|
||||||
|
lifecycleManager0 = t0.getLifecycleManager();
|
||||||
|
lifecycleManager1 = t1.getLifecycleManager();
|
||||||
|
lifecycleManager2 = t2.getLifecycleManager();
|
||||||
|
lifecycleManager0.startServices();
|
||||||
|
lifecycleManager1.startServices();
|
||||||
|
lifecycleManager2.startServices();
|
||||||
|
lifecycleManager0.waitForStartup();
|
||||||
|
lifecycleManager1.waitForStartup();
|
||||||
|
lifecycleManager2.waitForStartup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopLifecycles() throws InterruptedException {
|
||||||
|
// Clean up
|
||||||
|
lifecycleManager0.stopServices();
|
||||||
|
lifecycleManager1.stopServices();
|
||||||
|
lifecycleManager2.stopServices();
|
||||||
|
lifecycleManager0.waitForShutdown();
|
||||||
|
lifecycleManager1.waitForShutdown();
|
||||||
|
lifecycleManager2.waitForShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void defaultInit(boolean accept) throws DbException {
|
||||||
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
getPersonalBlogOfSharer();
|
||||||
|
listenToEvents(accept);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDefaultIdentities() throws DbException {
|
||||||
|
KeyPair keyPair = cryptoComponent.generateSignatureKeyPair();
|
||||||
|
author0 = authorFactory.createLocalAuthor(SHARER,
|
||||||
|
keyPair.getPublic().getEncoded(),
|
||||||
|
keyPair.getPrivate().getEncoded());
|
||||||
|
identityManager0.addLocalAuthor(author0);
|
||||||
|
|
||||||
|
keyPair = cryptoComponent.generateSignatureKeyPair();
|
||||||
|
author1 = authorFactory.createLocalAuthor(INVITEE,
|
||||||
|
keyPair.getPublic().getEncoded(),
|
||||||
|
keyPair.getPrivate().getEncoded());
|
||||||
|
identityManager1.addLocalAuthor(author1);
|
||||||
|
|
||||||
|
keyPair = cryptoComponent.generateSignatureKeyPair();
|
||||||
|
author2 = authorFactory.createLocalAuthor(CONTACT2,
|
||||||
|
keyPair.getPublic().getEncoded(),
|
||||||
|
keyPair.getPrivate().getEncoded());
|
||||||
|
identityManager2.addLocalAuthor(author2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDefaultContacts() throws DbException {
|
||||||
|
// sharer adds invitee as contact
|
||||||
|
contactId1 = contactManager0.addContact(author1,
|
||||||
|
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
contact1 = contactManager0.getContact(contactId1);
|
||||||
|
// sharer adds second contact
|
||||||
|
contactId2 = contactManager0.addContact(author2,
|
||||||
|
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
contact2 = contactManager0.getContact(contactId2);
|
||||||
|
// contacts add sharer back
|
||||||
|
contactId01 = contactManager1.addContact(author0,
|
||||||
|
author1.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
contact01 = contactManager1.getContact(contactId01);
|
||||||
|
contactId02 = contactManager2.addContact(author0,
|
||||||
|
author2.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
contact02 = contactManager2.getContact(contactId02);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void getPersonalBlogOfSharer() throws DbException {
|
||||||
|
blog0 = blogManager0.getPersonalBlog(author0);
|
||||||
|
blog1 = blogManager0.getPersonalBlog(author1);
|
||||||
|
blog2 = blogManager0.getPersonalBlog(author2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void listenToEvents(boolean accept) {
|
||||||
|
listener0 = new SharerListener();
|
||||||
|
t0.getEventBus().addListener(listener0);
|
||||||
|
listener1 = new InviteeListener(accept);
|
||||||
|
t1.getEventBus().addListener(listener1);
|
||||||
|
listener2 = new SharerListener();
|
||||||
|
t2.getEventBus().addListener(listener2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sync0To1() throws IOException, TimeoutException {
|
||||||
|
deliverMessage(sync0, contactId01, sync1, contactId1,
|
||||||
|
"Sharer to Invitee");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sync1To0() throws IOException, TimeoutException {
|
||||||
|
deliverMessage(sync1, contactId1, sync0, contactId01,
|
||||||
|
"Invitee to Sharer");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
||||||
|
SyncSessionFactory toSync, ContactId toId, String debug)
|
||||||
|
throws IOException, TimeoutException {
|
||||||
|
|
||||||
|
if (debug != null) LOG.info("TEST: Sending message from " + debug);
|
||||||
|
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
// Create an outgoing sync session
|
||||||
|
SyncSession sessionFrom =
|
||||||
|
fromSync.createSimplexOutgoingSession(toId, MAX_LATENCY, out);
|
||||||
|
// Write whatever needs to be written
|
||||||
|
sessionFrom.run();
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||||
|
// Create an incoming sync session
|
||||||
|
SyncSession sessionTo = toSync.createIncomingSession(fromId, in);
|
||||||
|
// Read whatever needs to be read
|
||||||
|
sessionTo.run();
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
// wait for message to actually arrive
|
||||||
|
msgWaiter.await(TIMEOUT, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectEagerSingletons(
|
||||||
|
BlogSharingIntegrationTestComponent component) {
|
||||||
|
|
||||||
|
component.inject(new LifecycleModule.EagerSingletons());
|
||||||
|
component.inject(new BlogsModule.EagerSingletons());
|
||||||
|
component.inject(new CryptoModule.EagerSingletons());
|
||||||
|
component.inject(new ContactModule.EagerSingletons());
|
||||||
|
component.inject(new TransportModule.EagerSingletons());
|
||||||
|
component.inject(new SharingModule.EagerSingletons());
|
||||||
|
component.inject(new SyncModule.EagerSingletons());
|
||||||
|
component.inject(new PropertiesModule.EagerSingletons());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
package org.briarproject;
|
||||||
|
|
||||||
|
import org.briarproject.api.blogs.BlogManager;
|
||||||
|
import org.briarproject.api.blogs.BlogSharingManager;
|
||||||
|
import org.briarproject.api.clients.ClientHelper;
|
||||||
|
import org.briarproject.api.clients.MessageQueueManager;
|
||||||
|
import org.briarproject.api.clients.PrivateGroupFactory;
|
||||||
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.db.DatabaseComponent;
|
||||||
|
import org.briarproject.api.event.EventBus;
|
||||||
|
import org.briarproject.api.forum.ForumManager;
|
||||||
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
|
import org.briarproject.blogs.BlogsModule;
|
||||||
|
import org.briarproject.clients.ClientsModule;
|
||||||
|
import org.briarproject.contact.ContactModule;
|
||||||
|
import org.briarproject.crypto.CryptoModule;
|
||||||
|
import org.briarproject.data.DataModule;
|
||||||
|
import org.briarproject.db.DatabaseModule;
|
||||||
|
import org.briarproject.event.EventModule;
|
||||||
|
import org.briarproject.forum.ForumModule;
|
||||||
|
import org.briarproject.identity.IdentityModule;
|
||||||
|
import org.briarproject.lifecycle.LifecycleModule;
|
||||||
|
import org.briarproject.properties.PropertiesModule;
|
||||||
|
import org.briarproject.sharing.SharingModule;
|
||||||
|
import org.briarproject.sync.SyncModule;
|
||||||
|
import org.briarproject.system.SystemModule;
|
||||||
|
import org.briarproject.transport.TransportModule;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Component;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Component(modules = {
|
||||||
|
TestDatabaseModule.class,
|
||||||
|
TestPluginsModule.class,
|
||||||
|
TestSeedProviderModule.class,
|
||||||
|
ClientsModule.class,
|
||||||
|
ContactModule.class,
|
||||||
|
CryptoModule.class,
|
||||||
|
DataModule.class,
|
||||||
|
DatabaseModule.class,
|
||||||
|
EventModule.class,
|
||||||
|
BlogsModule.class,
|
||||||
|
ForumModule.class,
|
||||||
|
IdentityModule.class,
|
||||||
|
LifecycleModule.class,
|
||||||
|
PropertiesModule.class,
|
||||||
|
SharingModule.class,
|
||||||
|
SyncModule.class,
|
||||||
|
SystemModule.class,
|
||||||
|
TransportModule.class
|
||||||
|
})
|
||||||
|
interface BlogSharingIntegrationTestComponent {
|
||||||
|
|
||||||
|
void inject(BlogSharingIntegrationTest testCase);
|
||||||
|
|
||||||
|
void inject(ContactModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(CryptoModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(BlogsModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(LifecycleModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(PropertiesModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(SharingModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(SyncModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(TransportModule.EagerSingletons init);
|
||||||
|
|
||||||
|
LifecycleManager getLifecycleManager();
|
||||||
|
|
||||||
|
EventBus getEventBus();
|
||||||
|
|
||||||
|
IdentityManager getIdentityManager();
|
||||||
|
|
||||||
|
ContactManager getContactManager();
|
||||||
|
|
||||||
|
BlogSharingManager getBlogSharingManager();
|
||||||
|
|
||||||
|
BlogManager getBlogManager();
|
||||||
|
|
||||||
|
SyncSessionFactory getSyncSessionFactory();
|
||||||
|
|
||||||
|
/* the following methods are only needed to manually construct messages */
|
||||||
|
|
||||||
|
DatabaseComponent getDatabaseComponent();
|
||||||
|
|
||||||
|
PrivateGroupFactory getPrivateGroupFactory();
|
||||||
|
|
||||||
|
ClientHelper getClientHelper();
|
||||||
|
|
||||||
|
MessageQueueManager getMessageQueueManager();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,446 @@
|
|||||||
|
package org.briarproject;
|
||||||
|
|
||||||
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import net.jodah.concurrentunit.Waiter;
|
||||||
|
|
||||||
|
import org.briarproject.api.contact.Contact;
|
||||||
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.crypto.SecretKey;
|
||||||
|
import org.briarproject.api.db.DbException;
|
||||||
|
import org.briarproject.api.event.Event;
|
||||||
|
import org.briarproject.api.event.EventListener;
|
||||||
|
import org.briarproject.api.event.MessageStateChangedEvent;
|
||||||
|
import org.briarproject.api.forum.Forum;
|
||||||
|
import org.briarproject.api.forum.ForumManager;
|
||||||
|
import org.briarproject.api.forum.ForumPost;
|
||||||
|
import org.briarproject.api.forum.ForumPostFactory;
|
||||||
|
import org.briarproject.api.forum.ForumPostHeader;
|
||||||
|
import org.briarproject.api.forum.ForumSharingManager;
|
||||||
|
import org.briarproject.api.identity.AuthorFactory;
|
||||||
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
|
import org.briarproject.api.identity.LocalAuthor;
|
||||||
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
import org.briarproject.api.sync.SyncSession;
|
||||||
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
|
import org.briarproject.api.system.Clock;
|
||||||
|
import org.briarproject.contact.ContactModule;
|
||||||
|
import org.briarproject.crypto.CryptoModule;
|
||||||
|
import org.briarproject.forum.ForumModule;
|
||||||
|
import org.briarproject.lifecycle.LifecycleModule;
|
||||||
|
import org.briarproject.properties.PropertiesModule;
|
||||||
|
import org.briarproject.sharing.SharingModule;
|
||||||
|
import org.briarproject.sync.SyncModule;
|
||||||
|
import org.briarproject.transport.TransportModule;
|
||||||
|
import org.briarproject.util.StringUtils;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
import static junit.framework.Assert.assertNull;
|
||||||
|
import static junit.framework.TestCase.assertFalse;
|
||||||
|
import static org.briarproject.TestPluginsModule.MAX_LATENCY;
|
||||||
|
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.INVALID;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.PENDING;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class ForumManagerTest {
|
||||||
|
|
||||||
|
private LifecycleManager lifecycleManager0, lifecycleManager1;
|
||||||
|
private SyncSessionFactory sync0, sync1;
|
||||||
|
private ForumManager forumManager0, forumManager1;
|
||||||
|
private ContactManager contactManager0, contactManager1;
|
||||||
|
private ContactId contactId0,contactId1;
|
||||||
|
private IdentityManager identityManager0, identityManager1;
|
||||||
|
private LocalAuthor author0, author1;
|
||||||
|
private Forum forum0;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
Clock clock;
|
||||||
|
@Inject
|
||||||
|
AuthorFactory authorFactory;
|
||||||
|
@Inject
|
||||||
|
ForumPostFactory forumPostFactory;
|
||||||
|
|
||||||
|
// objects accessed from background threads need to be volatile
|
||||||
|
private volatile ForumSharingManager forumSharingManager0;
|
||||||
|
private volatile ForumSharingManager forumSharingManager1;
|
||||||
|
private volatile Waiter validationWaiter;
|
||||||
|
private volatile Waiter deliveryWaiter;
|
||||||
|
|
||||||
|
private final File testDir = TestUtils.getTestDirectory();
|
||||||
|
private final SecretKey master = TestUtils.getSecretKey();
|
||||||
|
private final int TIMEOUT = 15000;
|
||||||
|
private final String SHARER = "Sharer";
|
||||||
|
private final String INVITEE = "Invitee";
|
||||||
|
|
||||||
|
private static final Logger LOG =
|
||||||
|
Logger.getLogger(ForumSharingIntegrationTest.class.getName());
|
||||||
|
|
||||||
|
private ForumManagerTestComponent t0, t1;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
ForumManagerTestComponent component =
|
||||||
|
DaggerForumManagerTestComponent.builder().build();
|
||||||
|
component.inject(this);
|
||||||
|
injectEagerSingletons(component);
|
||||||
|
|
||||||
|
assertTrue(testDir.mkdirs());
|
||||||
|
File t0Dir = new File(testDir, SHARER);
|
||||||
|
t0 = DaggerForumManagerTestComponent.builder()
|
||||||
|
.testDatabaseModule(new TestDatabaseModule(t0Dir)).build();
|
||||||
|
injectEagerSingletons(t0);
|
||||||
|
File t1Dir = new File(testDir, INVITEE);
|
||||||
|
t1 = DaggerForumManagerTestComponent.builder()
|
||||||
|
.testDatabaseModule(new TestDatabaseModule(t1Dir)).build();
|
||||||
|
injectEagerSingletons(t1);
|
||||||
|
|
||||||
|
identityManager0 = t0.getIdentityManager();
|
||||||
|
identityManager1 = t1.getIdentityManager();
|
||||||
|
contactManager0 = t0.getContactManager();
|
||||||
|
contactManager1 = t1.getContactManager();
|
||||||
|
forumManager0 = t0.getForumManager();
|
||||||
|
forumManager1 = t1.getForumManager();
|
||||||
|
forumSharingManager0 = t0.getForumSharingManager();
|
||||||
|
forumSharingManager1 = t1.getForumSharingManager();
|
||||||
|
sync0 = t0.getSyncSessionFactory();
|
||||||
|
sync1 = t1.getSyncSessionFactory();
|
||||||
|
|
||||||
|
// initialize waiters fresh for each test
|
||||||
|
validationWaiter = new Waiter();
|
||||||
|
deliveryWaiter = new Waiter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ForumPost createForumPost(GroupId groupId, ForumPost parent,
|
||||||
|
String body, long ms) throws Exception {
|
||||||
|
return forumPostFactory.createAnonymousPost(groupId, ms,
|
||||||
|
parent == null ? null : parent.getMessage().getId(),
|
||||||
|
"text/plain", StringUtils.toUtf8(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testForumPost() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
Forum forum = forumManager0.addForum("TestForum");
|
||||||
|
assertEquals(1, forumManager0.getForums().size());
|
||||||
|
final long ms1 = clock.currentTimeMillis() - 1000L;
|
||||||
|
final String body1 = "some forum text";
|
||||||
|
final long ms2 = clock.currentTimeMillis();
|
||||||
|
final String body2 = "some other forum text";
|
||||||
|
ForumPost post1 =
|
||||||
|
createForumPost(forum.getGroup().getId(), null, body1, ms1);
|
||||||
|
assertEquals(ms1, post1.getMessage().getTimestamp());
|
||||||
|
ForumPost post2 =
|
||||||
|
createForumPost(forum.getGroup().getId(), post1, body2, ms2);
|
||||||
|
assertEquals(ms2, post2.getMessage().getTimestamp());
|
||||||
|
forumManager0.addLocalPost(post1);
|
||||||
|
forumManager0.setReadFlag(post1.getMessage().getId(), true);
|
||||||
|
forumManager0.addLocalPost(post2);
|
||||||
|
forumManager0.setReadFlag(post2.getMessage().getId(), false);
|
||||||
|
Collection<ForumPostHeader> headers =
|
||||||
|
forumManager0.getPostHeaders(forum.getGroup().getId());
|
||||||
|
assertEquals(2, headers.size());
|
||||||
|
for (ForumPostHeader h : headers) {
|
||||||
|
final String hBody =
|
||||||
|
StringUtils.fromUtf8(forumManager0.getPostBody(h.getId()));
|
||||||
|
|
||||||
|
boolean isPost1 = h.getId().equals(post1.getMessage().getId());
|
||||||
|
boolean isPost2 = h.getId().equals(post2.getMessage().getId());
|
||||||
|
Assert.assertTrue(isPost1 || isPost2);
|
||||||
|
if (isPost1) {
|
||||||
|
assertEquals(h.getTimestamp(), ms1);
|
||||||
|
assertEquals(body1, hBody);
|
||||||
|
assertNull(h.getParentId());
|
||||||
|
assertTrue(h.isRead());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
assertEquals(h.getTimestamp(), ms2);
|
||||||
|
assertEquals(body2, hBody);
|
||||||
|
assertEquals(h.getParentId(), post2.getParent());
|
||||||
|
assertFalse(h.isRead());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
forumManager0.removeForum(forum);
|
||||||
|
assertEquals(0, forumManager0.getForums().size());
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testForumPostDelivery() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// share forum
|
||||||
|
GroupId g = forum0.getId();
|
||||||
|
forumSharingManager0.sendInvitation(g, contactId1, null);
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
Contact c0 = contactManager1.getContact(contactId0);
|
||||||
|
forumSharingManager1.respondToInvitation(forum0, c0, true);
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// add one forum post
|
||||||
|
long time = clock.currentTimeMillis();
|
||||||
|
ForumPost post1 = createForumPost(g, null, "a", time);
|
||||||
|
forumManager0.addLocalPost(post1);
|
||||||
|
assertEquals(1, forumManager0.getPostHeaders(g).size());
|
||||||
|
assertEquals(0, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
// send post to 1
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
assertEquals(1, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
// add another forum post
|
||||||
|
time = clock.currentTimeMillis();
|
||||||
|
ForumPost post2 = createForumPost(g, null, "b", time);
|
||||||
|
forumManager1.addLocalPost(post2);
|
||||||
|
assertEquals(1, forumManager0.getPostHeaders(g).size());
|
||||||
|
assertEquals(2, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
// send post to 0
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
assertEquals(2, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testForumPostDeliveredAfterParent() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// share forum
|
||||||
|
GroupId g = forum0.getId();
|
||||||
|
forumSharingManager0.sendInvitation(g, contactId1, null);
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
Contact c0 = contactManager1.getContact(contactId0);
|
||||||
|
forumSharingManager1.respondToInvitation(forum0, c0, true);
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// add one forum post without the parent
|
||||||
|
long time = clock.currentTimeMillis();
|
||||||
|
ForumPost post1 = createForumPost(g, null, "a", time);
|
||||||
|
ForumPost post2 = createForumPost(g, post1, "a", time);
|
||||||
|
forumManager0.addLocalPost(post2);
|
||||||
|
assertEquals(1, forumManager0.getPostHeaders(g).size());
|
||||||
|
assertEquals(0, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
// send post to 1 without waiting for message delivery
|
||||||
|
sync0To1();
|
||||||
|
validationWaiter.await(TIMEOUT, 1);
|
||||||
|
assertEquals(0, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
// now add the parent post as well
|
||||||
|
forumManager0.addLocalPost(post1);
|
||||||
|
assertEquals(2, forumManager0.getPostHeaders(g).size());
|
||||||
|
assertEquals(0, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
// and send it over to 1 and wait for a second message to be delivered
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 2);
|
||||||
|
assertEquals(2, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testForumPostWithParentInOtherGroup() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
defaultInit();
|
||||||
|
|
||||||
|
// share forum
|
||||||
|
GroupId g = forum0.getId();
|
||||||
|
forumSharingManager0.sendInvitation(g, contactId1, null);
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
Contact c0 = contactManager1.getContact(contactId0);
|
||||||
|
forumSharingManager1.respondToInvitation(forum0, c0, true);
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// share a second forum
|
||||||
|
Forum forum1 = forumManager0.addForum("Test Forum1");
|
||||||
|
GroupId g1 = forum1.getId();
|
||||||
|
forumSharingManager0.sendInvitation(g1, contactId1, null);
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
forumSharingManager1.respondToInvitation(forum1, c0, true);
|
||||||
|
sync1To0();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// add one forum post with a parent in another forum
|
||||||
|
long time = clock.currentTimeMillis();
|
||||||
|
ForumPost post1 = createForumPost(g1, null, "a", time);
|
||||||
|
ForumPost post = createForumPost(g, post1, "b", time);
|
||||||
|
forumManager0.addLocalPost(post);
|
||||||
|
assertEquals(1, forumManager0.getPostHeaders(g).size());
|
||||||
|
assertEquals(0, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
// send the child post to 1
|
||||||
|
sync0To1();
|
||||||
|
validationWaiter.await(TIMEOUT, 1);
|
||||||
|
assertEquals(1, forumManager0.getPostHeaders(g).size());
|
||||||
|
assertEquals(0, forumManager1.getPostHeaders(g).size());
|
||||||
|
|
||||||
|
// now also add the parent post which is in another group
|
||||||
|
forumManager0.addLocalPost(post1);
|
||||||
|
assertEquals(1, forumManager0.getPostHeaders(g1).size());
|
||||||
|
assertEquals(0, forumManager1.getPostHeaders(g1).size());
|
||||||
|
|
||||||
|
// send posts to 1
|
||||||
|
sync0To1();
|
||||||
|
deliveryWaiter.await(TIMEOUT, 1);
|
||||||
|
assertEquals(1, forumManager0.getPostHeaders(g).size());
|
||||||
|
assertEquals(1, forumManager0.getPostHeaders(g1).size());
|
||||||
|
// the next line is critical, makes sure post doesn't show up
|
||||||
|
assertEquals(0, forumManager1.getPostHeaders(g).size());
|
||||||
|
assertEquals(1, forumManager1.getPostHeaders(g1).size());
|
||||||
|
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
TestUtils.deleteTestDirectory(testDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Listener implements EventListener {
|
||||||
|
@Override
|
||||||
|
public void eventOccurred(Event e) {
|
||||||
|
if (e instanceof MessageStateChangedEvent) {
|
||||||
|
MessageStateChangedEvent event = (MessageStateChangedEvent) e;
|
||||||
|
if (!event.isLocal()) {
|
||||||
|
if (event.getState() == DELIVERED) {
|
||||||
|
deliveryWaiter.resume();
|
||||||
|
} else if (event.getState() == INVALID ||
|
||||||
|
event.getState() == PENDING) {
|
||||||
|
validationWaiter.resume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void defaultInit() throws DbException {
|
||||||
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
addForum();
|
||||||
|
listenToEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDefaultIdentities() throws DbException {
|
||||||
|
author0 = authorFactory.createLocalAuthor(SHARER,
|
||||||
|
TestUtils.getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
||||||
|
TestUtils.getRandomBytes(123));
|
||||||
|
identityManager0.addLocalAuthor(author0);
|
||||||
|
author1 = authorFactory.createLocalAuthor(INVITEE,
|
||||||
|
TestUtils.getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
||||||
|
TestUtils.getRandomBytes(123));
|
||||||
|
identityManager1.addLocalAuthor(author1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDefaultContacts() throws DbException {
|
||||||
|
// sharer adds invitee as contact
|
||||||
|
contactId1 = contactManager0.addContact(author1,
|
||||||
|
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
// invitee adds sharer back
|
||||||
|
contactId0 = contactManager1.addContact(author0,
|
||||||
|
author1.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addForum() throws DbException {
|
||||||
|
forum0 = forumManager0.addForum("Test Forum");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void listenToEvents() {
|
||||||
|
Listener listener0 = new Listener();
|
||||||
|
t0.getEventBus().addListener(listener0);
|
||||||
|
Listener listener1 = new Listener();
|
||||||
|
t1.getEventBus().addListener(listener1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sync0To1() throws IOException, TimeoutException {
|
||||||
|
deliverMessage(sync0, contactId0, sync1, contactId1, "0 to 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sync1To0() throws IOException, TimeoutException {
|
||||||
|
deliverMessage(sync1, contactId1, sync0, contactId0, "1 to 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
||||||
|
SyncSessionFactory toSync, ContactId toId, String debug)
|
||||||
|
throws IOException, TimeoutException {
|
||||||
|
|
||||||
|
if (debug != null) LOG.info("TEST: Sending message from " + debug);
|
||||||
|
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
// Create an outgoing sync session
|
||||||
|
SyncSession sessionFrom =
|
||||||
|
fromSync.createSimplexOutgoingSession(toId, MAX_LATENCY, out);
|
||||||
|
// Write whatever needs to be written
|
||||||
|
sessionFrom.run();
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||||
|
// Create an incoming sync session
|
||||||
|
SyncSession sessionTo = toSync.createIncomingSession(fromId, in);
|
||||||
|
// Read whatever needs to be read
|
||||||
|
sessionTo.run();
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startLifecycles() throws InterruptedException {
|
||||||
|
// Start the lifecycle manager and wait for it to finish
|
||||||
|
lifecycleManager0 = t0.getLifecycleManager();
|
||||||
|
lifecycleManager1 = t1.getLifecycleManager();
|
||||||
|
lifecycleManager0.startServices();
|
||||||
|
lifecycleManager1.startServices();
|
||||||
|
lifecycleManager0.waitForStartup();
|
||||||
|
lifecycleManager1.waitForStartup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopLifecycles() throws InterruptedException {
|
||||||
|
// Clean up
|
||||||
|
lifecycleManager0.stopServices();
|
||||||
|
lifecycleManager1.stopServices();
|
||||||
|
lifecycleManager0.waitForShutdown();
|
||||||
|
lifecycleManager1.waitForShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void injectEagerSingletons(ForumManagerTestComponent component) {
|
||||||
|
component.inject(new LifecycleModule.EagerSingletons());
|
||||||
|
component.inject(new ForumModule.EagerSingletons());
|
||||||
|
component.inject(new CryptoModule.EagerSingletons());
|
||||||
|
component.inject(new ContactModule.EagerSingletons());
|
||||||
|
component.inject(new TransportModule.EagerSingletons());
|
||||||
|
component.inject(new SharingModule.EagerSingletons());
|
||||||
|
component.inject(new SyncModule.EagerSingletons());
|
||||||
|
component.inject(new PropertiesModule.EagerSingletons());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package org.briarproject;
|
||||||
|
|
||||||
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.event.EventBus;
|
||||||
|
import org.briarproject.api.forum.ForumManager;
|
||||||
|
import org.briarproject.api.forum.ForumSharingManager;
|
||||||
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
|
import org.briarproject.blogs.BlogsModule;
|
||||||
|
import org.briarproject.clients.ClientsModule;
|
||||||
|
import org.briarproject.contact.ContactModule;
|
||||||
|
import org.briarproject.crypto.CryptoModule;
|
||||||
|
import org.briarproject.data.DataModule;
|
||||||
|
import org.briarproject.db.DatabaseModule;
|
||||||
|
import org.briarproject.event.EventModule;
|
||||||
|
import org.briarproject.forum.ForumModule;
|
||||||
|
import org.briarproject.identity.IdentityModule;
|
||||||
|
import org.briarproject.lifecycle.LifecycleModule;
|
||||||
|
import org.briarproject.properties.PropertiesModule;
|
||||||
|
import org.briarproject.sharing.SharingModule;
|
||||||
|
import org.briarproject.sync.SyncModule;
|
||||||
|
import org.briarproject.system.SystemModule;
|
||||||
|
import org.briarproject.transport.TransportModule;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Component;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Component(modules = {
|
||||||
|
TestDatabaseModule.class,
|
||||||
|
TestPluginsModule.class,
|
||||||
|
TestSeedProviderModule.class,
|
||||||
|
ClientsModule.class,
|
||||||
|
ContactModule.class,
|
||||||
|
CryptoModule.class,
|
||||||
|
DataModule.class,
|
||||||
|
DatabaseModule.class,
|
||||||
|
EventModule.class,
|
||||||
|
ForumModule.class,
|
||||||
|
BlogsModule.class,
|
||||||
|
IdentityModule.class,
|
||||||
|
LifecycleModule.class,
|
||||||
|
PropertiesModule.class,
|
||||||
|
SharingModule.class,
|
||||||
|
SyncModule.class,
|
||||||
|
SystemModule.class,
|
||||||
|
TransportModule.class
|
||||||
|
})
|
||||||
|
interface ForumManagerTestComponent {
|
||||||
|
|
||||||
|
void inject(ForumManagerTest testCase);
|
||||||
|
|
||||||
|
void inject(ContactModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(CryptoModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(ForumModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(LifecycleModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(PropertiesModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(SharingModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(SyncModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(TransportModule.EagerSingletons init);
|
||||||
|
|
||||||
|
LifecycleManager getLifecycleManager();
|
||||||
|
|
||||||
|
EventBus getEventBus();
|
||||||
|
|
||||||
|
IdentityManager getIdentityManager();
|
||||||
|
|
||||||
|
ContactManager getContactManager();
|
||||||
|
|
||||||
|
ForumSharingManager getForumSharingManager();
|
||||||
|
|
||||||
|
ForumManager getForumManager();
|
||||||
|
|
||||||
|
SyncSessionFactory getSyncSessionFactory();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package org.briarproject;
|
||||||
|
|
||||||
|
import org.briarproject.api.clients.ClientHelper;
|
||||||
|
import org.briarproject.api.clients.MessageQueueManager;
|
||||||
|
import org.briarproject.api.clients.PrivateGroupFactory;
|
||||||
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.db.DatabaseComponent;
|
||||||
|
import org.briarproject.api.event.EventBus;
|
||||||
|
import org.briarproject.api.forum.ForumManager;
|
||||||
|
import org.briarproject.api.forum.ForumSharingManager;
|
||||||
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
|
import org.briarproject.blogs.BlogsModule;
|
||||||
|
import org.briarproject.clients.ClientsModule;
|
||||||
|
import org.briarproject.contact.ContactModule;
|
||||||
|
import org.briarproject.crypto.CryptoModule;
|
||||||
|
import org.briarproject.data.DataModule;
|
||||||
|
import org.briarproject.db.DatabaseModule;
|
||||||
|
import org.briarproject.event.EventModule;
|
||||||
|
import org.briarproject.forum.ForumModule;
|
||||||
|
import org.briarproject.identity.IdentityModule;
|
||||||
|
import org.briarproject.lifecycle.LifecycleModule;
|
||||||
|
import org.briarproject.properties.PropertiesModule;
|
||||||
|
import org.briarproject.sharing.SharingModule;
|
||||||
|
import org.briarproject.sync.SyncModule;
|
||||||
|
import org.briarproject.system.SystemModule;
|
||||||
|
import org.briarproject.transport.TransportModule;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import dagger.Component;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
@Component(modules = {
|
||||||
|
TestDatabaseModule.class,
|
||||||
|
TestPluginsModule.class,
|
||||||
|
TestSeedProviderModule.class,
|
||||||
|
ClientsModule.class,
|
||||||
|
ContactModule.class,
|
||||||
|
CryptoModule.class,
|
||||||
|
DataModule.class,
|
||||||
|
DatabaseModule.class,
|
||||||
|
EventModule.class,
|
||||||
|
ForumModule.class,
|
||||||
|
BlogsModule.class,
|
||||||
|
IdentityModule.class,
|
||||||
|
LifecycleModule.class,
|
||||||
|
PropertiesModule.class,
|
||||||
|
SharingModule.class,
|
||||||
|
SyncModule.class,
|
||||||
|
SystemModule.class,
|
||||||
|
TransportModule.class
|
||||||
|
})
|
||||||
|
interface ForumSharingIntegrationTestComponent {
|
||||||
|
|
||||||
|
void inject(ForumSharingIntegrationTest testCase);
|
||||||
|
|
||||||
|
void inject(ContactModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(CryptoModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(ForumModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(LifecycleModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(PropertiesModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(SharingModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(SyncModule.EagerSingletons init);
|
||||||
|
|
||||||
|
void inject(TransportModule.EagerSingletons init);
|
||||||
|
|
||||||
|
LifecycleManager getLifecycleManager();
|
||||||
|
|
||||||
|
EventBus getEventBus();
|
||||||
|
|
||||||
|
IdentityManager getIdentityManager();
|
||||||
|
|
||||||
|
ContactManager getContactManager();
|
||||||
|
|
||||||
|
ForumSharingManager getForumSharingManager();
|
||||||
|
|
||||||
|
ForumManager getForumManager();
|
||||||
|
|
||||||
|
SyncSessionFactory getSyncSessionFactory();
|
||||||
|
|
||||||
|
/* the following methods are only needed to manually construct messages */
|
||||||
|
|
||||||
|
DatabaseComponent getDatabaseComponent();
|
||||||
|
|
||||||
|
PrivateGroupFactory getPrivateGroupFactory();
|
||||||
|
|
||||||
|
ClientHelper getClientHelper();
|
||||||
|
|
||||||
|
MessageQueueManager getMessageQueueManager();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,11 +1,17 @@
|
|||||||
package org.briarproject;
|
package org.briarproject;
|
||||||
|
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import net.jodah.concurrentunit.Waiter;
|
import net.jodah.concurrentunit.Waiter;
|
||||||
|
|
||||||
|
import org.briarproject.api.FormatException;
|
||||||
|
import org.briarproject.api.clients.ClientHelper;
|
||||||
import org.briarproject.api.clients.SessionId;
|
import org.briarproject.api.clients.SessionId;
|
||||||
import org.briarproject.api.contact.Contact;
|
import org.briarproject.api.contact.Contact;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
import org.briarproject.api.contact.ContactManager;
|
import org.briarproject.api.contact.ContactManager;
|
||||||
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
|
import org.briarproject.api.crypto.KeyPair;
|
||||||
import org.briarproject.api.crypto.SecretKey;
|
import org.briarproject.api.crypto.SecretKey;
|
||||||
import org.briarproject.api.data.BdfDictionary;
|
import org.briarproject.api.data.BdfDictionary;
|
||||||
import org.briarproject.api.data.BdfEntry;
|
import org.briarproject.api.data.BdfEntry;
|
||||||
@@ -19,10 +25,11 @@ import org.briarproject.api.event.IntroductionAbortedEvent;
|
|||||||
import org.briarproject.api.event.IntroductionRequestReceivedEvent;
|
import org.briarproject.api.event.IntroductionRequestReceivedEvent;
|
||||||
import org.briarproject.api.event.IntroductionResponseReceivedEvent;
|
import org.briarproject.api.event.IntroductionResponseReceivedEvent;
|
||||||
import org.briarproject.api.event.IntroductionSucceededEvent;
|
import org.briarproject.api.event.IntroductionSucceededEvent;
|
||||||
import org.briarproject.api.event.MessageValidatedEvent;
|
import org.briarproject.api.event.MessageStateChangedEvent;
|
||||||
import org.briarproject.api.identity.AuthorFactory;
|
import org.briarproject.api.identity.AuthorFactory;
|
||||||
import org.briarproject.api.identity.IdentityManager;
|
import org.briarproject.api.identity.IdentityManager;
|
||||||
import org.briarproject.api.identity.LocalAuthor;
|
import org.briarproject.api.identity.LocalAuthor;
|
||||||
|
import org.briarproject.api.introduction.IntroducerProtocolState;
|
||||||
import org.briarproject.api.introduction.IntroductionManager;
|
import org.briarproject.api.introduction.IntroductionManager;
|
||||||
import org.briarproject.api.introduction.IntroductionMessage;
|
import org.briarproject.api.introduction.IntroductionMessage;
|
||||||
import org.briarproject.api.introduction.IntroductionRequest;
|
import org.briarproject.api.introduction.IntroductionRequest;
|
||||||
@@ -30,9 +37,11 @@ import org.briarproject.api.lifecycle.LifecycleManager;
|
|||||||
import org.briarproject.api.properties.TransportProperties;
|
import org.briarproject.api.properties.TransportProperties;
|
||||||
import org.briarproject.api.properties.TransportPropertyManager;
|
import org.briarproject.api.properties.TransportPropertyManager;
|
||||||
import org.briarproject.api.sync.Group;
|
import org.briarproject.api.sync.Group;
|
||||||
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.briarproject.api.sync.MessageId;
|
import org.briarproject.api.sync.MessageId;
|
||||||
import org.briarproject.api.sync.SyncSession;
|
import org.briarproject.api.sync.SyncSession;
|
||||||
import org.briarproject.api.sync.SyncSessionFactory;
|
import org.briarproject.api.sync.SyncSessionFactory;
|
||||||
|
import org.briarproject.api.sync.ValidationManager.State;
|
||||||
import org.briarproject.api.system.Clock;
|
import org.briarproject.api.system.Clock;
|
||||||
import org.briarproject.contact.ContactModule;
|
import org.briarproject.contact.ContactModule;
|
||||||
import org.briarproject.crypto.CryptoModule;
|
import org.briarproject.crypto.CryptoModule;
|
||||||
@@ -53,6 +62,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -63,30 +73,42 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static org.briarproject.TestPluginsModule.MAX_LATENCY;
|
import static org.briarproject.TestPluginsModule.MAX_LATENCY;
|
||||||
import static org.briarproject.TestPluginsModule.TRANSPORT_ID;
|
import static org.briarproject.TestPluginsModule.TRANSPORT_ID;
|
||||||
|
import static org.briarproject.api.clients.MessageQueueManager.QUEUE_STATE_KEY;
|
||||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.GROUP_ID;
|
import static org.briarproject.api.introduction.IntroductionConstants.GROUP_ID;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.NAME;
|
import static org.briarproject.api.introduction.IntroductionConstants.NAME;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.PUBLIC_KEY;
|
import static org.briarproject.api.introduction.IntroductionConstants.PUBLIC_KEY;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.SESSION_ID;
|
import static org.briarproject.api.introduction.IntroductionConstants.SESSION_ID;
|
||||||
|
import static org.briarproject.api.introduction.IntroductionConstants.STATE;
|
||||||
|
import static org.briarproject.api.introduction.IntroductionConstants.TRANSPORT;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.TYPE;
|
import static org.briarproject.api.introduction.IntroductionConstants.TYPE;
|
||||||
import static org.briarproject.api.introduction.IntroductionConstants.TYPE_REQUEST;
|
import static org.briarproject.api.introduction.IntroductionConstants.TYPE_REQUEST;
|
||||||
|
import static org.briarproject.api.introduction.IntroductionConstants.TYPE_RESPONSE;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.DELIVERED;
|
||||||
|
import static org.briarproject.api.sync.ValidationManager.State.INVALID;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class IntroductionIntegrationTest extends BriarTestCase {
|
public class IntroductionIntegrationTest extends BriarTestCase {
|
||||||
|
|
||||||
LifecycleManager lifecycleManager0, lifecycleManager1, lifecycleManager2;
|
private LifecycleManager lifecycleManager0, lifecycleManager1,
|
||||||
SyncSessionFactory sync0, sync1, sync2;
|
lifecycleManager2;
|
||||||
ContactManager contactManager0, contactManager1, contactManager2;
|
private SyncSessionFactory sync0, sync1, sync2;
|
||||||
ContactId contactId0, contactId1, contactId2;
|
private ContactManager contactManager0, contactManager1, contactManager2;
|
||||||
IdentityManager identityManager0, identityManager1, identityManager2;
|
private ContactId contactId0, contactId1, contactId2;
|
||||||
LocalAuthor author0, author1, author2;
|
private IdentityManager identityManager0, identityManager1,
|
||||||
|
identityManager2;
|
||||||
|
private LocalAuthor author0, author1, author2;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Clock clock;
|
Clock clock;
|
||||||
@Inject
|
@Inject
|
||||||
|
CryptoComponent crypto;
|
||||||
|
@Inject
|
||||||
AuthorFactory authorFactory;
|
AuthorFactory authorFactory;
|
||||||
|
@Inject
|
||||||
|
IntroductionGroupFactory introductionGroupFactory;
|
||||||
|
|
||||||
// objects accessed from background threads need to be volatile
|
// objects accessed from background threads need to be volatile
|
||||||
private volatile IntroductionManager introductionManager0;
|
private volatile IntroductionManager introductionManager0;
|
||||||
@@ -150,32 +172,13 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
public void testIntroductionSession() throws Exception {
|
public void testIntroductionSession() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
try {
|
try {
|
||||||
// Add Identities
|
// Add Identities And Contacts
|
||||||
addDefaultIdentities();
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
|
||||||
// Add Transport Properties
|
// Add Transport Properties
|
||||||
addTransportProperties();
|
addTransportProperties();
|
||||||
|
|
||||||
// Add introducees as contacts
|
|
||||||
contactId1 = contactManager0.addContact(author1,
|
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
contactId2 = contactManager0.addContact(author2,
|
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
// Add introducer back
|
|
||||||
contactId0 = contactManager1.addContact(author0,
|
|
||||||
author1.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
ContactId contactId02 = contactManager2.addContact(author0,
|
|
||||||
author2.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
assertTrue(contactId0.equals(contactId02));
|
|
||||||
|
|
||||||
// listen to events
|
// listen to events
|
||||||
IntroducerListener listener0 = new IntroducerListener();
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
t0.getEventBus().addListener(listener0);
|
t0.getEventBus().addListener(listener0);
|
||||||
@@ -233,6 +236,18 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
assertTrue(contactManager2
|
assertTrue(contactManager2
|
||||||
.contactExists(author1.getId(), author2.getId()));
|
.contactExists(author1.getId(), author2.getId()));
|
||||||
|
|
||||||
|
// make sure that introduced contacts are not verified
|
||||||
|
for (Contact c : contactManager1.getActiveContacts()) {
|
||||||
|
if (c.getAuthor().equals(author2)) {
|
||||||
|
assertFalse(c.isVerified());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Contact c : contactManager2.getActiveContacts()) {
|
||||||
|
if (c.getAuthor().equals(author1)) {
|
||||||
|
assertFalse(c.isVerified());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
assertDefaultUiMessages();
|
assertDefaultUiMessages();
|
||||||
} finally {
|
} finally {
|
||||||
stopLifecycles();
|
stopLifecycles();
|
||||||
@@ -243,29 +258,13 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
public void testIntroductionSessionFirstDecline() throws Exception {
|
public void testIntroductionSessionFirstDecline() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
try {
|
try {
|
||||||
// Add Identities
|
// Add Identities And Contacts
|
||||||
addDefaultIdentities();
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
|
||||||
// Add Transport Properties
|
// Add Transport Properties
|
||||||
addTransportProperties();
|
addTransportProperties();
|
||||||
|
|
||||||
// Add introducees as contacts
|
|
||||||
contactId1 = contactManager0.addContact(author1, author0.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
contactId2 = contactManager0.addContact(author2, author0.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
// Add introducer back
|
|
||||||
contactId0 = contactManager1.addContact(author0, author1.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
ContactId contactId02 = contactManager2.addContact(author0,
|
|
||||||
author2.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
assertTrue(contactId0.equals(contactId02));
|
|
||||||
|
|
||||||
// listen to events
|
// listen to events
|
||||||
IntroducerListener listener0 = new IntroducerListener();
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
t0.getEventBus().addListener(listener0);
|
t0.getEventBus().addListener(listener0);
|
||||||
@@ -301,7 +300,7 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
assertTrue(listener0.response2Received);
|
assertTrue(listener0.response2Received);
|
||||||
|
|
||||||
// sync first forwarded response
|
// sync first forwarded response
|
||||||
deliverMessage(sync0, contactId0, sync2, contactId2);
|
deliverMessage(sync0, contactId0, sync2, contactId2, "0 to 2");
|
||||||
|
|
||||||
// note how the introducer does not forward the second response,
|
// note how the introducer does not forward the second response,
|
||||||
// because after the first decline the protocol finished
|
// because after the first decline the protocol finished
|
||||||
@@ -336,29 +335,13 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
public void testIntroductionSessionSecondDecline() throws Exception {
|
public void testIntroductionSessionSecondDecline() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
try {
|
try {
|
||||||
// Add Identities
|
// Add Identities And Contacts
|
||||||
addDefaultIdentities();
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
|
||||||
// Add Transport Properties
|
// Add Transport Properties
|
||||||
addTransportProperties();
|
addTransportProperties();
|
||||||
|
|
||||||
// Add introducees as contacts
|
|
||||||
contactId1 = contactManager0.addContact(author1, author0.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
contactId2 = contactManager0.addContact(author2, author0.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
// Add introducer back
|
|
||||||
contactId0 = contactManager1.addContact(author0, author1.getId(),
|
|
||||||
master, clock.currentTimeMillis(), false, true
|
|
||||||
);
|
|
||||||
ContactId contactId02 = contactManager2.addContact(author0,
|
|
||||||
author2.getId(), master, clock.currentTimeMillis(), false,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
assertTrue(contactId0.equals(contactId02));
|
|
||||||
|
|
||||||
// listen to events
|
// listen to events
|
||||||
IntroducerListener listener0 = new IntroducerListener();
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
t0.getEventBus().addListener(listener0);
|
t0.getEventBus().addListener(listener0);
|
||||||
@@ -424,29 +407,13 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
public void testIntroductionSessionDelayedFirstDecline() throws Exception {
|
public void testIntroductionSessionDelayedFirstDecline() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
try {
|
try {
|
||||||
// Add Identities
|
// Add Identities And Contacts
|
||||||
addDefaultIdentities();
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
|
||||||
// Add Transport Properties
|
// Add Transport Properties
|
||||||
addTransportProperties();
|
addTransportProperties();
|
||||||
|
|
||||||
// Add introducees as contacts
|
|
||||||
contactId1 = contactManager0.addContact(author1, author0.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
contactId2 = contactManager0.addContact(author2, author0.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
// Add introducer back
|
|
||||||
contactId0 = contactManager1.addContact(author0, author1.getId(),
|
|
||||||
master, clock.currentTimeMillis(), false, true
|
|
||||||
);
|
|
||||||
ContactId contactId02 = contactManager2.addContact(author0,
|
|
||||||
author2.getId(), master, clock.currentTimeMillis(), false,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
assertTrue(contactId0.equals(contactId02));
|
|
||||||
|
|
||||||
// listen to events
|
// listen to events
|
||||||
IntroducerListener listener0 = new IntroducerListener();
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
t0.getEventBus().addListener(listener0);
|
t0.getEventBus().addListener(listener0);
|
||||||
@@ -503,21 +470,13 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
public void testIntroductionToSameContact() throws Exception {
|
public void testIntroductionToSameContact() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
try {
|
try {
|
||||||
// Add Identities
|
// Add Identities And Contacts
|
||||||
addDefaultIdentities();
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
|
||||||
// Add Transport Properties
|
// Add Transport Properties
|
||||||
addTransportProperties();
|
addTransportProperties();
|
||||||
|
|
||||||
// Add introducee as contact
|
|
||||||
contactId1 = contactManager0.addContact(author1, author0.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
// Add introducer back
|
|
||||||
contactId0 = contactManager1.addContact(author0, author1.getId(),
|
|
||||||
master, clock.currentTimeMillis(), true, true
|
|
||||||
);
|
|
||||||
|
|
||||||
// listen to events
|
// listen to events
|
||||||
IntroducerListener listener0 = new IntroducerListener();
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
t0.getEventBus().addListener(listener0);
|
t0.getEventBus().addListener(listener0);
|
||||||
@@ -568,21 +527,21 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
// Add introducees' authors as contacts
|
// Add introducees' authors as contacts
|
||||||
contactId1 = contactManager0.addContact(author1,
|
contactId1 = contactManager0.addContact(author1,
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||||
true
|
true, true
|
||||||
);
|
);
|
||||||
contactId2 = contactManager0.addContact(author2,
|
contactId2 = contactManager0.addContact(author2,
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||||
true
|
true, true
|
||||||
);
|
);
|
||||||
// Add introducer back
|
// Add introducer back
|
||||||
contactId0 = null;
|
contactId0 = null;
|
||||||
ContactId contactId01 = contactManager1.addContact(author0,
|
ContactId contactId01 = contactManager1.addContact(author0,
|
||||||
author1.getId(), master, clock.currentTimeMillis(), false,
|
author1.getId(), master, clock.currentTimeMillis(), false,
|
||||||
true
|
true, true
|
||||||
);
|
);
|
||||||
ContactId contactId02 = contactManager1.addContact(author0,
|
ContactId contactId02 = contactManager1.addContact(author0,
|
||||||
author2.getId(), master, clock.currentTimeMillis(), false,
|
author2.getId(), master, clock.currentTimeMillis(), false,
|
||||||
true
|
true, true
|
||||||
);
|
);
|
||||||
|
|
||||||
// listen to events
|
// listen to events
|
||||||
@@ -653,32 +612,13 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
public void testSessionIdReuse() throws Exception {
|
public void testSessionIdReuse() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
try {
|
try {
|
||||||
// Add Identities
|
// Add Identities And Contacts
|
||||||
addDefaultIdentities();
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
|
||||||
// Add Transport Properties
|
// Add Transport Properties
|
||||||
addTransportProperties();
|
addTransportProperties();
|
||||||
|
|
||||||
// Add introducees as contacts
|
|
||||||
contactId1 = contactManager0.addContact(author1,
|
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
contactId2 = contactManager0.addContact(author2,
|
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
// Add introducer back
|
|
||||||
contactId0 = contactManager1.addContact(author0,
|
|
||||||
author1.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
ContactId contactId02 = contactManager2.addContact(author0,
|
|
||||||
author2.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
assertTrue(contactId0.equals(contactId02));
|
|
||||||
|
|
||||||
// listen to events
|
// listen to events
|
||||||
IntroducerListener listener0 = new IntroducerListener();
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
t0.getEventBus().addListener(listener0);
|
t0.getEventBus().addListener(listener0);
|
||||||
@@ -750,32 +690,13 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
public void testIntroducerRemovedCleanup() throws Exception {
|
public void testIntroducerRemovedCleanup() throws Exception {
|
||||||
startLifecycles();
|
startLifecycles();
|
||||||
try {
|
try {
|
||||||
// Add Identities
|
// Add Identities And Contacts
|
||||||
addDefaultIdentities();
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
|
||||||
// Add Transport Properties
|
// Add Transport Properties
|
||||||
addTransportProperties();
|
addTransportProperties();
|
||||||
|
|
||||||
// Add introducees as contacts
|
|
||||||
contactId1 = contactManager0.addContact(author1,
|
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
contactId2 = contactManager0.addContact(author2,
|
|
||||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
// Add introducer back
|
|
||||||
contactId0 = contactManager1.addContact(author0,
|
|
||||||
author1.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
ContactId contactId02 = contactManager2.addContact(author0,
|
|
||||||
author2.getId(), master, clock.currentTimeMillis(), true,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
assertTrue(contactId0.equals(contactId02));
|
|
||||||
|
|
||||||
// listen to events
|
// listen to events
|
||||||
IntroducerListener listener0 = new IntroducerListener();
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
t0.getEventBus().addListener(listener0);
|
t0.getEventBus().addListener(listener0);
|
||||||
@@ -832,7 +753,214 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add a test for faking responses when #256 is implemented
|
@Test
|
||||||
|
public void testIntroduceesRemovedCleanup() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
try {
|
||||||
|
// Add Identities And Contacts
|
||||||
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
|
||||||
|
// Add Transport Properties
|
||||||
|
addTransportProperties();
|
||||||
|
|
||||||
|
// listen to events
|
||||||
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
|
t0.getEventBus().addListener(listener0);
|
||||||
|
IntroduceeListener listener1 = new IntroduceeListener(1, true);
|
||||||
|
t1.getEventBus().addListener(listener1);
|
||||||
|
IntroduceeListener listener2 = new IntroduceeListener(2, true);
|
||||||
|
t2.getEventBus().addListener(listener2);
|
||||||
|
|
||||||
|
// make introduction
|
||||||
|
long time = clock.currentTimeMillis();
|
||||||
|
Contact introducee1 = contactManager0.getContact(contactId1);
|
||||||
|
Contact introducee2 = contactManager0.getContact(contactId2);
|
||||||
|
introductionManager0
|
||||||
|
.makeIntroduction(introducee1, introducee2, "Hi!", time);
|
||||||
|
|
||||||
|
// sync first request message
|
||||||
|
deliverMessage(sync0, contactId0, sync1, contactId1, "0 to 1");
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
assertTrue(listener1.requestReceived);
|
||||||
|
|
||||||
|
// get database and local group for introducee
|
||||||
|
DatabaseComponent db0 = t0.getDatabaseComponent();
|
||||||
|
IntroductionGroupFactory groupFactory0 =
|
||||||
|
t0.getIntroductionGroupFactory();
|
||||||
|
Group group1 = groupFactory0.createLocalGroup();
|
||||||
|
|
||||||
|
// get local session state messages
|
||||||
|
Map<MessageId, Metadata> map;
|
||||||
|
Transaction txn = db0.startTransaction(false);
|
||||||
|
try {
|
||||||
|
map = db0.getMessageMetadata(txn, group1.getId());
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db0.endTransaction(txn);
|
||||||
|
}
|
||||||
|
// check that we have one session state
|
||||||
|
assertEquals(1, map.size());
|
||||||
|
|
||||||
|
// introducer removes introducee1
|
||||||
|
contactManager0.removeContact(contactId1);
|
||||||
|
|
||||||
|
// get local session state messages again
|
||||||
|
txn = db0.startTransaction(false);
|
||||||
|
try {
|
||||||
|
map = db0.getMessageMetadata(txn, group1.getId());
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db0.endTransaction(txn);
|
||||||
|
}
|
||||||
|
// make sure local state is still there
|
||||||
|
assertEquals(1, map.size());
|
||||||
|
|
||||||
|
// introducer removes other introducee
|
||||||
|
contactManager0.removeContact(contactId2);
|
||||||
|
|
||||||
|
// get local session state messages again
|
||||||
|
txn = db0.startTransaction(false);
|
||||||
|
try {
|
||||||
|
map = db0.getMessageMetadata(txn, group1.getId());
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db0.endTransaction(txn);
|
||||||
|
}
|
||||||
|
// make sure local state is gone now
|
||||||
|
assertEquals(0, map.size());
|
||||||
|
} finally {
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testModifiedResponse() throws Exception {
|
||||||
|
startLifecycles();
|
||||||
|
try {
|
||||||
|
addDefaultIdentities();
|
||||||
|
addDefaultContacts();
|
||||||
|
addTransportProperties();
|
||||||
|
|
||||||
|
// listen to events
|
||||||
|
IntroducerListener listener0 = new IntroducerListener();
|
||||||
|
t0.getEventBus().addListener(listener0);
|
||||||
|
IntroduceeListener listener1 = new IntroduceeListener(1, true);
|
||||||
|
t1.getEventBus().addListener(listener1);
|
||||||
|
IntroduceeListener listener2 = new IntroduceeListener(2, true);
|
||||||
|
t2.getEventBus().addListener(listener2);
|
||||||
|
|
||||||
|
// make introduction
|
||||||
|
long time = clock.currentTimeMillis();
|
||||||
|
Contact introducee1 = contactManager0.getContact(contactId1);
|
||||||
|
Contact introducee2 = contactManager0.getContact(contactId2);
|
||||||
|
introductionManager0
|
||||||
|
.makeIntroduction(introducee1, introducee2, "Hi!", time);
|
||||||
|
|
||||||
|
// sync request messages
|
||||||
|
deliverMessage(sync0, contactId0, sync1, contactId1, "0 to 1");
|
||||||
|
deliverMessage(sync0, contactId0, sync2, contactId2, "0 to 2");
|
||||||
|
eventWaiter.await(TIMEOUT, 2);
|
||||||
|
|
||||||
|
// sync first response
|
||||||
|
deliverMessage(sync1, contactId1, sync0, contactId0, "1 to 0");
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// get response to be forwarded
|
||||||
|
MessageId responseId = null;
|
||||||
|
BdfDictionary response = null;
|
||||||
|
Group g2 = introductionGroupFactory
|
||||||
|
.createIntroductionGroup(introducee2);
|
||||||
|
ClientHelper clientHelper0 = t0.getClientHelper();
|
||||||
|
Map<MessageId, BdfDictionary> map =
|
||||||
|
clientHelper0.getMessageMetadataAsDictionary(g2.getId());
|
||||||
|
for (Map.Entry<MessageId, BdfDictionary> entry : map.entrySet()) {
|
||||||
|
if (entry.getValue().getLong(TYPE) == TYPE_RESPONSE) {
|
||||||
|
responseId = entry.getKey();
|
||||||
|
response = entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(responseId != null && response != null);
|
||||||
|
|
||||||
|
// adapt outgoing message queue to removed message
|
||||||
|
decreaseOutgoingMessageCounter(clientHelper0, g2.getId(), 1);
|
||||||
|
|
||||||
|
// modify response by changing transport properties
|
||||||
|
BdfDictionary tp = response.getDictionary(TRANSPORT);
|
||||||
|
tp.put("fakeId", BdfDictionary.of(new BdfEntry("fake", "fake")));
|
||||||
|
response.put(TRANSPORT, tp);
|
||||||
|
|
||||||
|
// replace original response with modified one
|
||||||
|
MessageSender sender0 = t0.getMessageSender();
|
||||||
|
DatabaseComponent db0 = t0.getDatabaseComponent();
|
||||||
|
Transaction txn = db0.startTransaction(false);
|
||||||
|
try {
|
||||||
|
db0.deleteMessage(txn, responseId);
|
||||||
|
sender0.sendMessage(txn, response);
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db0.endTransaction(txn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sync second response
|
||||||
|
deliverMessage(sync2, contactId2, sync0, contactId0, "2 to 0");
|
||||||
|
eventWaiter.await(TIMEOUT, 1);
|
||||||
|
|
||||||
|
// sync forwarded responses to introducees
|
||||||
|
deliverMessage(sync0, contactId0, sync1, contactId1, "0 to 1");
|
||||||
|
deliverMessage(sync0, contactId0, sync2, contactId2, "0 to 2");
|
||||||
|
|
||||||
|
// sync first ACK and its forward
|
||||||
|
deliverMessage(sync2, contactId2, sync0, contactId0, "2 to 0");
|
||||||
|
deliverMessage(sync0, contactId0, sync1, contactId1, "0 to 1");
|
||||||
|
|
||||||
|
// sync second ACK and forward it
|
||||||
|
deliverMessage(sync1, contactId1, sync0, contactId0, "1 to 0");
|
||||||
|
deliverMessage(sync0, contactId0, sync2, contactId2, "0 to 2");
|
||||||
|
|
||||||
|
// introducee2 should have detected the fake now
|
||||||
|
// and deleted introducee1 again
|
||||||
|
Collection<Contact> contacts2;
|
||||||
|
DatabaseComponent db2 = t2.getDatabaseComponent();
|
||||||
|
txn = db2.startTransaction(true);
|
||||||
|
try {
|
||||||
|
contacts2 = db2.getContacts(txn);
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db2.endTransaction(txn);
|
||||||
|
}
|
||||||
|
assertEquals(1, contacts2.size());
|
||||||
|
|
||||||
|
// sync abort message to introducer
|
||||||
|
deliverMessage(sync2, contactId2, sync0, contactId0, "2 to 0");
|
||||||
|
|
||||||
|
// ensure introducer got the abort
|
||||||
|
SessionId sessionId = new SessionId(response.getRaw(SESSION_ID));
|
||||||
|
BdfDictionary state =
|
||||||
|
clientHelper0.getMessageMetadataAsDictionary(sessionId);
|
||||||
|
assertEquals(IntroducerProtocolState.ERROR.getValue(),
|
||||||
|
state.getLong(STATE).intValue());
|
||||||
|
|
||||||
|
// sync abort messages to introducees
|
||||||
|
deliverMessage(sync0, contactId0, sync1, contactId1, "0 to 1");
|
||||||
|
deliverMessage(sync0, contactId0, sync2, contactId2, "0 to 2");
|
||||||
|
|
||||||
|
// although aborted, introducee1 keeps the contact,
|
||||||
|
// so introducer can not make contacts disappear by sending abort
|
||||||
|
Collection<Contact> contacts1;
|
||||||
|
DatabaseComponent db1 = t1.getDatabaseComponent();
|
||||||
|
txn = db1.startTransaction(true);
|
||||||
|
try {
|
||||||
|
contacts1 = db1.getContacts(txn);
|
||||||
|
txn.setComplete();
|
||||||
|
} finally {
|
||||||
|
db1.endTransaction(txn);
|
||||||
|
}
|
||||||
|
assertEquals(2, contacts1.size());
|
||||||
|
} finally {
|
||||||
|
stopLifecycles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws InterruptedException {
|
public void tearDown() throws InterruptedException {
|
||||||
@@ -875,20 +1003,48 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addDefaultIdentities() throws DbException {
|
private void addDefaultIdentities() throws DbException {
|
||||||
author0 = authorFactory.createLocalAuthor(INTRODUCER,
|
KeyPair keyPair0 = crypto.generateSignatureKeyPair();
|
||||||
TestUtils.getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
byte[] publicKey0 = keyPair0.getPublic().getEncoded();
|
||||||
TestUtils.getRandomBytes(123));
|
byte[] privateKey0 = keyPair0.getPrivate().getEncoded();
|
||||||
|
author0 = authorFactory
|
||||||
|
.createLocalAuthor(INTRODUCER, publicKey0, privateKey0);
|
||||||
identityManager0.addLocalAuthor(author0);
|
identityManager0.addLocalAuthor(author0);
|
||||||
author1 = authorFactory.createLocalAuthor(INTRODUCEE1,
|
KeyPair keyPair1 = crypto.generateSignatureKeyPair();
|
||||||
TestUtils.getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
byte[] publicKey1 = keyPair1.getPublic().getEncoded();
|
||||||
TestUtils.getRandomBytes(123));
|
byte[] privateKey1 = keyPair1.getPrivate().getEncoded();
|
||||||
|
author1 = authorFactory
|
||||||
|
.createLocalAuthor(INTRODUCEE1, publicKey1, privateKey1);
|
||||||
identityManager1.addLocalAuthor(author1);
|
identityManager1.addLocalAuthor(author1);
|
||||||
author2 = authorFactory.createLocalAuthor(INTRODUCEE2,
|
KeyPair keyPair2 = crypto.generateSignatureKeyPair();
|
||||||
TestUtils.getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
byte[] publicKey2 = keyPair2.getPublic().getEncoded();
|
||||||
TestUtils.getRandomBytes(123));
|
byte[] privateKey2 = keyPair2.getPrivate().getEncoded();
|
||||||
|
author2 = authorFactory
|
||||||
|
.createLocalAuthor(INTRODUCEE2, publicKey2, privateKey2);
|
||||||
identityManager2.addLocalAuthor(author2);
|
identityManager2.addLocalAuthor(author2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addDefaultContacts() throws DbException {
|
||||||
|
// Add introducees as contacts
|
||||||
|
contactId1 = contactManager0.addContact(author1,
|
||||||
|
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
contactId2 = contactManager0.addContact(author2,
|
||||||
|
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
// Add introducer back
|
||||||
|
contactId0 = contactManager1.addContact(author0,
|
||||||
|
author1.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
ContactId contactId02 = contactManager2.addContact(author0,
|
||||||
|
author2.getId(), master, clock.currentTimeMillis(), true,
|
||||||
|
true, true
|
||||||
|
);
|
||||||
|
assertTrue(contactId0.equals(contactId02));
|
||||||
|
}
|
||||||
|
|
||||||
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
||||||
SyncSessionFactory toSync, ContactId toId)
|
SyncSessionFactory toSync, ContactId toId)
|
||||||
throws IOException, TimeoutException {
|
throws IOException, TimeoutException {
|
||||||
@@ -896,7 +1052,7 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
private void deliverMessage(SyncSessionFactory fromSync, ContactId fromId,
|
||||||
SyncSessionFactory toSync, ContactId toId, String debug)
|
SyncSessionFactory toSync, ContactId toId, @Nullable String debug)
|
||||||
throws IOException, TimeoutException {
|
throws IOException, TimeoutException {
|
||||||
|
|
||||||
if (debug != null) LOG.info("TEST: Sending message from " + debug);
|
if (debug != null) LOG.info("TEST: Sending message from " + debug);
|
||||||
@@ -933,29 +1089,26 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
|
|
||||||
private class IntroduceeListener implements EventListener {
|
private class IntroduceeListener implements EventListener {
|
||||||
|
|
||||||
public volatile boolean requestReceived = false;
|
private volatile boolean requestReceived = false;
|
||||||
public volatile boolean succeeded = false;
|
private volatile boolean succeeded = false;
|
||||||
public volatile boolean aborted = false;
|
private volatile boolean aborted = false;
|
||||||
|
|
||||||
private final int introducee;
|
private final int introducee;
|
||||||
private final boolean accept;
|
private final boolean accept;
|
||||||
|
|
||||||
IntroduceeListener(int introducee, boolean accept) {
|
private IntroduceeListener(int introducee, boolean accept) {
|
||||||
this.introducee = introducee;
|
this.introducee = introducee;
|
||||||
this.accept = accept;
|
this.accept = accept;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void eventOccurred(Event e) {
|
public void eventOccurred(Event e) {
|
||||||
if (e instanceof MessageValidatedEvent) {
|
if (e instanceof MessageStateChangedEvent) {
|
||||||
MessageValidatedEvent event = (MessageValidatedEvent) e;
|
MessageStateChangedEvent event = (MessageStateChangedEvent) e;
|
||||||
if (event.getClientId()
|
State s = event.getState();
|
||||||
.equals(introductionManager0.getClientId()) &&
|
if ((s == DELIVERED || s == INVALID) && !event.isLocal()) {
|
||||||
!event.isLocal()) {
|
|
||||||
LOG.info("TEST: Introducee" + introducee +
|
LOG.info("TEST: Introducee" + introducee +
|
||||||
" received message in group " +
|
" received message");
|
||||||
((MessageValidatedEvent) e).getMessage()
|
|
||||||
.getGroupId().hashCode());
|
|
||||||
msgWaiter.resume();
|
msgWaiter.resume();
|
||||||
}
|
}
|
||||||
} else if (e instanceof IntroductionRequestReceivedEvent) {
|
} else if (e instanceof IntroductionRequestReceivedEvent) {
|
||||||
@@ -989,6 +1142,7 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DbException | IOException exception) {
|
} catch (DbException | IOException exception) {
|
||||||
|
msgWaiter.rethrow(exception);
|
||||||
eventWaiter.rethrow(exception);
|
eventWaiter.rethrow(exception);
|
||||||
} finally {
|
} finally {
|
||||||
eventWaiter.resume();
|
eventWaiter.resume();
|
||||||
@@ -1008,20 +1162,16 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
|
|
||||||
private class IntroducerListener implements EventListener {
|
private class IntroducerListener implements EventListener {
|
||||||
|
|
||||||
public volatile boolean response1Received = false;
|
private volatile boolean response1Received = false;
|
||||||
public volatile boolean response2Received = false;
|
private volatile boolean response2Received = false;
|
||||||
public volatile boolean aborted = false;
|
private volatile boolean aborted = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void eventOccurred(Event e) {
|
public void eventOccurred(Event e) {
|
||||||
if (e instanceof MessageValidatedEvent) {
|
if (e instanceof MessageStateChangedEvent) {
|
||||||
MessageValidatedEvent event = (MessageValidatedEvent) e;
|
MessageStateChangedEvent event = (MessageStateChangedEvent) e;
|
||||||
if (event.getClientId()
|
if (event.getState() == DELIVERED && !event.isLocal()) {
|
||||||
.equals(introductionManager0.getClientId()) &&
|
LOG.info("TEST: Introducer received message");
|
||||||
!event.isLocal()) {
|
|
||||||
LOG.info("TEST: Introducer received message in group " +
|
|
||||||
((MessageValidatedEvent) e).getMessage()
|
|
||||||
.getGroupId().hashCode());
|
|
||||||
msgWaiter.resume();
|
msgWaiter.resume();
|
||||||
}
|
}
|
||||||
} else if (e instanceof IntroductionResponseReceivedEvent) {
|
} else if (e instanceof IntroductionResponseReceivedEvent) {
|
||||||
@@ -1043,6 +1193,16 @@ public class IntroductionIntegrationTest extends BriarTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void decreaseOutgoingMessageCounter(ClientHelper clientHelper,
|
||||||
|
GroupId g, int num) throws FormatException, DbException {
|
||||||
|
BdfDictionary gD = clientHelper.getGroupMetadataAsDictionary(g);
|
||||||
|
LOG.warning(gD.toString());
|
||||||
|
BdfDictionary queue = gD.getDictionary(QUEUE_STATE_KEY);
|
||||||
|
queue.put("nextOut", queue.getLong("nextOut") - num);
|
||||||
|
gD.put(QUEUE_STATE_KEY, queue);
|
||||||
|
clientHelper.mergeGroupMetadata(g, gD);
|
||||||
|
}
|
||||||
|
|
||||||
private void injectEagerSingletons(
|
private void injectEagerSingletons(
|
||||||
IntroductionIntegrationTestComponent component) {
|
IntroductionIntegrationTestComponent component) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.briarproject;
|
package org.briarproject;
|
||||||
|
|
||||||
|
import org.briarproject.api.clients.ClientHelper;
|
||||||
import org.briarproject.api.contact.ContactManager;
|
import org.briarproject.api.contact.ContactManager;
|
||||||
import org.briarproject.api.db.DatabaseComponent;
|
import org.briarproject.api.db.DatabaseComponent;
|
||||||
import org.briarproject.api.event.EventBus;
|
import org.briarproject.api.event.EventBus;
|
||||||
@@ -85,6 +86,8 @@ public interface IntroductionIntegrationTestComponent {
|
|||||||
|
|
||||||
DatabaseComponent getDatabaseComponent();
|
DatabaseComponent getDatabaseComponent();
|
||||||
|
|
||||||
|
ClientHelper getClientHelper();
|
||||||
|
|
||||||
MessageSender getMessageSender();
|
MessageSender getMessageSender();
|
||||||
|
|
||||||
IntroductionGroupFactory getIntroductionGroupFactory();
|
IntroductionGroupFactory getIntroductionGroupFactory();
|
||||||
|
|||||||
@@ -2,6 +2,11 @@ package org.briarproject;
|
|||||||
|
|
||||||
import org.briarproject.api.UniqueId;
|
import org.briarproject.api.UniqueId;
|
||||||
import org.briarproject.api.crypto.CryptoComponent;
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
|
import org.briarproject.api.crypto.PrivateKey;
|
||||||
|
import org.briarproject.api.forum.ForumConstants;
|
||||||
|
import org.briarproject.api.forum.ForumPost;
|
||||||
|
import org.briarproject.api.forum.ForumPostFactory;
|
||||||
|
import org.briarproject.api.identity.Author;
|
||||||
import org.briarproject.api.identity.AuthorFactory;
|
import org.briarproject.api.identity.AuthorFactory;
|
||||||
import org.briarproject.api.messaging.MessagingConstants;
|
import org.briarproject.api.messaging.MessagingConstants;
|
||||||
import org.briarproject.api.messaging.PrivateMessage;
|
import org.briarproject.api.messaging.PrivateMessage;
|
||||||
@@ -13,6 +18,9 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static org.briarproject.api.forum.ForumConstants.MAX_FORUM_POST_BODY_LENGTH;
|
||||||
|
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||||
|
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
|
import static org.briarproject.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
|
||||||
import static org.briarproject.api.sync.SyncConstants.MAX_PACKET_PAYLOAD_LENGTH;
|
import static org.briarproject.api.sync.SyncConstants.MAX_PACKET_PAYLOAD_LENGTH;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@@ -25,6 +33,8 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
|
|||||||
AuthorFactory authorFactory;
|
AuthorFactory authorFactory;
|
||||||
@Inject
|
@Inject
|
||||||
PrivateMessageFactory privateMessageFactory;
|
PrivateMessageFactory privateMessageFactory;
|
||||||
|
@Inject
|
||||||
|
ForumPostFactory forumPostFactory;
|
||||||
|
|
||||||
public MessageSizeIntegrationTest() throws Exception {
|
public MessageSizeIntegrationTest() throws Exception {
|
||||||
MessageSizeIntegrationTestComponent component =
|
MessageSizeIntegrationTestComponent component =
|
||||||
@@ -51,4 +61,30 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
|
|||||||
+ MAX_PRIVATE_MESSAGE_BODY_LENGTH);
|
+ MAX_PRIVATE_MESSAGE_BODY_LENGTH);
|
||||||
assertTrue(length <= MAX_PACKET_PAYLOAD_LENGTH);
|
assertTrue(length <= MAX_PACKET_PAYLOAD_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testForumPostFitsIntoPacket() throws Exception {
|
||||||
|
// Create a maximum-length author
|
||||||
|
String authorName = TestUtils.getRandomString(
|
||||||
|
MAX_AUTHOR_NAME_LENGTH);
|
||||||
|
byte[] authorPublic = new byte[MAX_PUBLIC_KEY_LENGTH];
|
||||||
|
Author author = authorFactory.createAuthor(authorName, authorPublic);
|
||||||
|
// Create a maximum-length forum post
|
||||||
|
GroupId groupId = new GroupId(TestUtils.getRandomId());
|
||||||
|
long timestamp = Long.MAX_VALUE;
|
||||||
|
MessageId parent = new MessageId(TestUtils.getRandomId());
|
||||||
|
String contentType = TestUtils.getRandomString(
|
||||||
|
ForumConstants.MAX_CONTENT_TYPE_LENGTH);
|
||||||
|
byte[] body = new byte[MAX_FORUM_POST_BODY_LENGTH];
|
||||||
|
PrivateKey privateKey = crypto.generateSignatureKeyPair().getPrivate();
|
||||||
|
ForumPost post = forumPostFactory.createPseudonymousPost(groupId,
|
||||||
|
timestamp, parent, author, contentType, body, privateKey);
|
||||||
|
// Check the size of the serialised message
|
||||||
|
int length = post.getMessage().getRaw().length;
|
||||||
|
assertTrue(length > UniqueId.LENGTH + 8 + UniqueId.LENGTH
|
||||||
|
+ MAX_AUTHOR_NAME_LENGTH + MAX_PUBLIC_KEY_LENGTH
|
||||||
|
+ ForumConstants.MAX_CONTENT_TYPE_LENGTH
|
||||||
|
+ MAX_FORUM_POST_BODY_LENGTH);
|
||||||
|
assertTrue(length <= MAX_PACKET_PAYLOAD_LENGTH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.briarproject.crypto.CryptoModule;
|
|||||||
import org.briarproject.data.DataModule;
|
import org.briarproject.data.DataModule;
|
||||||
import org.briarproject.db.DatabaseModule;
|
import org.briarproject.db.DatabaseModule;
|
||||||
import org.briarproject.event.EventModule;
|
import org.briarproject.event.EventModule;
|
||||||
|
import org.briarproject.forum.ForumModule;
|
||||||
import org.briarproject.identity.IdentityModule;
|
import org.briarproject.identity.IdentityModule;
|
||||||
import org.briarproject.messaging.MessagingModule;
|
import org.briarproject.messaging.MessagingModule;
|
||||||
import org.briarproject.sync.SyncModule;
|
import org.briarproject.sync.SyncModule;
|
||||||
@@ -24,6 +25,7 @@ import dagger.Component;
|
|||||||
DataModule.class,
|
DataModule.class,
|
||||||
DatabaseModule.class,
|
DatabaseModule.class,
|
||||||
EventModule.class,
|
EventModule.class,
|
||||||
|
ForumModule.class,
|
||||||
IdentityModule.class,
|
IdentityModule.class,
|
||||||
MessagingModule.class,
|
MessagingModule.class,
|
||||||
SyncModule.class,
|
SyncModule.class,
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
|||||||
Author bobAuthor = new Author(bobId, "Bob",
|
Author bobAuthor = new Author(bobId, "Bob",
|
||||||
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||||
ContactId contactId = contactManager.addContact(bobAuthor, aliceId,
|
ContactId contactId = contactManager.addContact(bobAuthor, aliceId,
|
||||||
master, timestamp, true, true);
|
master, timestamp, true, true, true);
|
||||||
|
|
||||||
// Send Bob a message
|
// Send Bob a message
|
||||||
GroupId groupId = messagingManager.getConversationId(contactId);
|
GroupId groupId = messagingManager.getConversationId(contactId);
|
||||||
@@ -146,7 +146,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
|||||||
Author aliceAuthor = new Author(aliceId, "Alice",
|
Author aliceAuthor = new Author(aliceId, "Alice",
|
||||||
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
new byte[MAX_PUBLIC_KEY_LENGTH]);
|
||||||
ContactId contactId = contactManager.addContact(aliceAuthor, bobId,
|
ContactId contactId = contactManager.addContact(aliceAuthor, bobId,
|
||||||
master, timestamp, false, true);
|
master, timestamp, false, true, true);
|
||||||
|
|
||||||
// Set up an event listener
|
// Set up an event listener
|
||||||
MessageListener listener = new MessageListener();
|
MessageListener listener = new MessageListener();
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
|
||||||
import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
|
import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
@@ -76,7 +75,7 @@ public class SyncIntegrationTest extends BriarTestCase {
|
|||||||
streamNumber = 123;
|
streamNumber = 123;
|
||||||
// Create a group
|
// Create a group
|
||||||
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
||||||
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
byte[] descriptor = new byte[0];
|
||||||
Group group = groupFactory.createGroup(clientId, descriptor);
|
Group group = groupFactory.createGroup(clientId, descriptor);
|
||||||
// Add two messages to the group
|
// Add two messages to the group
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
|
|||||||
11
briar-android/.tx/config
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[main]
|
||||||
|
host = https://www.transifex.com
|
||||||
|
lang_map = pt_BR: pt-rBR
|
||||||
|
|
||||||
|
[briar.stringsxml-5]
|
||||||
|
file_filter = res/values-<lang>/strings.xml
|
||||||
|
source_file = res/values/strings.xml
|
||||||
|
source_lang = en
|
||||||
|
type = ANDROID
|
||||||
|
minimum_perc = 25
|
||||||
|
|
||||||
@@ -7,8 +7,7 @@
|
|||||||
android:versionName="0.12">
|
android:versionName="0.12">
|
||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="9"
|
android:minSdkVersion="14"
|
||||||
|
|
||||||
android:targetSdkVersion="22"
|
android:targetSdkVersion="22"
|
||||||
tools:overrideLibrary="android.support.v14.preference"
|
tools:overrideLibrary="android.support.v14.preference"
|
||||||
/>
|
/>
|
||||||
@@ -51,7 +50,9 @@
|
|||||||
android:finishOnTaskLaunch="true"
|
android:finishOnTaskLaunch="true"
|
||||||
android:label="@string/crash_report_title"
|
android:label="@string/crash_report_title"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:process=":briar_error_handler">
|
android:process=":briar_error_handler"
|
||||||
|
android:theme="@style/BriarThemeNoActionBar.Default"
|
||||||
|
android:windowSoftInputMode="stateHidden">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
@@ -67,7 +68,8 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".android.SetupActivity"
|
android:name=".android.SetupActivity"
|
||||||
android:label="@string/setup_title">
|
android:label="@string/setup_title"
|
||||||
|
android:windowSoftInputMode="adjustResize">
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
@@ -98,6 +100,149 @@
|
|||||||
/>
|
/>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.sharing.InvitationsForumActivity"
|
||||||
|
android:label="@string/forum_invitations_title"
|
||||||
|
android:parentActivityName=".android.NavDrawerActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.NavDrawerActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.sharing.InvitationsBlogActivity"
|
||||||
|
android:label="@string/blogs_sharing_invitations_title"
|
||||||
|
android:parentActivityName=".android.contact.ConversationActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.contact.ConversationActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.forum.CreateForumActivity"
|
||||||
|
android:label="@string/create_forum_title"
|
||||||
|
android:parentActivityName=".android.NavDrawerActivity"
|
||||||
|
android:windowSoftInputMode="stateVisible">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.NavDrawerActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.forum.ForumActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:parentActivityName=".android.NavDrawerActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.NavDrawerActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.sharing.ShareForumActivity"
|
||||||
|
android:label="@string/activity_share_toolbar_header"
|
||||||
|
android:parentActivityName=".android.forum.ForumActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.forum.ForumActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.sharing.ShareBlogActivity"
|
||||||
|
android:label="@string/activity_share_toolbar_header"
|
||||||
|
android:parentActivityName=".android.blogs.BlogActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.blogs.BlogActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.sharing.SharingStatusForumActivity"
|
||||||
|
android:label="@string/sharing_status"
|
||||||
|
android:parentActivityName=".android.forum.ForumActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.forum.ForumActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.sharing.SharingStatusBlogActivity"
|
||||||
|
android:label="@string/sharing_status"
|
||||||
|
android:parentActivityName=".android.blogs.BlogActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.blogs.BlogActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.blogs.CreateBlogActivity"
|
||||||
|
android:label="@string/blogs_my_blogs_label"
|
||||||
|
android:parentActivityName=".android.NavDrawerActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.NavDrawerActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.blogs.BlogActivity"
|
||||||
|
android:parentActivityName=".android.NavDrawerActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.NavDrawerActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.blogs.WriteBlogPostActivity"
|
||||||
|
android:label="@string/blogs_write_blog_post"
|
||||||
|
android:parentActivityName=".android.blogs.BlogActivity"
|
||||||
|
android:windowSoftInputMode="stateVisible|adjustResize">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.blogs.BlogActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.blogs.ReblogActivity"
|
||||||
|
android:label="@string/blogs_reblog_button"
|
||||||
|
android:parentActivityName=".android.blogs.BlogActivity"
|
||||||
|
android:windowSoftInputMode="stateHidden">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.blogs.BlogActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.blogs.RssFeedImportActivity"
|
||||||
|
android:label="@string/blogs_rss_feeds_import"
|
||||||
|
android:parentActivityName=".android.NavDrawerActivity"
|
||||||
|
android:windowSoftInputMode="stateVisible|adjustResize">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.NavDrawerActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.blogs.RssFeedManageActivity"
|
||||||
|
android:label="@string/blogs_rss_feeds_manage"
|
||||||
|
android:parentActivityName=".android.NavDrawerActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.NavDrawerActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".android.identity.CreateIdentityActivity"
|
android:name=".android.identity.CreateIdentityActivity"
|
||||||
android:label="@string/new_identity_title"
|
android:label="@string/new_identity_title"
|
||||||
@@ -142,7 +287,7 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".android.SettingsActivity"
|
android:name=".android.SettingsActivity"
|
||||||
android:label="@string/settings_title"
|
android:label="@string/settings_button"
|
||||||
android:parentActivityName=".android.NavDrawerActivity">
|
android:parentActivityName=".android.NavDrawerActivity">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
@@ -154,6 +299,16 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".android.ChangePasswordActivity"
|
||||||
|
android:label="@string/change_password"
|
||||||
|
android:parentActivityName=".android.SettingsActivity">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value=".android.SettingsActivity"
|
||||||
|
/>
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".android.panic.PanicPreferencesActivity"
|
android:name=".android.panic.PanicPreferencesActivity"
|
||||||
android:label="@string/panic_setting">
|
android:label="@string/panic_setting">
|
||||||
|
|||||||
92
briar-android/artwork/trust-indicator.svg
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="49"
|
||||||
|
height="20"
|
||||||
|
viewBox="0 0 49.000004 20"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="trust-indicator.svg">
|
||||||
|
<defs
|
||||||
|
id="defs4" />
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="15.839192"
|
||||||
|
inkscape:cx="19.828141"
|
||||||
|
inkscape:cy="4.1791031"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="layer1"
|
||||||
|
showgrid="false"
|
||||||
|
units="px"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="993"
|
||||||
|
inkscape:window-x="1440"
|
||||||
|
inkscape:window-y="0"
|
||||||
|
inkscape:window-maximized="1" />
|
||||||
|
<metadata
|
||||||
|
id="metadata7">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title />
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(-216.17711,-507.04154)">
|
||||||
|
<g
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25px;line-height:125%;font-family:FreeSans;-inkscape-font-specification:FreeSans;letter-spacing:0px;word-spacing:0px;fill:#b7b7b7;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
id="text4136"
|
||||||
|
transform="matrix(1,0,0,0.90497738,-18.96574,55.694085)">
|
||||||
|
<path
|
||||||
|
d="m 250.64285,514.07648 0,-2.275 -2.55,0 0,-3.8 2.55,0 0,-2.275 -2.55,0 0,-4.225 -2.375,0 0,4.225 -3.15,0 0,-4.225 -2.375,0 0,4.225 -2.55,0 0,2.275 2.55,0 0,3.8 -2.55,0 0,2.275 2.55,0 0,4 2.375,0 0,-4 3.15,0 0,4 2.375,0 0,-4 2.55,0 z m -4.925,-2.275 -3.15,0 0,-3.8 3.15,0 0,3.8 z"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;font-family:Titillium;-inkscape-font-specification:'Titillium Semi-Bold';fill:#b7b7b7;fill-opacity:1"
|
||||||
|
id="path4745"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
transform="matrix(1,0,0,0.90497738,-3.4657389,55.694085)"
|
||||||
|
id="g4755"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25px;line-height:125%;font-family:FreeSans;-inkscape-font-specification:FreeSans;letter-spacing:0px;word-spacing:0px;fill:#b7b7b7;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1">
|
||||||
|
<path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="path4757"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;font-family:Titillium;-inkscape-font-specification:'Titillium Semi-Bold';fill:#b7b7b7;fill-opacity:1"
|
||||||
|
d="m 250.64285,514.07648 0,-2.275 -2.55,0 0,-3.8 2.55,0 0,-2.275 -2.55,0 0,-4.225 -2.375,0 0,4.225 -3.15,0 0,-4.225 -2.375,0 0,4.225 -2.55,0 0,2.275 2.55,0 0,3.8 -2.55,0 0,2.275 2.55,0 0,4 2.375,0 0,-4 3.15,0 0,4 2.375,0 0,-4 2.55,0 z m -4.925,-2.275 -3.15,0 0,-3.8 3.15,0 0,3.8 z" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25px;line-height:125%;font-family:FreeSans;-inkscape-font-specification:FreeSans;letter-spacing:0px;word-spacing:0px;fill:#b7b7b7;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
id="g4139"
|
||||||
|
transform="matrix(1,0,0,0.90497738,12.034262,55.694085)">
|
||||||
|
<path
|
||||||
|
d="m 250.64285,514.07648 0,-2.275 -2.55,0 0,-3.8 2.55,0 0,-2.275 -2.55,0 0,-4.225 -2.375,0 0,4.225 -3.15,0 0,-4.225 -2.375,0 0,4.225 -2.55,0 0,2.275 2.55,0 0,3.8 -2.55,0 0,2.275 2.55,0 0,4 2.375,0 0,-4 3.15,0 0,4 2.375,0 0,-4 2.55,0 z m -4.925,-2.275 -3.15,0 0,-3.8 3.15,0 0,3.8 z"
|
||||||
|
style="font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;font-family:Titillium;-inkscape-font-specification:'Titillium Semi-Bold';fill:#b7b7b7;fill-opacity:1"
|
||||||
|
id="path4141"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.6 KiB |
@@ -6,35 +6,25 @@ apply plugin: 'witness'
|
|||||||
apply plugin: 'com.neenbedankt.android-apt'
|
apply plugin: 'com.neenbedankt.android-apt'
|
||||||
apply plugin: 'de.undercouch.download'
|
apply plugin: 'de.undercouch.download'
|
||||||
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
def supportVersion = '23.2.1'
|
def supportVersion = '23.2.1'
|
||||||
compile project(':briar-api')
|
compile project(':briar-api')
|
||||||
compile project(':briar-core')
|
compile project(':briar-core')
|
||||||
compile fileTree(dir: 'libs', include: '*.jar')
|
compile fileTree(dir: 'libs', include: '*.jar')
|
||||||
// This shouldn't be necessary; per section 23.4.4 of the Gradle docs:
|
|
||||||
// "file dependencies are included in transitive project dependencies within the same build".
|
|
||||||
compile files('../briar-core/libs/jsocks.jar')
|
|
||||||
compile "com.android.support:support-v4:$supportVersion"
|
compile "com.android.support:support-v4:$supportVersion"
|
||||||
compile("com.android.support:appcompat-v7:$supportVersion") {
|
compile("com.android.support:appcompat-v7:$supportVersion") {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
}
|
}
|
||||||
compile("com.android.support:preference-v7:$supportVersion") {
|
|
||||||
exclude module: 'support-v4'
|
|
||||||
}
|
|
||||||
compile("com.android.support:preference-v14:$supportVersion") {
|
compile("com.android.support:preference-v14:$supportVersion") {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
exclude module: 'preference-v7'
|
|
||||||
exclude module: 'recyclerview-v7'
|
|
||||||
}
|
}
|
||||||
compile("com.android.support:design:$supportVersion") {
|
compile("com.android.support:design:$supportVersion") {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
exclude module: 'recyclerview-v7'
|
exclude module: 'recyclerview-v7'
|
||||||
}
|
}
|
||||||
|
compile "com.android.support:cardview-v7:$supportVersion"
|
||||||
compile('ch.acra:acra:4.8.5') {
|
compile('ch.acra:acra:4.8.5') {
|
||||||
exclude module: 'support-v4'
|
exclude module: 'support-v4'
|
||||||
exclude module: 'support-annotations'
|
exclude module: 'support-annotations'
|
||||||
@@ -52,11 +42,6 @@ dependencies {
|
|||||||
testCompile project(path: ':briar-tests')
|
testCompile project(path: ':briar-tests')
|
||||||
testCompile 'org.robolectric:robolectric:3.0'
|
testCompile 'org.robolectric:robolectric:3.0'
|
||||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||||
|
|
||||||
androidTestCompile 'org.robolectric:robolectric:3.0'
|
|
||||||
androidTestCompile 'org.mockito:mockito-core:1.10.19'
|
|
||||||
androidTestApt 'com.google.dagger:dagger-compiler:2.0.2'
|
|
||||||
androidTestCompile 'junit:junit:4.12'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyVerification {
|
dependencyVerification {
|
||||||
@@ -68,13 +53,13 @@ dependencyVerification {
|
|||||||
'com.google.zxing:core:b4d82452e7a6bf6ec2698904b332431717ed8f9a850224f295aec89de80f2259',
|
'com.google.zxing:core:b4d82452e7a6bf6ec2698904b332431717ed8f9a850224f295aec89de80f2259',
|
||||||
'com.android.support:support-v4:81ce890f26d35c75ad17d0f998a7e3230330c3b41e0b629566bc744bee89e448',
|
'com.android.support:support-v4:81ce890f26d35c75ad17d0f998a7e3230330c3b41e0b629566bc744bee89e448',
|
||||||
'com.android.support:appcompat-v7:00f9d93acacd6731f309724054bf51492814b4b2869f16d7d5c0038dcb8c9a0d',
|
'com.android.support:appcompat-v7:00f9d93acacd6731f309724054bf51492814b4b2869f16d7d5c0038dcb8c9a0d',
|
||||||
'com.android.support:preference-v7:775101bd07bd052e455761c5c5d9523d7ad59f2f320e3e8cbde241fd6b1d6025',
|
|
||||||
'com.android.support:preference-v14:44881bb46094e86d0bc2426f205419674a5b4eb514b44b5a4659b5de29f71eb7',
|
'com.android.support:preference-v14:44881bb46094e86d0bc2426f205419674a5b4eb514b44b5a4659b5de29f71eb7',
|
||||||
'com.android.support:design:003e0c0bea0a6891f8b2bc43f20ae7af2a49a17363e5bb10df5ee0bae12fa686',
|
'com.android.support:design:003e0c0bea0a6891f8b2bc43f20ae7af2a49a17363e5bb10df5ee0bae12fa686',
|
||||||
'com.android.support:support-annotations:786ab0d060774fb95cfdaf4878771e14b85733b1af9d72a4aae762dc7c1dff9f',
|
'com.android.support:support-annotations:786ab0d060774fb95cfdaf4878771e14b85733b1af9d72a4aae762dc7c1dff9f',
|
||||||
'com.android.support:animated-vector-drawable:06d1963b85aa917099d7757e6a7b3e4dc06889413dc747f625ae8683606db3a1',
|
'com.android.support:animated-vector-drawable:06d1963b85aa917099d7757e6a7b3e4dc06889413dc747f625ae8683606db3a1',
|
||||||
'com.android.support:support-vector-drawable:799bafe4c3de812386f0b291f744d5d6876452722dd40189b9ab87dbbf594ea1',
|
'com.android.support:support-vector-drawable:799bafe4c3de812386f0b291f744d5d6876452722dd40189b9ab87dbbf594ea1',
|
||||||
'com.android.support:recyclerview-v7:44040a888e23e0c93162a3377cfe06751080e3c22d369ab0d4301ef60d63b0fe',
|
'com.android.support:recyclerview-v7:44040a888e23e0c93162a3377cfe06751080e3c22d369ab0d4301ef60d63b0fe',
|
||||||
|
'com.android.support:cardview-v7:4595f1c4a28cfa083b6c0920ad4d49e1c2ca4b8302a955e548f68eb63b74931b',
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,6 +67,10 @@ android {
|
|||||||
compileSdkVersion 23
|
compileSdkVersion 23
|
||||||
buildToolsVersion "23.0.3"
|
buildToolsVersion "23.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
resValue "string", "app_package", "org.briarproject"
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main {
|
main {
|
||||||
manifest.srcFile 'AndroidManifest.xml'
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
@@ -105,24 +94,16 @@ android {
|
|||||||
unitTests.returnDefaultValues = true
|
unitTests.returnDefaultValues = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Move the build types to build-types/<type>
|
|
||||||
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
|
|
||||||
// This moves them out of them default location under src/<type>/... which would
|
|
||||||
// conflict with src/ being used by the main source set.
|
|
||||||
// Adding new build types or product flavors should be accompanied
|
|
||||||
// by a similar customization.
|
|
||||||
debug.setRoot('build-types/debug')
|
|
||||||
release.setRoot('build-types/release')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
|
shrinkResources false
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
|
shrinkResources true
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
|
||||||
}
|
}
|
||||||
@@ -134,8 +115,10 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
abortOnError false
|
warning 'MissingTranslation'
|
||||||
|
warning 'ImpliedQuantity'
|
||||||
}
|
}
|
||||||
|
|
||||||
dexOptions {
|
dexOptions {
|
||||||
incremental true
|
incremental true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
-dontobfuscate
|
-dontobfuscate
|
||||||
-verbose
|
-verbose
|
||||||
-useuniqueclassmembernames
|
-useuniqueclassmembernames
|
||||||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
#-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||||
# For comfortability in case we do obfuscate
|
# For comfortability in case we do obfuscate
|
||||||
# -renamesourcefileattribute SourceFile
|
# -renamesourcefileattribute SourceFile
|
||||||
-keepattributes SourceFile, LineNumberTable, *Annotation*, Signature, InnerClasses, EnclosingMethod
|
-keepattributes SourceFile, LineNumberTable, *Annotation*, Signature, InnerClasses, EnclosingMethod
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
-keep public class * extends android.app.Service
|
-keep public class * extends android.app.Service
|
||||||
-keep public class * extends android.content.BroadcastReceiver
|
-keep public class * extends android.content.BroadcastReceiver
|
||||||
-keep public class * extends android.content.ContentProvider
|
-keep public class * extends android.content.ContentProvider
|
||||||
-keep public class com.android.vending.licensing.ILicensingService
|
|
||||||
-keepclasseswithmembers class * { native <methods>; }
|
-keepclasseswithmembers class * { native <methods>; }
|
||||||
-keepclasseswithmembers class * {
|
-keepclasseswithmembers class * {
|
||||||
public <init> (android.content.Context, android.util.AttributeSet);
|
public <init> (android.content.Context, android.util.AttributeSet);
|
||||||
@@ -32,31 +31,32 @@
|
|||||||
-keepclassmembers class * extends android.app.Activity {
|
-keepclassmembers class * extends android.app.Activity {
|
||||||
public void *(android.view.View);
|
public void *(android.view.View);
|
||||||
}
|
}
|
||||||
-keepclassmembers class * {
|
|
||||||
@com.google.inject.Inject <init>(...);
|
|
||||||
@com.google.inject.Inject <fields>;
|
|
||||||
}
|
|
||||||
# Just in case Roboguice events are used
|
|
||||||
-keepclassmembers class * {
|
|
||||||
void *(**On*Event);
|
|
||||||
}
|
|
||||||
|
|
||||||
-keep class org.h2.** { *; }
|
-keep class org.h2.** { *; }
|
||||||
-keep class org.briarproject.** { *; }
|
-keep class org.briarproject.** { *; }
|
||||||
-keep class com.google.inject.** { *; }
|
|
||||||
-keep class javax.inject.** { *; }
|
-keep class javax.inject.** { *; }
|
||||||
-keep class javax.annotation.** { *; }
|
|
||||||
-keep class roboguice.** { *; }
|
|
||||||
-keep class dagger.** { *; }
|
-keep class dagger.** { *; }
|
||||||
-keep class com.google.** { *; }
|
-keep class com.google.zxing.Result
|
||||||
|
|
||||||
-dontwarn org.h2.**
|
-dontwarn org.h2.**
|
||||||
-dontnote org.h2.**
|
-dontnote org.h2.**
|
||||||
-dontwarn net.sf.cglib.**
|
-dontwarn net.sf.cglib.**
|
||||||
-dontwarn org.briarproject.plugins.tcp.**
|
-dontwarn org.briarproject.plugins.tcp.**
|
||||||
-dontwarn roboguice.**
|
-dontnote org.briarproject.crypto.**
|
||||||
|
-dontnote org.spongycastle.crypto.parsers.ECIESPublicKeyParser
|
||||||
-dontwarn net.sourceforge.jsocks.**
|
-dontwarn net.sourceforge.jsocks.**
|
||||||
-dontnote android.support.**
|
-dontnote android.support.**
|
||||||
-dontnote dagger.**
|
-dontnote dagger.**
|
||||||
-dontwarn dagger.**
|
-dontwarn dagger.**
|
||||||
|
-dontnote com.google.common.**
|
||||||
-dontwarn com.google.common.**
|
-dontwarn com.google.common.**
|
||||||
|
|
||||||
|
# RSS libraries
|
||||||
|
-keep class com.rometools.rome.feed.synd.impl.** { *;}
|
||||||
|
-keep class com.rometools.rome.io.impl.** { *;}
|
||||||
|
-dontnote com.rometools.rome.**
|
||||||
|
-dontwarn javax.xml.stream.**
|
||||||
|
-dontwarn org.jaxen.**
|
||||||
|
-dontwarn java.nio.**
|
||||||
|
-dontwarn org.codehaus.mojo.animal_sniffer.**
|
||||||
|
-dontwarn org.slf4j.impl.**
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 975 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1009 B |
|
Before Width: | Height: | Size: 366 B |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 2.1 KiB |
BIN
briar-android/res/drawable-hdpi/msg_in_top.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 2.1 KiB |
BIN
briar-android/res/drawable-hdpi/msg_out_top.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 2.0 KiB |
BIN
briar-android/res/drawable-hdpi/notice_in_bottom.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 2.0 KiB |
BIN
briar-android/res/drawable-hdpi/notice_out_bottom.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 210 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 362 B |
|
Before Width: | Height: | Size: 708 B |
|
Before Width: | Height: | Size: 713 B |
|
Before Width: | Height: | Size: 531 B |
|
Before Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 1.9 KiB |
BIN
briar-android/res/drawable-mdpi/msg_in_top.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1014 B |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 1.8 KiB |
BIN
briar-android/res/drawable-mdpi/msg_out_top.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
briar-android/res/drawable-mdpi/notice_in_bottom.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
briar-android/res/drawable-mdpi/notice_out_bottom.9.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
@@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
A FAB does not work, because even with fabSize="mini" it will be too big due to shadow drawing
|
|
||||||
on lower API levels
|
|
||||||
-->
|
|
||||||
<ripple
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:color="@color/briar_primary_dark">
|
|
||||||
|
|
||||||
<item>
|
|
||||||
<shape android:shape="oval">
|
|
||||||
<solid android:color="@color/briar_primary"/>
|
|
||||||
</shape>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
</ripple>
|
|
||||||
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 853 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 515 B |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 2.7 KiB |
BIN
briar-android/res/drawable-xhdpi/msg_in_top.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 2.6 KiB |
BIN
briar-android/res/drawable-xhdpi/msg_out_top.9.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 2.4 KiB |
BIN
briar-android/res/drawable-xhdpi/notice_in_bottom.9.png
Normal file
|
After Width: | Height: | Size: 16 KiB |