Skip to content

Commit c1f53e6

Browse files
committed
EndToEndRandomIT: create keys before all tests
Fixes inconsistencies due to keys created at wrong time Co-authored-by: Tobias Kaminsky <tobias@kaminsky.me> Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
1 parent bcfa832 commit c1f53e6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/src/androidTest/java/com/nextcloud/client/EndToEndRandomIT.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import org.junit.BeforeClass;
5454
import org.junit.Rule;
5555
import org.junit.Test;
56+
import org.junit.runner.RunWith;
5657

5758
import java.io.File;
5859
import java.io.IOException;
@@ -61,13 +62,16 @@
6162
import java.util.List;
6263
import java.util.Random;
6364

65+
import androidx.test.ext.junit.runners.AndroidJUnit4;
66+
6467
import static com.owncloud.android.lib.resources.status.OwnCloudVersion.nextcloud_19;
6568
import static junit.framework.TestCase.assertEquals;
6669
import static junit.framework.TestCase.assertFalse;
6770
import static junit.framework.TestCase.assertNotNull;
6871
import static junit.framework.TestCase.assertTrue;
6972
import static org.junit.Assume.assumeTrue;
7073

74+
@RunWith(AndroidJUnit4.class)
7175
public class EndToEndRandomIT extends AbstractOnServerIT {
7276
public enum Action {
7377
CREATE_FOLDER,
@@ -88,8 +92,9 @@ public enum Action {
8892
public RetryTestRule retryTestRule = new RetryTestRule();
8993

9094
@BeforeClass
91-
public static void initClass() {
95+
public static void initClass() throws Exception {
9296
arbitraryDataProvider = new ArbitraryDataProvider(targetContext.getContentResolver());
97+
createKeys();
9398
}
9499

95100
@Before
@@ -511,7 +516,6 @@ public void reInit() throws Exception {
511516
encFolder.setEncrypted(true);
512517
getStorageManager().saveFolder(encFolder, new ArrayList<>(), new ArrayList<>());
513518

514-
createKeys();
515519

516520
// delete keys
517521
arbitraryDataProvider.deleteKeyForAccount(account.name, EncryptionUtils.PRIVATE_KEY);
@@ -553,7 +557,7 @@ private void useExistingKeys() throws Exception {
553557
/*
554558
TODO do not c&p code
555559
*/
556-
private void createKeys() throws Exception {
560+
private static void createKeys() throws Exception {
557561
String publicKey;
558562

559563
// Create public/private key pair
@@ -594,7 +598,7 @@ private void createKeys() throws Exception {
594598
}
595599
}
596600

597-
private String generateMnemonicString() {
601+
private static String generateMnemonicString() {
598602
return "1 2 3 4 5 6";
599603
}
600604

0 commit comments

Comments
 (0)