Skip to content

Commit

Permalink
Merge pull request #5953 from vector-im/task/eric/reformat-project
Browse files Browse the repository at this point in the history
Reformats project based on editorconfig
  • Loading branch information
ericdecanini authored May 6, 2022
2 parents 17c6f7c + be0be69 commit 9f9c6fb
Show file tree
Hide file tree
Showing 275 changed files with 2,717 additions and 1,634 deletions.
1 change: 1 addition & 0 deletions changelog.d/5953.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reformatted project code
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,19 @@ class PermalinkParserTest {
Assert.assertTrue("Should be parsed as email invite but was ${parsedLink::class.java}", parsedLink is PermalinkData.RoomEmailInviteLink)
parsedLink as PermalinkData.RoomEmailInviteLink
Assert.assertEquals("!MRBNLPtFnMAazZVPMO:matrix.org", parsedLink.roomId)
Assert.assertEquals("XmOwRZnSFabCRhTywFbJWKXWVNPysOpXIbroMGaUymqkJSvHeVKRsjHajwjCYdBsvGSvHauxbKfJmOxtXldtyLnyBMLKpBQCMzyYggrdapbVIceWZBtmslOQrXLABRoe", parsedLink.token)
Assert.assertEquals(
"XmOwRZnSFabCRhTywFbJWKXWVNPysOpXIbroMGaUymqkJSvHeVKRsjHajwjCYdBsvGSvHauxbKfJmOxtXldtyLnyBMLKpBQCMzyYggrdapbVIceWZBtmslOQrXLABRoe",
parsedLink.token
)
Assert.assertEquals("vector.im", parsedLink.identityServer)
Assert.assertEquals("Team2", parsedLink.roomName)
Assert.assertEquals("hiphop5", parsedLink.inviterName)
}

@Test
fun testParseLinkWIthEvent() {
val rawInvite = "https://matrix.to/#/!OGEhHVWSdvArJzumhm:matrix.org/\$xuvJUVDJnwEeVjPx029rAOZ50difpmU_5gZk_T0jGfc?via=matrix.org&via=libera.chat&via=matrix.example.io"
val rawInvite =
"https://matrix.to/#/!OGEhHVWSdvArJzumhm:matrix.org/\$xuvJUVDJnwEeVjPx029rAOZ50difpmU_5gZk_T0jGfc?via=matrix.org&via=libera.chat&via=matrix.example.io"

val parsedLink = PermalinkParser.parse(rawInvite)
Assert.assertTrue("Should be parsed as room link", parsedLink is PermalinkData.RoomLink)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ import kotlinx.coroutines.asCoroutineDispatcher
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import java.util.concurrent.Executors

internal val testCoroutineDispatchers = MatrixCoroutineDispatchers(Main, Main, Main, Main,
Executors.newSingleThreadExecutor().asCoroutineDispatcher())
internal val testCoroutineDispatchers = MatrixCoroutineDispatchers(
Main, Main, Main, Main,
Executors.newSingleThreadExecutor().asCoroutineDispatcher()
)
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ class DeactivateAccountTest : InstrumentedTest {
val throwable = commonTestHelper.logAccountWithError(session.myUserId, TestConstants.PASSWORD)

// Test the error
assertTrue(throwable is Failure.ServerError &&
throwable.error.code == MatrixError.M_USER_DEACTIVATED &&
throwable.error.message == "This account has been deactivated")
assertTrue(
throwable is Failure.ServerError &&
throwable.error.code == MatrixError.M_USER_DEACTIVATED &&
throwable.error.message == "This account has been deactivated"
)

// Try to create an account with the deactivate account user id, it will fail (M_USER_IN_USE)
val hs = commonTestHelper.createHomeServerConfig()
Expand All @@ -95,8 +97,10 @@ class DeactivateAccountTest : InstrumentedTest {

// Test the error
accountCreationError.let {
assertTrue(it is Failure.ServerError &&
it.error.code == MatrixError.M_USER_IN_USE)
assertTrue(
it is Failure.ServerError &&
it.error.code == MatrixError.M_USER_IN_USE
)
}

// No need to close the session, it has been deactivated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
)
)
}
}, it)
}, it
)
}
}

Expand All @@ -308,7 +309,8 @@ class CryptoTestHelper(private val testHelper: CommonTestHelper) {
requestID,
roomId,
bob.myUserId,
bob.sessionParams.credentials.deviceId!!)
bob.sessionParams.credentials.deviceId!!
)

// we should reach SHOW SAS on both
var alicePovTx: OutgoingSasVerificationTransaction? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ import org.matrix.android.sdk.internal.raw.RawModule
import org.matrix.android.sdk.internal.settings.SettingsModule
import org.matrix.android.sdk.internal.util.system.SystemModule

@Component(modules = [
TestModule::class,
MatrixModule::class,
NetworkModule::class,
AuthModule::class,
RawModule::class,
SettingsModule::class,
SystemModule::class
])
@Component(
modules = [
TestModule::class,
MatrixModule::class,
NetworkModule::class,
AuthModule::class,
RawModule::class,
SettingsModule::class,
SystemModule::class
]
)
@MatrixScope
internal interface TestMatrixComponent : MatrixComponent {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ class CryptoStoreTest : InstrumentedTest {
}

val olmSession1 = OlmSession().apply {
initOutboundSession(olmAccount1,
initOutboundSession(
olmAccount1,
olmAccount1.identityKeys()[OlmAccount.JSON_KEY_IDENTITY_KEY],
olmAccount1.oneTimeKeys()[OlmAccount.JSON_KEY_ONE_TIME_KEY]?.values?.first())
olmAccount1.oneTimeKeys()[OlmAccount.JSON_KEY_ONE_TIME_KEY]?.values?.first()
)
}

val sessionId1 = olmSession1.sessionIdentifier()
Expand All @@ -93,9 +95,11 @@ class CryptoStoreTest : InstrumentedTest {
}

val olmSession2 = OlmSession().apply {
initOutboundSession(olmAccount2,
initOutboundSession(
olmAccount2,
olmAccount2.identityKeys()[OlmAccount.JSON_KEY_IDENTITY_KEY],
olmAccount2.oneTimeKeys()[OlmAccount.JSON_KEY_ONE_TIME_KEY]?.values?.first())
olmAccount2.oneTimeKeys()[OlmAccount.JSON_KEY_ONE_TIME_KEY]?.values?.first()
)
}

val sessionId2 = olmSession2.sessionIdentifier()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,13 @@ class E2eeSanityTests : InstrumentedTest {
}

val importedResult = testHelper.doSync<ImportRoomKeysResult> {
keysBackupService.restoreKeyBackupWithPassword(keyVersionResult!!,
keysBackupService.restoreKeyBackupWithPassword(
keyVersionResult!!,
keyBackupPassword,
null,
null,
null, it)
null, it
)
}

assertEquals(3, importedResult.totalNumberOfKeys)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ class ExportEncryptionTest {
fail("## checkExportDecrypt1() failed : " + e.message)
}

assertEquals("## checkExportDecrypt1() : expectedString $expectedString -- decodedString $decodedString",
assertEquals(
"## checkExportDecrypt1() : expectedString $expectedString -- decodedString $decodedString",
expectedString,
decodedString)
decodedString
)
}

@Test
Expand All @@ -111,9 +113,11 @@ class ExportEncryptionTest {
fail("## checkExportDecrypt2() failed : " + e.message)
}

assertEquals("## checkExportDecrypt2() : expectedString $expectedString -- decodedString $decodedString",
assertEquals(
"## checkExportDecrypt2() : expectedString $expectedString -- decodedString $decodedString",
expectedString,
decodedString)
decodedString
)
}

@Test
Expand All @@ -129,9 +133,11 @@ class ExportEncryptionTest {
fail("## checkExportDecrypt3() failed : " + e.message)
}

assertEquals("## checkExportDecrypt3() : expectedString $expectedString -- decodedString $decodedString",
assertEquals(
"## checkExportDecrypt3() : expectedString $expectedString -- decodedString $decodedString",
expectedString,
decodedString)
decodedString
)
}

@Test
Expand All @@ -147,9 +153,11 @@ class ExportEncryptionTest {
fail("## checkExportEncrypt1() failed : " + e.message)
}

assertEquals("## checkExportEncrypt1() : expectedString $expectedString -- decodedString $decodedString",
assertEquals(
"## checkExportEncrypt1() : expectedString $expectedString -- decodedString $decodedString",
expectedString,
decodedString)
decodedString
)
}

@Test
Expand All @@ -165,9 +173,11 @@ class ExportEncryptionTest {
fail("## checkExportEncrypt2() failed : " + e.message)
}

assertEquals("## checkExportEncrypt2() : expectedString $expectedString -- decodedString $decodedString",
assertEquals(
"## checkExportEncrypt2() : expectedString $expectedString -- decodedString $decodedString",
expectedString,
decodedString)
decodedString
)
}

@Test
Expand All @@ -183,9 +193,11 @@ class ExportEncryptionTest {
fail("## checkExportEncrypt3() failed : " + e.message)
}

assertEquals("## checkExportEncrypt3() : expectedString $expectedString -- decodedString $decodedString",
assertEquals(
"## checkExportEncrypt3() : expectedString $expectedString -- decodedString $decodedString",
expectedString,
decodedString)
decodedString
)
}

@Test
Expand All @@ -201,8 +213,10 @@ class ExportEncryptionTest {
fail("## checkExportEncrypt4() failed : " + e.message)
}

assertEquals("## checkExportEncrypt4() : expectedString $expectedString -- decodedString $decodedString",
assertEquals(
"## checkExportEncrypt4() : expectedString $expectedString -- decodedString $decodedString",
expectedString,
decodedString)
decodedString
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ class UnwedgingTest : InstrumentedTest {
// Let us wedge the session now. Set crypto state like after the first message
Timber.i("## CRYPTO | testUnwedging: wedge the session now. Set crypto state like after the first message")

aliceCryptoStore.storeSession(OlmSessionWrapper(deserializeFromRealm<OlmSession>(oldSession)!!), bobSession.cryptoService().getMyDevice().identityKey()!!)
aliceCryptoStore.storeSession(
OlmSessionWrapper(deserializeFromRealm<OlmSession>(oldSession)!!),
bobSession.cryptoService().getMyDevice().identityKey()!!
)
olmDevice.clearOlmSessionCache()
Thread.sleep(6_000)

Expand Down Expand Up @@ -218,7 +221,8 @@ class UnwedgingTest : InstrumentedTest {
)
)
}
}, it)
}, it
)
}

// Wait until we received back the key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,16 @@ class XSigningTest : InstrumentedTest {
assertNull("Alice should not see bob User key", bobKeysFromAlicePOV.userKey())
assertNotNull("Alice can see bob SelfSigned key", bobKeysFromAlicePOV.selfSigningKey())

assertEquals("Bob keys from alice pov should match", bobKeysFromAlicePOV.masterKey()?.unpaddedBase64PublicKey, bobSession.cryptoService().crossSigningService().getMyCrossSigningKeys()?.masterKey()?.unpaddedBase64PublicKey)
assertEquals("Bob keys from alice pov should match", bobKeysFromAlicePOV.selfSigningKey()?.unpaddedBase64PublicKey, bobSession.cryptoService().crossSigningService().getMyCrossSigningKeys()?.selfSigningKey()?.unpaddedBase64PublicKey)
assertEquals(
"Bob keys from alice pov should match",
bobKeysFromAlicePOV.masterKey()?.unpaddedBase64PublicKey,
bobSession.cryptoService().crossSigningService().getMyCrossSigningKeys()?.masterKey()?.unpaddedBase64PublicKey
)
assertEquals(
"Bob keys from alice pov should match",
bobKeysFromAlicePOV.selfSigningKey()?.unpaddedBase64PublicKey,
bobSession.cryptoService().crossSigningService().getMyCrossSigningKeys()?.selfSigningKey()?.unpaddedBase64PublicKey
)

assertFalse("Bob keys from alice pov should not be trusted", bobKeysFromAlicePOV.isTrusted())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,10 @@ class KeyShareTests : InstrumentedTest {
Log.v("TEST", "Incoming request Session 1 (looking for $outGoingRequestId)")
Log.v("TEST", "=========================")
it.forEach { keyRequest ->
Log.v("TEST", "[ts${keyRequest.localCreationTimestamp}] requestId ${keyRequest.requestId}, for sessionId ${keyRequest.requestBody?.sessionId} is ${keyRequest.state}")
Log.v(
"TEST",
"[ts${keyRequest.localCreationTimestamp}] requestId ${keyRequest.requestId}, for sessionId ${keyRequest.requestBody?.sessionId} is ${keyRequest.state}"
)
}
Log.v("TEST", "=========================")
}
Expand All @@ -164,8 +167,10 @@ class KeyShareTests : InstrumentedTest {
}

// Mark the device as trusted
aliceSession.cryptoService().setDeviceVerification(DeviceTrustLevel(crossSigningVerified = false, locallyVerified = true), aliceSession.myUserId,
aliceSession2.sessionParams.deviceId ?: "")
aliceSession.cryptoService().setDeviceVerification(
DeviceTrustLevel(crossSigningVerified = false, locallyVerified = true), aliceSession.myUserId,
aliceSession2.sessionParams.deviceId ?: ""
)

// Re request
aliceSession2.cryptoService().reRequestRoomKeyForEvent(receivedEvent.root)
Expand Down Expand Up @@ -223,7 +228,8 @@ class KeyShareTests : InstrumentedTest {
)
)
}
}, it)
}, it
)
}

// Also bootstrap keybackup on first session
Expand Down Expand Up @@ -282,8 +288,10 @@ class KeyShareTests : InstrumentedTest {
})

val txId = "m.testVerif12"
aliceVerificationService2.beginKeyVerification(VerificationMethod.SAS, aliceSession1.myUserId, aliceSession1.sessionParams.deviceId
?: "", txId)
aliceVerificationService2.beginKeyVerification(
VerificationMethod.SAS, aliceSession1.myUserId, aliceSession1.sessionParams.deviceId
?: "", txId
)

commonTestHelper.waitWithLatch { latch ->
commonTestHelper.retryPeriodicallyWithLatch(latch) {
Expand Down Expand Up @@ -337,7 +345,8 @@ class KeyShareTests : InstrumentedTest {
)
)
}
}, it)
}, it
)
}

// Create an encrypted room and send a couple of messages
Expand Down Expand Up @@ -371,7 +380,8 @@ class KeyShareTests : InstrumentedTest {
)
)
}
}, it)
}, it
)
}

// Let alice invite bob
Expand Down
Loading

0 comments on commit 9f9c6fb

Please sign in to comment.