Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
briar
briar
Commits
1bf0fdfa
Verified
Commit
1bf0fdfa
authored
Sep 21, 2017
by
Torsten Grote
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add an option to debug builds to create fake test data
parent
237759aa
Pipeline
#649
passed with stage
in 5 minutes and 47 seconds
Changes
47
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
676 additions
and
126 deletions
+676
-126
bramble-android/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java
...n/java/org/briarproject/bramble/plugin/tor/TorPlugin.java
+1
-1
bramble-api/src/main/java/org/briarproject/bramble/api/plugin/LanTcpConstants.java
.../org/briarproject/bramble/api/plugin/LanTcpConstants.java
+5
-0
bramble-api/src/main/java/org/briarproject/bramble/api/plugin/TorConstants.java
...ava/org/briarproject/bramble/api/plugin/TorConstants.java
+3
-0
bramble-api/src/main/java/org/briarproject/bramble/util/StringUtils.java
.../main/java/org/briarproject/bramble/util/StringUtils.java
+10
-0
bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java
...rc/test/java/org/briarproject/bramble/test/TestUtils.java
+0
-7
bramble-core/src/main/java/org/briarproject/bramble/plugin/tcp/LanTcpPlugin.java
...ava/org/briarproject/bramble/plugin/tcp/LanTcpPlugin.java
+1
-1
bramble-core/src/test/java/org/briarproject/bramble/client/ClientHelperImplTest.java
...org/briarproject/bramble/client/ClientHelperImplTest.java
+2
-2
bramble-core/src/test/java/org/briarproject/bramble/crypto/HashTest.java
...c/test/java/org/briarproject/bramble/crypto/HashTest.java
+3
-2
bramble-core/src/test/java/org/briarproject/bramble/crypto/SignatureTest.java
...t/java/org/briarproject/bramble/crypto/SignatureTest.java
+4
-3
bramble-core/src/test/java/org/briarproject/bramble/data/BdfReaderImplTest.java
...java/org/briarproject/bramble/data/BdfReaderImplTest.java
+10
-11
bramble-core/src/test/java/org/briarproject/bramble/data/BdfWriterImplTest.java
...java/org/briarproject/bramble/data/BdfWriterImplTest.java
+4
-4
bramble-core/src/test/java/org/briarproject/bramble/db/BasicH2Test.java
...rc/test/java/org/briarproject/bramble/db/BasicH2Test.java
+5
-4
bramble-core/src/test/java/org/briarproject/bramble/db/DatabaseComponentImplTest.java
...rg/briarproject/bramble/db/DatabaseComponentImplTest.java
+2
-1
bramble-core/src/test/java/org/briarproject/bramble/db/H2DatabaseTest.java
...test/java/org/briarproject/bramble/db/H2DatabaseTest.java
+2
-1
bramble-core/src/test/java/org/briarproject/bramble/identity/IdentityManagerImplTest.java
...riarproject/bramble/identity/IdentityManagerImplTest.java
+5
-3
bramble-core/src/test/java/org/briarproject/bramble/properties/TransportPropertyValidatorTest.java
...ct/bramble/properties/TransportPropertyValidatorTest.java
+3
-2
bramble-core/src/test/java/org/briarproject/bramble/sync/SyncIntegrationTest.java
...va/org/briarproject/bramble/sync/SyncIntegrationTest.java
+2
-1
bramble-core/src/test/java/org/briarproject/bramble/sync/ValidationManagerImplTest.java
.../briarproject/bramble/sync/ValidationManagerImplTest.java
+2
-1
bramble-core/src/test/java/org/briarproject/bramble/test/ValidatorTestCase.java
...java/org/briarproject/bramble/test/ValidatorTestCase.java
+2
-1
briar-android/src/main/java/org/briarproject/briar/android/AndroidComponent.java
...java/org/briarproject/briar/android/AndroidComponent.java
+3
-3
briar-android/src/main/java/org/briarproject/briar/android/activity/ActivityComponent.java
...riarproject/briar/android/activity/ActivityComponent.java
+3
-0
briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsActivity.java
...briarproject/briar/android/settings/SettingsActivity.java
+0
-24
briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsFragment.java
...briarproject/briar/android/settings/SettingsFragment.java
+35
-8
briar-android/src/main/res/xml/settings.xml
briar-android/src/main/res/xml/settings.xml
+4
-0
briar-api/src/main/java/org/briarproject/briar/api/test/TestDataCreator.java
...java/org/briarproject/briar/api/test/TestDataCreator.java
+11
-0
briar-core/src/main/java/org/briarproject/briar/BriarCoreEagerSingletons.java
...java/org/briarproject/briar/BriarCoreEagerSingletons.java
+1
-0
briar-core/src/main/java/org/briarproject/briar/BriarCoreModule.java
...src/main/java/org/briarproject/briar/BriarCoreModule.java
+3
-1
briar-core/src/main/java/org/briarproject/briar/test/TestData.java
...e/src/main/java/org/briarproject/briar/test/TestData.java
+68
-0
briar-core/src/main/java/org/briarproject/briar/test/TestDataCreatorImpl.java
...java/org/briarproject/briar/test/TestDataCreatorImpl.java
+409
-0
briar-core/src/main/java/org/briarproject/briar/test/TestModule.java
...src/main/java/org/briarproject/briar/test/TestModule.java
+19
-0
briar-core/src/test/java/org/briarproject/briar/blog/BlogManagerImplTest.java
...java/org/briarproject/briar/blog/BlogManagerImplTest.java
+1
-1
briar-core/src/test/java/org/briarproject/briar/blog/BlogManagerIntegrationTest.java
...g/briarproject/briar/blog/BlogManagerIntegrationTest.java
+1
-1
briar-core/src/test/java/org/briarproject/briar/blog/BlogPostValidatorTest.java
...va/org/briarproject/briar/blog/BlogPostValidatorTest.java
+2
-1
briar-core/src/test/java/org/briarproject/briar/client/MessageQueueManagerImplTest.java
...riarproject/briar/client/MessageQueueManagerImplTest.java
+2
-1
briar-core/src/test/java/org/briarproject/briar/forum/ForumPostValidatorTest.java
.../org/briarproject/briar/forum/ForumPostValidatorTest.java
+6
-5
briar-core/src/test/java/org/briarproject/briar/introduction/IntroductionIntegrationTest.java
...oject/briar/introduction/IntroductionIntegrationTest.java
+2
-1
briar-core/src/test/java/org/briarproject/briar/introduction/IntroductionManagerImplTest.java
...oject/briar/introduction/IntroductionManagerImplTest.java
+2
-1
briar-core/src/test/java/org/briarproject/briar/introduction/IntroductionValidatorTest.java
...project/briar/introduction/IntroductionValidatorTest.java
+15
-14
briar-core/src/test/java/org/briarproject/briar/introduction/MessageSenderTest.java
...rg/briarproject/briar/introduction/MessageSenderTest.java
+2
-1
briar-core/src/test/java/org/briarproject/briar/messaging/MessageSizeIntegrationTest.java
...arproject/briar/messaging/MessageSizeIntegrationTest.java
+2
-2
briar-core/src/test/java/org/briarproject/briar/messaging/PrivateMessageValidatorTest.java
...rproject/briar/messaging/PrivateMessageValidatorTest.java
+3
-3
briar-core/src/test/java/org/briarproject/briar/privategroup/GroupMessageValidatorTest.java
...project/briar/privategroup/GroupMessageValidatorTest.java
+1
-1
briar-core/src/test/java/org/briarproject/briar/privategroup/invitation/GroupInvitationManagerImplTest.java
...ivategroup/invitation/GroupInvitationManagerImplTest.java
+1
-1
briar-core/src/test/java/org/briarproject/briar/privategroup/invitation/GroupInvitationValidatorTest.java
...privategroup/invitation/GroupInvitationValidatorTest.java
+1
-1
briar-core/src/test/java/org/briarproject/briar/sharing/BlogSharingValidatorTest.java
.../briarproject/briar/sharing/BlogSharingValidatorTest.java
+6
-5
briar-core/src/test/java/org/briarproject/briar/sharing/ForumSharingIntegrationTest.java
...iarproject/briar/sharing/ForumSharingIntegrationTest.java
+1
-1
briar-core/src/test/java/org/briarproject/briar/sharing/ForumSharingValidatorTest.java
...briarproject/briar/sharing/ForumSharingValidatorTest.java
+6
-5
No files found.
bramble-android/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java
View file @
1bf0fdfa
...
...
@@ -84,13 +84,13 @@ import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_NETWORK_
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
TorConstants
.
PREF_TOR_NETWORK_NEVER
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
TorConstants
.
PREF_TOR_NETWORK_WIFI
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
TorConstants
.
PREF_TOR_PORT
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
TorConstants
.
PROP_ONION
;
import
static
org
.
briarproject
.
bramble
.
util
.
PrivacyUtils
.
scrubOnion
;
@MethodsNotNullByDefault
@ParametersNotNullByDefault
class
TorPlugin
implements
DuplexPlugin
,
EventHandler
,
EventListener
{
private
static
final
String
PROP_ONION
=
"onion"
;
private
static
final
String
[]
EVENTS
=
{
"CIRC"
,
"ORCONN"
,
"HS_DESC"
,
"NOTICE"
,
"WARN"
,
"ERR"
};
...
...
bramble-api/src/main/java/org/briarproject/bramble/api/plugin/LanTcpConstants.java
View file @
1bf0fdfa
...
...
@@ -4,5 +4,10 @@ public interface LanTcpConstants {
TransportId
ID
=
new
TransportId
(
"org.briarproject.bramble.lan"
);
// a transport property (shared with contacts)
String
PROP_IP_PORTS
=
"ipPorts"
;
// a local setting
String
PREF_LAN_IP_PORTS
=
"ipPorts"
;
}
bramble-api/src/main/java/org/briarproject/bramble/api/plugin/TorConstants.java
View file @
1bf0fdfa
...
...
@@ -4,6 +4,8 @@ public interface TorConstants {
TransportId
ID
=
new
TransportId
(
"org.briarproject.bramble.tor"
);
String
PROP_ONION
=
"onion"
;
int
SOCKS_PORT
=
59050
;
int
CONTROL_PORT
=
59051
;
...
...
@@ -16,4 +18,5 @@ public interface TorConstants {
int
PREF_TOR_NETWORK_NEVER
=
0
;
int
PREF_TOR_NETWORK_WIFI
=
1
;
int
PREF_TOR_NETWORK_ALWAYS
=
2
;
}
bramble-api/src/main/java/org/briarproject/bramble/util/StringUtils.java
View file @
1bf0fdfa
...
...
@@ -8,6 +8,7 @@ import java.nio.charset.CharacterCodingException;
import
java.nio.charset.Charset
;
import
java.nio.charset.CharsetDecoder
;
import
java.util.Collection
;
import
java.util.Random
;
import
java.util.regex.Pattern
;
import
javax.annotation.Nullable
;
...
...
@@ -27,6 +28,7 @@ public class StringUtils {
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
private
static
final
Random
random
=
new
Random
();
public
static
boolean
isNullOrEmpty
(
@Nullable
String
s
)
{
return
s
==
null
||
s
.
length
()
==
0
;
...
...
@@ -139,4 +141,12 @@ public class StringUtils {
}
return
s
.
toString
();
}
public
static
String
getRandomString
(
int
length
)
{
char
[]
c
=
new
char
[
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
c
[
i
]
=
(
char
)
(
'a'
+
random
.
nextInt
(
26
));
return
new
String
(
c
);
}
}
bramble-api/src/test/java/org/briarproject/bramble/test/TestUtils.java
View file @
1bf0fdfa
...
...
@@ -34,13 +34,6 @@ public class TestUtils {
return
getRandomBytes
(
UniqueId
.
LENGTH
);
}
public
static
String
getRandomString
(
int
length
)
{
char
[]
c
=
new
char
[
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
c
[
i
]
=
(
char
)
(
'a'
+
random
.
nextInt
(
26
));
return
new
String
(
c
);
}
public
static
SecretKey
getSecretKey
()
{
return
new
SecretKey
(
getRandomBytes
(
SecretKey
.
LENGTH
));
}
...
...
bramble-core/src/main/java/org/briarproject/bramble/plugin/tcp/LanTcpPlugin.java
View file @
1bf0fdfa
...
...
@@ -35,6 +35,7 @@ import static java.util.logging.Level.WARNING;
import
static
org
.
briarproject
.
bramble
.
api
.
keyagreement
.
KeyAgreementConstants
.
TRANSPORT_ID_LAN
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
LanTcpConstants
.
ID
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
LanTcpConstants
.
PREF_LAN_IP_PORTS
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
LanTcpConstants
.
PROP_IP_PORTS
;
import
static
org
.
briarproject
.
bramble
.
util
.
ByteUtils
.
MAX_16_BIT_UNSIGNED
;
import
static
org
.
briarproject
.
bramble
.
util
.
PrivacyUtils
.
scrubSocketAddress
;
...
...
@@ -45,7 +46,6 @@ class LanTcpPlugin extends TcpPlugin {
Logger
.
getLogger
(
LanTcpPlugin
.
class
.
getName
());
private
static
final
int
MAX_ADDRESSES
=
4
;
private
static
final
String
PROP_IP_PORTS
=
"ipPorts"
;
private
static
final
String
SEPARATOR
=
","
;
LanTcpPlugin
(
Executor
ioExecutor
,
Backoff
backoff
,
...
...
bramble-core/src/test/java/org/briarproject/bramble/client/ClientHelperImplTest.java
View file @
1bf0fdfa
...
...
@@ -20,7 +20,7 @@ import org.briarproject.bramble.api.sync.Message;
import
org.briarproject.bramble.api.sync.MessageFactory
;
import
org.briarproject.bramble.api.sync.MessageId
;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.
test.Test
Utils
;
import
org.briarproject.bramble.
util.String
Utils
;
import
org.jmock.Expectations
;
import
org.jmock.Mockery
;
import
org.junit.Test
;
...
...
@@ -65,7 +65,7 @@ public class ClientHelperImplTest extends BrambleTestCase {
new
Message
(
messageId
,
groupId
,
timestamp
,
rawMessage
);
private
final
Metadata
metadata
=
new
Metadata
();
private
final
BdfList
list
=
BdfList
.
of
(
"Sign this!"
,
getRandomBytes
(
42
));
private
final
String
label
=
Test
Utils
.
getRandomString
(
5
);
private
final
String
label
=
String
Utils
.
getRandomString
(
5
);
public
ClientHelperImplTest
()
{
clientHelper
=
...
...
bramble-core/src/test/java/org/briarproject/bramble/crypto/HashTest.java
View file @
1bf0fdfa
...
...
@@ -4,6 +4,7 @@ import org.briarproject.bramble.api.crypto.CryptoComponent;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.test.TestSecureRandomProvider
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.junit.Test
;
import
java.util.Arrays
;
...
...
@@ -15,7 +16,7 @@ public class HashTest extends BrambleTestCase {
private
final
CryptoComponent
crypto
;
private
final
String
label
=
Test
Utils
.
getRandomString
(
42
);
private
final
String
label
=
String
Utils
.
getRandomString
(
42
);
private
final
byte
[]
inputBytes
=
TestUtils
.
getRandomBytes
(
123
);
private
final
byte
[]
inputBytes1
=
TestUtils
.
getRandomBytes
(
234
);
private
final
byte
[]
inputBytes2
=
new
byte
[
0
];
...
...
@@ -40,7 +41,7 @@ public class HashTest extends BrambleTestCase {
@Test
public
void
testDifferentLabelsProduceDifferentHashes
()
{
String
label2
=
Test
Utils
.
getRandomString
(
42
);
String
label2
=
String
Utils
.
getRandomString
(
42
);
byte
[]
hash1
=
crypto
.
hash
(
label
,
inputBytes
,
inputBytes1
,
inputBytes2
);
byte
[]
hash2
=
crypto
.
hash
(
label2
,
inputBytes
,
inputBytes1
,
inputBytes2
);
...
...
bramble-core/src/test/java/org/briarproject/bramble/crypto/SignatureTest.java
View file @
1bf0fdfa
...
...
@@ -5,6 +5,7 @@ import org.briarproject.bramble.api.crypto.KeyPair;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.test.TestSecureRandomProvider
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.junit.Test
;
import
java.util.Arrays
;
...
...
@@ -18,7 +19,7 @@ public class SignatureTest extends BrambleTestCase {
private
final
CryptoComponent
crypto
;
private
final
byte
[]
publicKey
,
privateKey
;
private
final
String
label
=
Test
Utils
.
getRandomString
(
42
);
private
final
String
label
=
String
Utils
.
getRandomString
(
42
);
private
final
byte
[]
inputBytes
=
TestUtils
.
getRandomBytes
(
123
);
public
SignatureTest
()
{
...
...
@@ -64,7 +65,7 @@ public class SignatureTest extends BrambleTestCase {
public
void
testDifferentLabelsProduceDifferentSignatures
()
throws
Exception
{
// Generate a second label
String
label2
=
Test
Utils
.
getRandomString
(
42
);
String
label2
=
String
Utils
.
getRandomString
(
42
);
// Calculate the signature with different inputs
// the results should be different
byte
[]
sig1
=
crypto
.
sign
(
label
,
inputBytes
,
privateKey
);
...
...
@@ -100,7 +101,7 @@ public class SignatureTest extends BrambleTestCase {
@Test
public
void
testDifferentLabelFailsVerification
()
throws
Exception
{
// Generate a second label
String
label2
=
Test
Utils
.
getRandomString
(
42
);
String
label2
=
String
Utils
.
getRandomString
(
42
);
// calculate the signature with different label, should fail to verify
byte
[]
sig
=
crypto
.
sign
(
label
,
inputBytes
,
privateKey
);
assertFalse
(
crypto
.
verify
(
label2
,
inputBytes
,
publicKey
,
sig
));
...
...
bramble-core/src/test/java/org/briarproject/bramble/data/BdfReaderImplTest.java
View file @
1bf0fdfa
...
...
@@ -4,7 +4,6 @@ import org.briarproject.bramble.api.FormatException;
import
org.briarproject.bramble.api.data.BdfDictionary
;
import
org.briarproject.bramble.api.data.BdfList
;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.junit.Test
;
...
...
@@ -159,7 +158,7 @@ public class BdfReaderImplTest extends BrambleTestCase {
@Test
public
void
testReadString8
()
throws
Exception
{
String
longest
=
Test
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
);
String
longest
=
String
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
);
String
longHex
=
StringUtils
.
toHexString
(
longest
.
getBytes
(
"UTF-8"
));
// "foo", the empty string, and 127 random letters
setContents
(
"41"
+
"03"
+
"666F6F"
+
"41"
+
"00"
+
...
...
@@ -181,7 +180,7 @@ public class BdfReaderImplTest extends BrambleTestCase {
@Test
public
void
testSkipString8
()
throws
Exception
{
String
longest
=
Test
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
);
String
longest
=
String
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
);
String
longHex
=
StringUtils
.
toHexString
(
longest
.
getBytes
(
"UTF-8"
));
// "foo", the empty string, and 127 random letters
setContents
(
"41"
+
"03"
+
"666F6F"
+
"41"
+
"00"
+
...
...
@@ -194,9 +193,9 @@ public class BdfReaderImplTest extends BrambleTestCase {
@Test
public
void
testReadString16
()
throws
Exception
{
String
shortest
=
Test
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
+
1
);
String
shortest
=
String
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
+
1
);
String
shortHex
=
StringUtils
.
toHexString
(
shortest
.
getBytes
(
"UTF-8"
));
String
longest
=
Test
Utils
.
getRandomString
(
Short
.
MAX_VALUE
);
String
longest
=
String
Utils
.
getRandomString
(
Short
.
MAX_VALUE
);
String
longHex
=
StringUtils
.
toHexString
(
longest
.
getBytes
(
"UTF-8"
));
// 128 random letters and 2^15 -1 random letters
setContents
(
"42"
+
"0080"
+
shortHex
+
"42"
+
"7FFF"
+
longHex
);
...
...
@@ -207,7 +206,7 @@ public class BdfReaderImplTest extends BrambleTestCase {
@Test
(
expected
=
FormatException
.
class
)
public
void
testReadString16ChecksMaxLength
()
throws
Exception
{
String
shortest
=
Test
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
+
1
);
String
shortest
=
String
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
+
1
);
String
shortHex
=
StringUtils
.
toHexString
(
shortest
.
getBytes
(
"UTF-8"
));
// 128 random letters, twice
setContents
(
"42"
+
"0080"
+
shortHex
+
"42"
+
"0080"
+
shortHex
);
...
...
@@ -218,9 +217,9 @@ public class BdfReaderImplTest extends BrambleTestCase {
@Test
public
void
testSkipString16
()
throws
Exception
{
String
shortest
=
Test
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
+
1
);
String
shortest
=
String
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
+
1
);
String
shortHex
=
StringUtils
.
toHexString
(
shortest
.
getBytes
(
"UTF-8"
));
String
longest
=
Test
Utils
.
getRandomString
(
Short
.
MAX_VALUE
);
String
longest
=
String
Utils
.
getRandomString
(
Short
.
MAX_VALUE
);
String
longHex
=
StringUtils
.
toHexString
(
longest
.
getBytes
(
"UTF-8"
));
// 128 random letters and 2^15 - 1 random letters
setContents
(
"42"
+
"0080"
+
shortHex
+
"42"
+
"7FFF"
+
longHex
);
...
...
@@ -231,7 +230,7 @@ public class BdfReaderImplTest extends BrambleTestCase {
@Test
public
void
testReadString32
()
throws
Exception
{
String
shortest
=
Test
Utils
.
getRandomString
(
Short
.
MAX_VALUE
+
1
);
String
shortest
=
String
Utils
.
getRandomString
(
Short
.
MAX_VALUE
+
1
);
String
shortHex
=
StringUtils
.
toHexString
(
shortest
.
getBytes
(
"UTF-8"
));
// 2^15 random letters
setContents
(
"44"
+
"00008000"
+
shortHex
);
...
...
@@ -241,7 +240,7 @@ public class BdfReaderImplTest extends BrambleTestCase {
@Test
(
expected
=
FormatException
.
class
)
public
void
testReadString32ChecksMaxLength
()
throws
Exception
{
String
shortest
=
Test
Utils
.
getRandomString
(
Short
.
MAX_VALUE
+
1
);
String
shortest
=
String
Utils
.
getRandomString
(
Short
.
MAX_VALUE
+
1
);
String
shortHex
=
StringUtils
.
toHexString
(
shortest
.
getBytes
(
"UTF-8"
));
// 2^15 random letters, twice
setContents
(
"44"
+
"00008000"
+
shortHex
+
...
...
@@ -253,7 +252,7 @@ public class BdfReaderImplTest extends BrambleTestCase {
@Test
public
void
testSkipString32
()
throws
Exception
{
String
shortest
=
Test
Utils
.
getRandomString
(
Short
.
MAX_VALUE
+
1
);
String
shortest
=
String
Utils
.
getRandomString
(
Short
.
MAX_VALUE
+
1
);
String
shortHex
=
StringUtils
.
toHexString
(
shortest
.
getBytes
(
"UTF-8"
));
// 2^15 random letters, twice
setContents
(
"44"
+
"00008000"
+
shortHex
+
...
...
bramble-core/src/test/java/org/briarproject/bramble/data/BdfWriterImplTest.java
View file @
1bf0fdfa
...
...
@@ -81,7 +81,7 @@ public class BdfWriterImplTest extends BrambleTestCase {
@Test
public
void
testWriteString8
()
throws
IOException
{
String
longest
=
Test
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
);
String
longest
=
String
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
);
String
longHex
=
StringUtils
.
toHexString
(
longest
.
getBytes
(
"UTF-8"
));
w
.
writeString
(
"foo bar baz bam "
);
w
.
writeString
(
longest
);
...
...
@@ -93,9 +93,9 @@ public class BdfWriterImplTest extends BrambleTestCase {
@Test
public
void
testWriteString16
()
throws
IOException
{
String
shortest
=
Test
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
+
1
);
String
shortest
=
String
Utils
.
getRandomString
(
Byte
.
MAX_VALUE
+
1
);
String
shortHex
=
StringUtils
.
toHexString
(
shortest
.
getBytes
(
"UTF-8"
));
String
longest
=
Test
Utils
.
getRandomString
(
Short
.
MAX_VALUE
);
String
longest
=
String
Utils
.
getRandomString
(
Short
.
MAX_VALUE
);
String
longHex
=
StringUtils
.
toHexString
(
longest
.
getBytes
(
"UTF-8"
));
w
.
writeString
(
shortest
);
w
.
writeString
(
longest
);
...
...
@@ -106,7 +106,7 @@ public class BdfWriterImplTest extends BrambleTestCase {
@Test
public
void
testWriteString32
()
throws
IOException
{
String
shortest
=
Test
Utils
.
getRandomString
(
Short
.
MAX_VALUE
+
1
);
String
shortest
=
String
Utils
.
getRandomString
(
Short
.
MAX_VALUE
+
1
);
String
shortHex
=
StringUtils
.
toHexString
(
shortest
.
getBytes
(
"UTF-8"
));
w
.
writeString
(
shortest
);
// STRING_32 tag, length 2^15, UTF-8 bytes
...
...
bramble-core/src/test/java/org/briarproject/bramble/db/BasicH2Test.java
View file @
1bf0fdfa
...
...
@@ -2,6 +2,7 @@ package org.briarproject.bramble.db;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -48,8 +49,8 @@ public class BasicH2Test extends BrambleTestCase {
createTable
(
connection
);
// Generate an ID and two names
byte
[]
id
=
TestUtils
.
getRandomId
();
String
oldName
=
Test
Utils
.
getRandomString
(
50
);
String
newName
=
Test
Utils
.
getRandomString
(
50
);
String
oldName
=
String
Utils
.
getRandomString
(
50
);
String
newName
=
String
Utils
.
getRandomString
(
50
);
// Insert the ID and old name into the table
insertRow
(
id
,
oldName
);
// Check that the old name can be retrieved using the ID
...
...
@@ -78,8 +79,8 @@ public class BasicH2Test extends BrambleTestCase {
String
[]
newNames
=
new
String
[
BATCH_SIZE
];
for
(
int
i
=
0
;
i
<
BATCH_SIZE
;
i
++)
{
ids
[
i
]
=
TestUtils
.
getRandomId
();
oldNames
[
i
]
=
Test
Utils
.
getRandomString
(
50
);
newNames
[
i
]
=
Test
Utils
.
getRandomString
(
50
);
oldNames
[
i
]
=
String
Utils
.
getRandomString
(
50
);
newNames
[
i
]
=
String
Utils
.
getRandomString
(
50
);
}
// Insert the IDs and old names into the table as a batch
insertBatch
(
ids
,
oldNames
);
...
...
bramble-core/src/test/java/org/briarproject/bramble/db/DatabaseComponentImplTest.java
View file @
1bf0fdfa
...
...
@@ -49,6 +49,7 @@ import org.briarproject.bramble.api.transport.OutgoingKeys;
import
org.briarproject.bramble.api.transport.TransportKeys
;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.jmock.Expectations
;
import
org.jmock.Mockery
;
import
org.junit.Test
;
...
...
@@ -94,7 +95,7 @@ public class DatabaseComponentImplTest extends BrambleTestCase {
private
final
Contact
contact
;
public
DatabaseComponentImplTest
()
{
clientId
=
new
ClientId
(
Test
Utils
.
getRandomString
(
5
));
clientId
=
new
ClientId
(
String
Utils
.
getRandomString
(
5
));
groupId
=
new
GroupId
(
TestUtils
.
getRandomId
());
byte
[]
descriptor
=
new
byte
[
MAX_GROUP_DESCRIPTOR_LENGTH
];
group
=
new
Group
(
groupId
,
clientId
,
descriptor
);
...
...
bramble-core/src/test/java/org/briarproject/bramble/db/H2DatabaseTest.java
View file @
1bf0fdfa
...
...
@@ -24,6 +24,7 @@ import org.briarproject.bramble.system.SystemClock;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.test.TestDatabaseConfig
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -84,7 +85,7 @@ public class H2DatabaseTest extends BrambleTestCase {
public
H2DatabaseTest
()
throws
Exception
{
groupId
=
new
GroupId
(
TestUtils
.
getRandomId
());
clientId
=
new
ClientId
(
Test
Utils
.
getRandomString
(
5
));
clientId
=
new
ClientId
(
String
Utils
.
getRandomString
(
5
));
byte
[]
descriptor
=
new
byte
[
MAX_GROUP_DESCRIPTOR_LENGTH
];
group
=
new
Group
(
groupId
,
clientId
,
descriptor
);
AuthorId
authorId
=
new
AuthorId
(
TestUtils
.
getRandomId
());
...
...
bramble-core/src/test/java/org/briarproject/bramble/identity/IdentityManagerImplTest.java
View file @
1bf0fdfa
...
...
@@ -11,6 +11,7 @@ import org.briarproject.bramble.api.identity.IdentityManager;
import
org.briarproject.bramble.api.identity.LocalAuthor
;
import
org.briarproject.bramble.test.BrambleMockTestCase
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.jmock.Expectations
;
import
org.junit.Test
;
...
...
@@ -31,8 +32,9 @@ public class IdentityManagerImplTest extends BrambleMockTestCase {
private
final
Transaction
txn
=
new
Transaction
(
null
,
false
);
private
final
LocalAuthor
localAuthor
=
new
LocalAuthor
(
new
AuthorId
(
TestUtils
.
getRandomId
()),
TestUtils
.
getRandomString
(
8
),
TestUtils
.
getRandomBytes
(
42
),
TestUtils
.
getRandomBytes
(
42
),
0
);
StringUtils
.
getRandomString
(
8
),
TestUtils
.
getRandomBytes
(
42
),
TestUtils
.
getRandomBytes
(
42
),
0
);
private
final
Collection
<
LocalAuthor
>
localAuthors
=
Collections
.
singletonList
(
localAuthor
);
...
...
@@ -93,7 +95,7 @@ public class IdentityManagerImplTest extends BrambleMockTestCase {
assertEquals
(
UNKNOWN
,
identityManager
.
getAuthorStatus
(
authorId
));
// add one unverified contact
Author
author
=
new
Author
(
authorId
,
Test
Utils
.
getRandomString
(
8
),
Author
author
=
new
Author
(
authorId
,
String
Utils
.
getRandomString
(
8
),
TestUtils
.
getRandomBytes
(
42
));
Contact
contact
=
new
Contact
(
new
ContactId
(
1
),
author
,
localAuthor
.
getId
(),
...
...
bramble-core/src/test/java/org/briarproject/bramble/properties/TransportPropertyValidatorTest.java
View file @
1bf0fdfa
...
...
@@ -14,6 +14,7 @@ import org.briarproject.bramble.api.sync.MessageId;
import
org.briarproject.bramble.api.system.Clock
;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.jmock.Mockery
;
import
org.junit.Test
;
...
...
@@ -36,7 +37,7 @@ public class TransportPropertyValidatorTest extends BrambleTestCase {
bdfDictionary
=
new
BdfDictionary
();
GroupId
groupId
=
new
GroupId
(
TestUtils
.
getRandomId
());
ClientId
clientId
=
new
ClientId
(
Test
Utils
.
getRandomString
(
5
));
ClientId
clientId
=
new
ClientId
(
String
Utils
.
getRandomString
(
5
));
byte
[]
descriptor
=
TestUtils
.
getRandomBytes
(
12
);
group
=
new
Group
(
groupId
,
clientId
,
descriptor
);
...
...
@@ -85,7 +86,7 @@ public class TransportPropertyValidatorTest extends BrambleTestCase {
public
void
testValidateLongTransportId
()
throws
IOException
{
String
wrongTransportIdString
=
Test
Utils
.
getRandomString
(
MAX_TRANSPORT_ID_LENGTH
+
1
);
String
Utils
.
getRandomString
(
MAX_TRANSPORT_ID_LENGTH
+
1
);
BdfList
body
=
BdfList
.
of
(
wrongTransportIdString
,
4
,
bdfDictionary
);
tpv
.
validateMessage
(
message
,
group
,
body
);
}
...
...
bramble-core/src/test/java/org/briarproject/bramble/sync/SyncIntegrationTest.java
View file @
1bf0fdfa
...
...
@@ -22,6 +22,7 @@ import org.briarproject.bramble.api.transport.StreamReaderFactory;
import
org.briarproject.bramble.api.transport.StreamWriterFactory
;
import
org.briarproject.bramble.test.BrambleTestCase
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.junit.Test
;
import
java.io.ByteArrayInputStream
;
...
...
@@ -78,7 +79,7 @@ public class SyncIntegrationTest extends BrambleTestCase {
headerKey
=
TestUtils
.
getSecretKey
();
streamNumber
=
123
;
// Create a group
ClientId
clientId
=
new
ClientId
(
Test
Utils
.
getRandomString
(
5
));
ClientId
clientId
=
new
ClientId
(
String
Utils
.
getRandomString
(
5
));
byte
[]
descriptor
=
new
byte
[
MAX_GROUP_DESCRIPTOR_LENGTH
];
Group
group
=
groupFactory
.
createGroup
(
clientId
,
descriptor
);
// Add two messages to the group
...
...
bramble-core/src/test/java/org/briarproject/bramble/sync/ValidationManagerImplTest.java
View file @
1bf0fdfa
...
...
@@ -23,6 +23,7 @@ import org.briarproject.bramble.test.BrambleMockTestCase;
import
org.briarproject.bramble.test.ImmediateExecutor
;
import
org.briarproject.bramble.test.TestUtils
;
import
org.briarproject.bramble.util.ByteUtils
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.jmock.Expectations
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -51,7 +52,7 @@ public class ValidationManagerImplTest extends BrambleMockTestCase {
private
final
Executor
dbExecutor
=
new
ImmediateExecutor
();
private
final
Executor
validationExecutor
=
new
ImmediateExecutor
();
private
final
ClientId
clientId
=
new
ClientId
(
Test
Utils
.
getRandomString
(
5
));
new
ClientId
(
String
Utils
.
getRandomString
(
5
));
private
final
MessageId
messageId
=
new
MessageId
(
TestUtils
.
getRandomId
());
private
final
MessageId
messageId1
=
new
MessageId
(
TestUtils
.
getRandomId
());
private
final
MessageId
messageId2
=
new
MessageId
(
TestUtils
.
getRandomId
());
...
...
bramble-core/src/test/java/org/briarproject/bramble/test/ValidatorTestCase.java
View file @
1bf0fdfa
...
...
@@ -9,6 +9,7 @@ import org.briarproject.bramble.api.sync.GroupId;
import
org.briarproject.bramble.api.sync.Message
;
import
org.briarproject.bramble.api.sync.MessageId
;
import
org.briarproject.bramble.api.system.Clock
;
import
org.briarproject.bramble.util.StringUtils
;
public
abstract
class
ValidatorTestCase
extends
BrambleMockTestCase
{
...
...
@@ -28,7 +29,7 @@ public abstract class ValidatorTestCase extends BrambleMockTestCase {
protected
final
Message
message
=
new
Message
(
messageId
,
groupId
,
timestamp
,
raw
);
protected
final
ClientId
clientId
=
new
ClientId
(
Test
Utils
.
getRandomString
(
123
));
new
ClientId
(
String
Utils
.
getRandomString
(
123
));
protected
final
byte
[]
descriptor
=
TestUtils
.
getRandomBytes
(
123
);
protected
final
Group
group
=
new
Group
(
groupId
,
clientId
,
descriptor
);
...
...
briar-android/src/main/java/org/briarproject/briar/android/AndroidComponent.java
View file @
1bf0fdfa
...
...
@@ -26,7 +26,6 @@ import org.briarproject.briar.BriarCoreEagerSingletons;
import
org.briarproject.briar.BriarCoreModule
;
import
org.briarproject.briar.android.reporting.BriarReportSender
;
import
org.briarproject.briar.api.android.AndroidNotificationManager
;
import
org.briarproject.briar.api.android.ReferenceManager
;
import
org.briarproject.briar.api.android.ScreenFilterMonitor
;
import
org.briarproject.briar.api.blog.BlogManager
;
import
org.briarproject.briar.api.blog.BlogPostFactory
;
...
...
@@ -44,6 +43,7 @@ import org.briarproject.briar.api.privategroup.PrivateGroupFactory;
import
org.briarproject.briar.api.privategroup.PrivateGroupManager
;
import
org.briarproject.briar.api.privategroup.invitation.GroupInvitationFactory
;
import
org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager
;
import
org.briarproject.briar.api.test.TestDataCreator
;
import
org.thoughtcrime.securesms.components.emoji.EmojiProvider
;
import
org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel
;
...
...
@@ -73,8 +73,6 @@ public interface AndroidComponent
DatabaseConfig
databaseConfig
();
ReferenceManager
referenceMangager
();
@DatabaseExecutor
Executor
databaseExecutor
();
...
...
@@ -140,6 +138,8 @@ public interface AndroidComponent
Clock
clock
();
TestDataCreator
testDataCreator
();
@IoExecutor
Executor
ioExecutor
();
...
...
briar-android/src/main/java/org/briarproject/briar/android/activity/ActivityComponent.java
View file @
1bf0fdfa
...
...
@@ -51,6 +51,7 @@ import org.briarproject.briar.android.privategroup.reveal.GroupRevealModule;
import
org.briarproject.briar.android.privategroup.reveal.RevealContactsActivity
;
import
org.briarproject.briar.android.privategroup.reveal.RevealContactsFragment
;
import
org.briarproject.briar.android.settings.SettingsActivity
;
import
org.briarproject.briar.android.settings.SettingsFragment
;
import
org.briarproject.briar.android.sharing.BlogInvitationActivity
;
import
org.briarproject.briar.android.sharing.BlogSharingStatusActivity
;
import
org.briarproject.briar.android.sharing.ForumInvitationActivity
;
...
...
@@ -179,4 +180,6 @@ public interface ActivityComponent {
void
inject
(
IntroductionMessageFragment
fragment
);
void
inject
(
SettingsFragment
fragment
);
}
briar-android/src/main/java/org/briarproject/briar/android/settings/SettingsActivity.java
View file @
1bf0fdfa
...
...
@@ -4,24 +4,12 @@ import android.os.Bundle;
import
android.support.v7.app.ActionBar
;
import
android.view.MenuItem
;
import
org.briarproject.bramble.api.event.EventBus
;
import
org.briarproject.bramble.api.settings.SettingsManager
;
import
org.briarproject.bramble.api.system.AndroidExecutor
;
import
org.briarproject.briar.R
;
import
org.briarproject.briar.android.activity.ActivityComponent
;
import
org.briarproject.briar.android.activity.BriarActivity
;
import
javax.inject.Inject
;
public
class
SettingsActivity
extends
BriarActivity
{
@Inject
protected
AndroidExecutor
androidExecutor
;
@Inject
protected
SettingsManager
settingsManager
;
@Inject
protected
EventBus
eventBus
;
@Override
public
void
onCreate
(
Bundle
bundle
)
{
super
.
onCreate
(
bundle
);
...
...
@@ -40,18 +28,6 @@ public class SettingsActivity extends BriarActivity {
component
.
inject
(
this
);
}
public
AndroidExecutor
getAndroidExecutor
()
{
return
androidExecutor
;
}
public
SettingsManager
getSettingsManager
()
{
return
settingsManager
;
}
public
EventBus
getEventBus
()
{
return
eventBus
;
}
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
if
(
item
.
getItemId
()
==
android
.
R
.
id
.
home
)
{
...
...