Fix ktlint issues
This commit is contained in:
parent
ed773dbb96
commit
35f011ba37
|
@ -50,7 +50,6 @@ class CommonTestHelper(context: Context) {
|
|||
matrix = Matrix.getInstance(context)
|
||||
}
|
||||
|
||||
|
||||
fun createAccount(userNamePrefix: String, testParams: SessionTestParams): Session {
|
||||
return createAccount(userNamePrefix, TestConstants.PASSWORD, testParams)
|
||||
}
|
||||
|
@ -74,7 +73,7 @@ class CommonTestHelper(context: Context) {
|
|||
* @param session the session to sync
|
||||
*/
|
||||
fun syncSession(session: Session) {
|
||||
//val lock = CountDownLatch(1)
|
||||
// val lock = CountDownLatch(1)
|
||||
|
||||
// val observer = androidx.lifecycle.Observer<SyncState> { syncState ->
|
||||
// if (syncState is SyncState.Idle) {
|
||||
|
@ -89,8 +88,8 @@ class CommonTestHelper(context: Context) {
|
|||
|
||||
session.open()
|
||||
session.startSync(true)
|
||||
//await(lock)
|
||||
//session.syncState().removeObserver(observer)
|
||||
// await(lock)
|
||||
// session.syncState().removeObserver(observer)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,7 +128,6 @@ class CommonTestHelper(context: Context) {
|
|||
return sentEvents
|
||||
}
|
||||
|
||||
|
||||
// PRIVATE METHODS *****************************************************************************
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package im.vector.matrix.android.common
|
||||
|
||||
import android.os.SystemClock
|
||||
import android.text.TextUtils
|
||||
import im.vector.matrix.android.api.session.Session
|
||||
import im.vector.matrix.android.api.session.events.model.Event
|
||||
import im.vector.matrix.android.api.session.events.model.EventType
|
||||
|
|
|
@ -41,7 +41,6 @@ class MockOkHttpInterceptor : Interceptor {
|
|||
|
||||
private var rules: ArrayList<Rule> = ArrayList()
|
||||
|
||||
|
||||
fun addRule(rule: Rule) {
|
||||
rules.add(rule)
|
||||
}
|
||||
|
@ -60,7 +59,6 @@ class MockOkHttpInterceptor : Interceptor {
|
|||
return chain.proceed(originalRequest)
|
||||
}
|
||||
|
||||
|
||||
abstract class Rule(val match: String) {
|
||||
abstract fun process(originalRequest: Request): Response?
|
||||
}
|
||||
|
@ -81,6 +79,5 @@ class MockOkHttpInterceptor : Interceptor {
|
|||
.code(code)
|
||||
.build()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package im.vector.matrix.android.internal.crypto
|
||||
|
||||
|
||||
import android.os.MemoryFile
|
||||
import android.util.Base64
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
|
|
@ -150,7 +150,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
var megolmBackupCreationInfo: MegolmBackupCreationInfo? = null
|
||||
val latch = CountDownLatch(1)
|
||||
keysBackup.prepareKeysBackupVersion(null, null, object : MatrixCallback<MegolmBackupCreationInfo> {
|
||||
|
||||
override fun onSuccess(data: MegolmBackupCreationInfo) {
|
||||
megolmBackupCreationInfo = data
|
||||
|
||||
|
@ -210,7 +209,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
|
||||
mTestHelper.await(latch)
|
||||
|
||||
|
||||
val nbOfKeys = cryptoTestData.firstSession.inboundGroupSessionsCount(false)
|
||||
val backedUpKeys = cryptoTestData.firstSession.inboundGroupSessionsCount(true)
|
||||
|
||||
|
@ -230,7 +228,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
cryptoTestData.close()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check that backupAllGroupSessions() returns valid data
|
||||
*/
|
||||
|
@ -258,7 +255,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
assertEquals(nbOfKeys, total)
|
||||
lastBackedUpKeysProgress = progress
|
||||
}
|
||||
|
||||
}, TestMatrixCallback(latch))
|
||||
|
||||
mTestHelper.await(latch)
|
||||
|
@ -400,7 +396,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
testData.cryptoTestData.close()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* - Do an e2e backup to the homeserver with a recovery key
|
||||
* - And log Alice on a new device
|
||||
|
@ -1081,7 +1076,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
keysBackup.backupAllGroupSessions(object : ProgressListener {
|
||||
override fun onProgress(progress: Int, total: Int) {
|
||||
}
|
||||
|
||||
}, TestMatrixCallback(latch2, false))
|
||||
mTestHelper.await(latch2)
|
||||
|
||||
|
@ -1121,7 +1115,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
val latch = CountDownLatch(1)
|
||||
keysBackup.backupAllGroupSessions(object : ProgressListener {
|
||||
override fun onProgress(progress: Int, total: Int) {
|
||||
|
||||
}
|
||||
}, TestMatrixCallback(latch))
|
||||
mTestHelper.await(latch)
|
||||
|
@ -1153,7 +1146,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
keysBackup2.backupAllGroupSessions(object : ProgressListener {
|
||||
override fun onProgress(progress: Int, total: Int) {
|
||||
}
|
||||
|
||||
}, object : TestMatrixCallback<Unit>(latch2, false) {
|
||||
override fun onSuccess(data: Unit) {
|
||||
isSuccessful = true
|
||||
|
@ -1274,7 +1266,6 @@ class KeysBackupTest : InstrumentedTest {
|
|||
var megolmBackupCreationInfo: MegolmBackupCreationInfo? = null
|
||||
val latch = CountDownLatch(1)
|
||||
keysBackup.prepareKeysBackupVersion(password, null, object : MatrixCallback<MegolmBackupCreationInfo> {
|
||||
|
||||
override fun onSuccess(data: MegolmBackupCreationInfo) {
|
||||
megolmBackupCreationInfo = data
|
||||
|
||||
|
|
|
@ -88,13 +88,12 @@ class SASTest : InstrumentedTest {
|
|||
assertEquals("Alice state should be started", SasVerificationTxState.Started, aliceSasTx!!.state)
|
||||
assertEquals("Bob state should be started by alice", SasVerificationTxState.OnStarted, bobSasTx!!.state)
|
||||
|
||||
//Let's cancel from alice side
|
||||
// Let's cancel from alice side
|
||||
val cancelLatch = CountDownLatch(1)
|
||||
|
||||
val bobListener2 = object : SasVerificationService.SasVerificationListener {
|
||||
override fun transactionCreated(tx: SasVerificationTransaction) {}
|
||||
|
||||
|
||||
override fun transactionUpdated(tx: SasVerificationTransaction) {
|
||||
if (tx.transactionId == txID) {
|
||||
if ((tx as SASVerificationTransaction).state === SasVerificationTxState.OnCancelled) {
|
||||
|
@ -135,7 +134,7 @@ class SASTest : InstrumentedTest {
|
|||
val protocols = listOf("meh_dont_know")
|
||||
val tid = "00000000"
|
||||
|
||||
//Bob should receive a cancel
|
||||
// Bob should receive a cancel
|
||||
var canceledToDeviceEvent: Event? = null
|
||||
val cancelLatch = CountDownLatch(1)
|
||||
// TODO bobSession!!.dataHandler.addListener(object : MXEventListener() {
|
||||
|
@ -166,7 +165,6 @@ class SASTest : InstrumentedTest {
|
|||
}
|
||||
aliceSession.getSasVerificationService().addListener(aliceListener)
|
||||
|
||||
|
||||
fakeBobStart(bobSession, aliceUserID, aliceDevice, tid, protocols = protocols)
|
||||
|
||||
mTestHelper.await(cancelLatch)
|
||||
|
@ -175,7 +173,6 @@ class SASTest : InstrumentedTest {
|
|||
assertEquals("Request should be cancelled with m.unknown_method", CancelCode.UnknownMethod.value, cancelReq.code)
|
||||
|
||||
cryptoTestData.close()
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -187,7 +184,7 @@ class SASTest : InstrumentedTest {
|
|||
val mac = listOf("shaBit")
|
||||
val tid = "00000000"
|
||||
|
||||
//Bob should receive a cancel
|
||||
// Bob should receive a cancel
|
||||
var canceledToDeviceEvent: Event? = null
|
||||
val cancelLatch = CountDownLatch(1)
|
||||
// TODO bobSession!!.dataHandler.addListener(object : MXEventListener() {
|
||||
|
@ -213,7 +210,6 @@ class SASTest : InstrumentedTest {
|
|||
assertEquals("Request should be cancelled with m.unknown_method", CancelCode.UnknownMethod.value, cancelReq.code)
|
||||
|
||||
cryptoTestData.close()
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -222,11 +218,10 @@ class SASTest : InstrumentedTest {
|
|||
|
||||
val bobSession = cryptoTestData.secondSession!!
|
||||
|
||||
|
||||
val codes = listOf("bin", "foo", "bar")
|
||||
val tid = "00000000"
|
||||
|
||||
//Bob should receive a cancel
|
||||
// Bob should receive a cancel
|
||||
var canceledToDeviceEvent: Event? = null
|
||||
val cancelLatch = CountDownLatch(1)
|
||||
// TODO bobSession!!.dataHandler.addListener(object : MXEventListener() {
|
||||
|
@ -252,7 +247,6 @@ class SASTest : InstrumentedTest {
|
|||
assertEquals("Request should be cancelled with m.unknown_method", CancelCode.UnknownMethod.value, cancelReq.code)
|
||||
|
||||
cryptoTestData.close()
|
||||
|
||||
}
|
||||
|
||||
private fun fakeBobStart(bobSession: Session,
|
||||
|
@ -284,8 +278,7 @@ class SASTest : InstrumentedTest {
|
|||
// TODO )
|
||||
}
|
||||
|
||||
|
||||
//any two devices may only have at most one key verification in flight at a time.
|
||||
// any two devices may only have at most one key verification in flight at a time.
|
||||
// If a device has two verifications in progress with the same device, then it should cancel both verifications.
|
||||
@Test
|
||||
fun test_aliceStartTwoRequests() {
|
||||
|
@ -294,7 +287,6 @@ class SASTest : InstrumentedTest {
|
|||
val aliceSession = cryptoTestData.firstSession
|
||||
val bobSession = cryptoTestData.secondSession
|
||||
|
||||
|
||||
val aliceSasMgr = aliceSession.getSasVerificationService()
|
||||
|
||||
val aliceCreatedLatch = CountDownLatch(2)
|
||||
|
@ -343,7 +335,6 @@ class SASTest : InstrumentedTest {
|
|||
var accepted: KeyVerificationAccept? = null
|
||||
var startReq: KeyVerificationStart? = null
|
||||
|
||||
|
||||
val aliceAcceptedLatch = CountDownLatch(1)
|
||||
val aliceListener = object : SasVerificationService.SasVerificationListener {
|
||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||
|
@ -375,7 +366,6 @@ class SASTest : InstrumentedTest {
|
|||
}
|
||||
bobSasMgr.addListener(bobListener)
|
||||
|
||||
|
||||
val bobUserId = bobSession.myUserId
|
||||
val bobDeviceId = bobSession.getMyDevice().deviceId
|
||||
aliceSasMgr.beginKeyVerificationSAS(bobUserId, bobDeviceId)
|
||||
|
@ -383,7 +373,7 @@ class SASTest : InstrumentedTest {
|
|||
|
||||
assertTrue("Should have receive a commitment", accepted!!.commitment?.trim()?.isEmpty() == false)
|
||||
|
||||
//check that agreement is valid
|
||||
// check that agreement is valid
|
||||
assertTrue("Agreed Protocol should be Valid", accepted!!.isValid())
|
||||
assertTrue("Agreed Protocol should be known by alice", startReq!!.keyAgreementProtocols!!.contains(accepted!!.keyAgreementProtocol))
|
||||
assertTrue("Hash should be known by alice", startReq!!.hashes!!.contains(accepted!!.hash))
|
||||
|
@ -406,7 +396,6 @@ class SASTest : InstrumentedTest {
|
|||
val aliceSasMgr = aliceSession.getSasVerificationService()
|
||||
val bobSasMgr = bobSession!!.getSasVerificationService()
|
||||
|
||||
|
||||
val aliceSASLatch = CountDownLatch(1)
|
||||
val aliceListener = object : SasVerificationService.SasVerificationListener {
|
||||
override fun transactionCreated(tx: SasVerificationTransaction) {}
|
||||
|
@ -446,7 +435,6 @@ class SASTest : InstrumentedTest {
|
|||
}
|
||||
bobSasMgr.addListener(bobListener)
|
||||
|
||||
|
||||
val bobUserId = bobSession.myUserId
|
||||
val bobDeviceId = bobSession.getMyDevice().deviceId
|
||||
val verificationSAS = aliceSasMgr.beginKeyVerificationSAS(bobUserId, bobDeviceId)
|
||||
|
@ -462,7 +450,6 @@ class SASTest : InstrumentedTest {
|
|||
cryptoTestData.close()
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun test_happyPath() {
|
||||
val cryptoTestData = mCryptoTestHelper.doE2ETestWithAliceAndBobInARoom()
|
||||
|
@ -473,7 +460,6 @@ class SASTest : InstrumentedTest {
|
|||
val aliceSasMgr = aliceSession.getSasVerificationService()
|
||||
val bobSasMgr = bobSession!!.getSasVerificationService()
|
||||
|
||||
|
||||
val aliceSASLatch = CountDownLatch(1)
|
||||
val aliceListener = object : SasVerificationService.SasVerificationListener {
|
||||
override fun transactionCreated(tx: SasVerificationTransaction) {}
|
||||
|
@ -519,18 +505,17 @@ class SASTest : InstrumentedTest {
|
|||
}
|
||||
bobSasMgr.addListener(bobListener)
|
||||
|
||||
|
||||
val bobUserId = bobSession.myUserId
|
||||
val bobDeviceId = bobSession.getMyDevice().deviceId
|
||||
aliceSasMgr.beginKeyVerificationSAS(bobUserId, bobDeviceId)
|
||||
mTestHelper.await(aliceSASLatch)
|
||||
mTestHelper.await(bobSASLatch)
|
||||
|
||||
//Assert that devices are verified
|
||||
// Assert that devices are verified
|
||||
val bobDeviceInfoFromAlicePOV: MXDeviceInfo? = aliceSession.getDeviceInfo(bobUserId, bobDeviceId)
|
||||
val aliceDeviceInfoFromBobPOV: MXDeviceInfo? = bobSession.getDeviceInfo(aliceSession.myUserId, aliceSession.getMyDevice().deviceId)
|
||||
|
||||
//latch wait a bit again
|
||||
// latch wait a bit again
|
||||
Thread.sleep(1000)
|
||||
|
||||
assertTrue("alice device should be verified from bob point of view", aliceDeviceInfoFromBobPOV!!.isVerified)
|
||||
|
|
|
@ -1364,7 +1364,6 @@ internal class KeysBackup @Inject constructor(
|
|||
.executeBy(taskExecutor)
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
// Maximum delay in ms in {@link maybeBackupKeys}
|
||||
private const val KEY_BACKUP_WAITING_TIME_TO_SEND_KEY_BACKUP_MILLIS = 10_000L
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package im.vector.matrix.android.internal.crypto.keysbackup.util
|
||||
|
||||
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.FixMethodOrder
|
||||
|
@ -35,7 +34,7 @@ class Base58Test {
|
|||
@Test
|
||||
fun decode() {
|
||||
// Example comes from https://github.com/keis/base58
|
||||
assertArrayEquals("hello world".toByteArray(), base58decode("StV1DL6CwTryKyV"));
|
||||
assertArrayEquals("hello world".toByteArray(), base58decode("StV1DL6CwTryKyV"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue