Skip to content

Commit 73b9850

Browse files
authored
Enable SSL integration tests (#5430)
- Some features were missing which caused ssl tests failures. See https://github.com/realm/openssl-android/pull/2 Linking with pre-build openssl 1.0.2k-1. - Use a new Realm instead of using deleteRealm()
1 parent d3618c1 commit 73b9850

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

realm/realm-library/src/main/cpp/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ use_realm_core(${build_SYNC} "${REALM_CORE_DIST_DIR}" "${CORE_SOURCE_PATH}")
9191
set(openssl_build_TYPE "release")
9292
# FIXME Read the openssl version from core when the core/sync release has that information.
9393
set(openssl_VERSION "1.0.2k")
94-
set(openssl_FILENAME "openssl-${openssl_build_TYPE}-${openssl_VERSION}-Android-${ANDROID_ABI}")
94+
set(openssl_BUILD_NUMBER "1")
95+
set(openssl_FILENAME "openssl-${openssl_build_TYPE}-${openssl_VERSION}-${openssl_BUILD_NUMBER}-Android-${ANDROID_ABI}")
9596
set(openssl_URL "http://static.realm.io/downloads/openssl/${openssl_VERSION}/Android/${ANDROID_ABI}/${openssl_FILENAME}.tar.gz")
9697

9798
message(STATUS "Downloading OpenSSL...")

realm/realm-library/src/syncIntegrationTest/java/io/realm/SSLConfigurationTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import static org.junit.Assert.fail;
4040

4141
@RunWith(AndroidJUnit4.class)
42-
@Ignore("See https://github.com/realm/ros/issues/240")
4342
public class SSLConfigurationTests extends StandardIntegrationTest {
4443

4544
@Rule
@@ -65,12 +64,12 @@ public void trustedRootCA() throws InterruptedException {
6564
SystemClock.sleep(TimeUnit.SECONDS.toMillis(2)); // FIXME: Replace with Sync Progress Notifications once available.
6665
realm.close();
6766
user.logout();
68-
Realm.deleteRealm(configOld);
6967

7068
// 2. Local state should now be completely reset. Open the Realm again with a new configuration which should
7169
// download the uploaded changes.
7270
user = SyncUser.login(SyncCredentials.usernamePassword(username, password), Constants.AUTH_URL);
7371
SyncConfiguration config = configurationFactory.createSyncConfigurationBuilder(user, Constants.USER_REALM_SECURE)
72+
.name("useSsl")
7473
.schema(StringOnly.class)
7574
.waitForInitialRemoteData()
7675
.trustedRootCA("trusted_ca.pem")
@@ -106,12 +105,12 @@ public void withoutSSLVerification() throws InterruptedException {
106105
SystemClock.sleep(TimeUnit.SECONDS.toMillis(2)); // FIXME: Replace with Sync Progress Notifications once available.
107106
realm.close();
108107
user.logout();
109-
Realm.deleteRealm(configOld);
110108

111109
// 2. Local state should now be completely reset. Open the Realm again with a new configuration which should
112110
// download the uploaded changes.
113111
user = SyncUser.login(SyncCredentials.usernamePassword(username, password), Constants.AUTH_URL);
114112
SyncConfiguration config = configurationFactory.createSyncConfigurationBuilder(user, Constants.USER_REALM_SECURE)
113+
.name("useSsl")
115114
.schema(StringOnly.class)
116115
.waitForInitialRemoteData()
117116
.disableSSLVerification()
@@ -147,12 +146,12 @@ public void trustedRootCA_syncShouldFailWithoutTrustedCA() throws InterruptedExc
147146
SystemClock.sleep(TimeUnit.SECONDS.toMillis(2)); // FIXME: Replace with Sync Progress Notifications once available.
148147
realm.close();
149148
user.logout();
150-
Realm.deleteRealm(configOld);
151149

152150
// 2. Local state should now be completely reset. Open the Realm again with a new configuration which should
153151
// download the uploaded changes.
154152
user = SyncUser.login(SyncCredentials.usernamePassword(username, password), Constants.AUTH_URL);
155153
SyncConfiguration config = configurationFactory.createSyncConfigurationBuilder(user, Constants.USER_REALM_SECURE)
154+
.name("useSsl")
156155
.schema(StringOnly.class)
157156
.build();
158157
realm = Realm.getInstance(config);
@@ -170,6 +169,7 @@ public void combining_trustedRootCA_and_withoutSSLVerification_willThrow() {
170169
SyncUser user = SyncUser.login(SyncCredentials.usernamePassword(username, password, true), Constants.AUTH_URL);
171170

172171
TestHelper.TestLogger testLogger = new TestHelper.TestLogger();
172+
int originalLevel = RealmLog.getLevel();
173173
RealmLog.add(testLogger);
174174
RealmLog.setLevel(LogLevel.WARN);
175175

@@ -181,6 +181,8 @@ public void combining_trustedRootCA_and_withoutSSLVerification_willThrow() {
181181

182182
assertEquals("SSL Verification is disabled, the provided server certificate will not be used.",
183183
testLogger.message);
184+
RealmLog.remove(testLogger);
185+
RealmLog.setLevel(originalLevel);
184186
}
185187

186188
@Test

tools/sync_test_server/ros-testing-server.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ function startRealmObjectServer(onSuccess, onError) {
9090
['start',
9191
'--data', path,
9292
'--loglevel', 'detail',
93+
'--https',
94+
'--https-key', '/127_0_0_1-server.key.pem',
95+
'--https-cert', '/127_0_0_1-chain.crt.pem',
96+
'--https-port', '9443',
9397
'--access-token-ttl', '20' //WARNING : Changing this value may impact the timeout of the refresh token test (AuthTests#preemptiveTokenRefresh)
9498
],
9599
{ env: env, cwd: path});

0 commit comments

Comments
 (0)