-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
412 additions
and
72 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
FlowCrypt/src/androidTest/assets/messages/info/encrypted_msg_need_passphrase_single_key.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"encryptionType": "STANDARD", | ||
"inlineSubject": "Simple encrypted message", | ||
"localFolder": { | ||
"account": "[email protected]", | ||
"attributes": [ | ||
"\\HasNoChildren" | ||
], | ||
"folderAlias": "INBOX", | ||
"fullName": "INBOX", | ||
"isCustom": false, | ||
"msgCount": 14 | ||
}, | ||
"msgBlocks": [ | ||
{ | ||
"complete": true, | ||
"content": "\n \u003c!DOCTYPE html\u003e\u003chtml\u003e\n \u003chead\u003e\n \u003cmeta name\u003d\"viewport\" content\u003d\"width\u003ddevice-width\" /\u003e\n \u003cstyle\u003e\n body { word-wrap: break-word; word-break: break-word; hyphens: auto; margin-left: 0px; padding-left: 0px; }\n body img { display: inline !important; height: auto !important; max-width: 95% !important; }\n body pre { white-space: pre-wrap !important; }\n body \u003e div.MsgBlock \u003e table { zoom: 75% } /* table layouts tend to overflow - eg emails from fb */\n \u003c/style\u003e\n \u003c/head\u003e\n \u003cbody\u003e\u003c/body\u003e\n \u003c/html\u003e", | ||
"type": "plainHtml" | ||
}, | ||
{ | ||
"complete": true, | ||
"content": "-----BEGIN PGP MESSAGE-----\nVersion: PGPainless\n\nhF4D16Pe22XLHvsSAQdAfIIpNkCZvyOeQ+WY3ZuqJVaCaGuTj+gafXZsjZEGUBkw\nFEoutq0LAaIoZgTpVdcjFhOuUmfiyy0NLYoenh+45SQcUDFuD6DwO+sb0BeiurqW\nhF4DTxRYvSK3u1MSAQdA6ZqfNCDVMRS4E/jKqY2GZZO1dfaAG8QtAvgRp5yjClsw\nq0nR6a/jIv6JrAjI49xCAqTpLYyKSxyQAMlGgWnLn0Ltpq+4VA30nvQquFuFllK1\n0rUBNuGZH/Nvb44aCpthISzFUxbMlRSTW4ITqfx7Vu3Y7ECn/B4kvSXJx2HN/L47\nqO+fe3DPRAB7u+r8yRgJlSExOu7yodkJuIpm2RKHRk2WLaJilwK84/M6fjmvoO9n\nC9Y9EoJiCLfbXCTx/G0Y5iKvq2338oYd0LA/DHFUZpExkb21hsG37P0DubF/ZeKp\nRL/EpOo+vBKRrPp1nBpOXuiVwIecCnsRHS5GMnndVv1BpigYpDr1\n\u003dfWI0\n-----END PGP MESSAGE-----", | ||
"decryptErr": { | ||
"error": { | ||
"message": "Missing pass phrase", | ||
"type": "need_passphrase" | ||
}, | ||
"isEncrypted": true, | ||
"isSuccess": false, | ||
"longids": { | ||
"chosen": [], | ||
"matching": [ | ||
"3DEBE9F677D5B9BB38E5A244225F8023C20D0957" | ||
], | ||
"message": [ | ||
"D7A3DEDB65CB1EFB", | ||
"4F1458BD22B7BB53" | ||
], | ||
"needPassphrase": [ | ||
"3DEBE9F677D5B9BB38E5A244225F8023C20D0957" | ||
] | ||
} | ||
}, | ||
"type": "decryptErr" | ||
} | ||
], | ||
"msgEntity": { | ||
"cc": [], | ||
"email": "[email protected]", | ||
"flags": "\\SEEN", | ||
"folder": "INBOX", | ||
"from": [ | ||
{ | ||
"address": "[email protected]" | ||
} | ||
], | ||
"fromAddress": "[email protected]", | ||
"hasAttachments": false, | ||
"id": 292, | ||
"isSeen": true, | ||
"msgState": "NONE", | ||
"receivedDate": 1619763416000, | ||
"replyTo": "[email protected]", | ||
"replyToAddress": [ | ||
{ | ||
"address": "[email protected]" | ||
} | ||
], | ||
"sentDate": 1619763414000, | ||
"state": -1, | ||
"subject": "Simple encrypted message", | ||
"to": [ | ||
{ | ||
"address": "[email protected]" | ||
} | ||
], | ||
"toAddress": "[email protected]", | ||
"uid": 14, | ||
"uidAsHEX": "e" | ||
}, | ||
"text": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
FlowCrypt/src/androidTest/java/com/flowcrypt/email/matchers/ToastMatcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* © 2016-present FlowCrypt a.s. Limitations apply. Contact [email protected] | ||
* Contributors: DenBond7 | ||
*/ | ||
|
||
package com.flowcrypt.email.matchers | ||
|
||
import android.view.WindowManager | ||
import androidx.test.espresso.Root | ||
import androidx.test.espresso.remote.annotation.RemoteMsgConstructor | ||
import org.hamcrest.Description | ||
import org.hamcrest.TypeSafeMatcher | ||
|
||
/** | ||
* @author Denis Bondarenko | ||
* Date: 6/7/21 | ||
* Time: 11:37 AM | ||
* E-mail: [email protected] | ||
* | ||
* See details here | ||
* https://stackoverflow.com/questions/28390574/checking-toast-message-in-android-espresso | ||
*/ | ||
class ToastMatcher @RemoteMsgConstructor constructor() : TypeSafeMatcher<Root?>() { | ||
override fun describeTo(description: Description) { | ||
description.appendText("is toast") | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
public override fun matchesSafely(root: Root?): Boolean { | ||
val type = root?.windowLayoutParams?.get()?.type | ||
if (type == WindowManager.LayoutParams.TYPE_TOAST) { | ||
val windowToken = root.decorView.windowToken | ||
val appToken = root.decorView.applicationWindowToken | ||
if (windowToken === appToken) { // means this window isn't contained by any other windows. | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ package com.flowcrypt.email.rules | |
|
||
import com.flowcrypt.email.TestConstants | ||
import com.flowcrypt.email.database.entity.AccountEntity | ||
import com.flowcrypt.email.database.entity.KeyEntity | ||
import com.flowcrypt.email.model.KeyImportDetails | ||
import com.flowcrypt.email.security.model.PgpKeyDetails | ||
import com.flowcrypt.email.security.pgp.PgpKey | ||
|
@@ -25,22 +26,32 @@ class AddPrivateKeyToDatabaseRule( | |
val accountEntity: AccountEntity, | ||
val keyPath: String, | ||
val passphrase: String, | ||
val sourceType: KeyImportDetails.SourceType | ||
val sourceType: KeyImportDetails.SourceType, | ||
val passphraseType: KeyEntity.PassphraseType = KeyEntity.PassphraseType.DATABASE | ||
) : BaseRule() { | ||
|
||
lateinit var pgpKeyDetails: PgpKeyDetails | ||
private set | ||
|
||
constructor() : this( | ||
AccountDaoManager.getDefaultAccountDao(), "pgp/[email protected]_fisrtKey_prv_strong.asc", | ||
TestConstants.DEFAULT_STRONG_PASSWORD, KeyImportDetails.SourceType.EMAIL | ||
constructor(passphraseType: KeyEntity.PassphraseType = KeyEntity.PassphraseType.DATABASE) : this( | ||
accountEntity = AccountDaoManager.getDefaultAccountDao(), | ||
keyPath = "pgp/[email protected]_fisrtKey_prv_strong.asc", | ||
passphrase = TestConstants.DEFAULT_STRONG_PASSWORD, | ||
sourceType = KeyImportDetails.SourceType.EMAIL, | ||
passphraseType = passphraseType | ||
) | ||
|
||
override fun apply(base: Statement, description: Description): Statement { | ||
return object : Statement() { | ||
override fun evaluate() { | ||
pgpKeyDetails = PgpKey.parseKeys(context.assets.open(keyPath)).toPgpKeyDetailsList().first() | ||
PrivateKeysManager.saveKeyToDatabase(accountEntity, pgpKeyDetails, passphrase, sourceType) | ||
PrivateKeysManager.saveKeyToDatabase( | ||
accountEntity = accountEntity, | ||
pgpKeyDetails = pgpKeyDetails, | ||
passphrase = passphrase, | ||
sourceType = sourceType, | ||
passphraseType = passphraseType | ||
) | ||
base.evaluate() | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.