Fixes formatting errors in ExportEncryptionTest and VectorBaseActivity

This commit is contained in:
ericdecanini 2022-05-06 10:10:25 +02:00
parent 4266c330de
commit be0be699e4
2 changed files with 11 additions and 15 deletions

View File

@ -83,8 +83,7 @@ class ExportEncryptionTest {
@Test @Test
fun checkExportDecrypt1() { fun checkExportDecrypt1() {
val password = "password" val password = "password"
val input = val input = "-----BEGIN MEGOLM SESSION DATA-----\nAXNhbHRzYWx0c2FsdHNhbHSIiIiIiIiIiIiIiIiIiIiIAAAACmIRUW2OjZ3L2l6j9h0lHlV3M2dx\n" + "cissyYBxjsfsAndErh065A8=\n-----END MEGOLM SESSION DATA-----"
"-----BEGIN MEGOLM SESSION DATA-----\nAXNhbHRzYWx0c2FsdHNhbHSIiIiIiIiIiIiIiIiIiIiIAAAACmIRUW2OjZ3L2l6j9h0lHlV3M2dx\n" + "cissyYBxjsfsAndErh065A8=\n-----END MEGOLM SESSION DATA-----"
val expectedString = "plain" val expectedString = "plain"
var decodedString: String? = null var decodedString: String? = null
@ -104,8 +103,7 @@ class ExportEncryptionTest {
@Test @Test
fun checkExportDecrypt2() { fun checkExportDecrypt2() {
val password = "betterpassword" val password = "betterpassword"
val input = val input = "-----BEGIN MEGOLM SESSION DATA-----\nAW1vcmVzYWx0bW9yZXNhbHT//////////wAAAAAAAAAAAAAD6KyBpe1Niv5M5NPm4ZATsJo5nghk\n" + "KYu63a0YQ5DRhUWEKk7CcMkrKnAUiZny\n-----END MEGOLM SESSION DATA-----"
"-----BEGIN MEGOLM SESSION DATA-----\nAW1vcmVzYWx0bW9yZXNhbHT//////////wAAAAAAAAAAAAAD6KyBpe1Niv5M5NPm4ZATsJo5nghk\n" + "KYu63a0YQ5DRhUWEKk7CcMkrKnAUiZny\n-----END MEGOLM SESSION DATA-----"
val expectedString = "Hello, World" val expectedString = "Hello, World"
var decodedString: String? = null var decodedString: String? = null
@ -125,8 +123,7 @@ class ExportEncryptionTest {
@Test @Test
fun checkExportDecrypt3() { fun checkExportDecrypt3() {
val password = "SWORDFISH" val password = "SWORDFISH"
val input = val input = "-----BEGIN MEGOLM SESSION DATA-----\nAXllc3NhbHR5Z29vZG5lc3P//////////wAAAAAAAAAAAAAD6OIW+Je7gwvjd4kYrb+49gKCfExw\n" + "MgJBMD4mrhLkmgAngwR1pHjbWXaoGybtiAYr0moQ93GrBQsCzPbvl82rZhaXO3iH5uHo/RCEpOqp\nPgg29363BGR+/Ripq/VCLKGNbw==\n-----END MEGOLM SESSION DATA-----"
"-----BEGIN MEGOLM SESSION DATA-----\nAXllc3NhbHR5Z29vZG5lc3P//////////wAAAAAAAAAAAAAD6OIW+Je7gwvjd4kYrb+49gKCfExw\n" + "MgJBMD4mrhLkmgAngwR1pHjbWXaoGybtiAYr0moQ93GrBQsCzPbvl82rZhaXO3iH5uHo/RCEpOqp\nPgg29363BGR+/Ripq/VCLKGNbw==\n-----END MEGOLM SESSION DATA-----"
val expectedString = "alphanumericallyalphanumericallyalphanumericallyalphanumerically" val expectedString = "alphanumericallyalphanumericallyalphanumericallyalphanumerically"
var decodedString: String? = null var decodedString: String? = null
@ -205,8 +202,7 @@ class ExportEncryptionTest {
@Test @Test
fun checkExportEncrypt4() { fun checkExportEncrypt4() {
val password = val password = "passwordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpassword" + "passwordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpassword"
"passwordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpassword" + "passwordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpasswordpassword"
val expectedString = "alphanumericallyalphanumericallyalphanumericallyalphanumerically" val expectedString = "alphanumericallyalphanumericallyalphanumericallyalphanumerically"
var decodedString: String? = null var decodedString: String? = null

View File

@ -260,18 +260,18 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
private fun handleGlobalError(globalError: GlobalError) { private fun handleGlobalError(globalError: GlobalError) {
when (globalError) { when (globalError) {
is GlobalError.InvalidToken -> is GlobalError.InvalidToken -> handleInvalidToken(globalError)
handleInvalidToken(globalError) is GlobalError.ConsentNotGivenError -> displayConsentNotGivenDialog(globalError)
is GlobalError.ConsentNotGivenError -> is GlobalError.CertificateError -> handleCertificateError(globalError)
consentNotGivenHelper.displayDialog(globalError.consentUri,
activeSessionHolder.getActiveSession().sessionParams.homeServerHost ?: "")
is GlobalError.CertificateError ->
handleCertificateError(globalError)
GlobalError.ExpiredAccount -> Unit // TODO Handle account expiration GlobalError.ExpiredAccount -> Unit // TODO Handle account expiration
is GlobalError.InitialSyncRequest -> handleInitialSyncRequest(globalError) is GlobalError.InitialSyncRequest -> handleInitialSyncRequest(globalError)
} }
} }
private fun displayConsentNotGivenDialog(globalError: GlobalError.ConsentNotGivenError) {
consentNotGivenHelper.displayDialog(globalError.consentUri, activeSessionHolder.getActiveSession().sessionParams.homeServerHost ?: "")
}
private fun handleInitialSyncRequest(initialSyncRequest: GlobalError.InitialSyncRequest) { private fun handleInitialSyncRequest(initialSyncRequest: GlobalError.InitialSyncRequest) {
MaterialAlertDialogBuilder(this) MaterialAlertDialogBuilder(this)
.setTitle(R.string.initial_sync_request_title) .setTitle(R.string.initial_sync_request_title)