aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/androidTest/java/com/zeapo/pwdstore/EncryptTest.kt
diff options
context:
space:
mode:
authorHarsh Shandilya <msfjarvis@gmail.com>2020-04-17 00:24:13 +0530
committerGitHub <noreply@github.com>2020-04-17 00:24:13 +0530
commit4ffd7ed9bffa5139277ffb91de5a69f2b714222c (patch)
treebccd7b27685d602da42d03111eeb4a36b1a803c1 /app/src/androidTest/java/com/zeapo/pwdstore/EncryptTest.kt
parent8b4751f8250dea3efe04c73a87bdfe2926e2ac3f (diff)
downloadHardenedPass-4ffd7ed9bffa5139277ffb91de5a69f2b714222c.tar.gz
HardenedPass-4ffd7ed9bffa5139277ffb91de5a69f2b714222c.zip
Enable emulator tests (#708)
* github: Enable instrumentation testing in PRs Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Upgrade to Gradle 6.3 Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Remove outdated and broken tests, redo PasswordEntryTest in Kotlin Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Remove now unused test assets Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * github: Disable debug APK uploads in PR testing Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Update .github/workflows/pull_request.yml * Update .github/workflows/pull_request.yml Switching to Ubuntu fails due to the SDK 29 missing. Co-authored-by: Fabian Henneke <FabianHenneke@users.noreply.github.com>
Diffstat (limited to 'app/src/androidTest/java/com/zeapo/pwdstore/EncryptTest.kt')
-rw-r--r--app/src/androidTest/java/com/zeapo/pwdstore/EncryptTest.kt100
1 files changed, 0 insertions, 100 deletions
diff --git a/app/src/androidTest/java/com/zeapo/pwdstore/EncryptTest.kt b/app/src/androidTest/java/com/zeapo/pwdstore/EncryptTest.kt
deleted file mode 100644
index ba63ce1a..00000000
--- a/app/src/androidTest/java/com/zeapo/pwdstore/EncryptTest.kt
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright © 2014-2020 The Android Password Store Authors. All Rights Reserved.
- * SPDX-License-Identifier: GPL-3.0-only
- */
-package com.zeapo.pwdstore
-
-import android.annotation.SuppressLint
-import android.content.Context
-import android.content.Intent
-import android.os.IBinder
-import android.os.ParcelFileDescriptor
-import androidx.test.espresso.Espresso.onView
-import androidx.test.espresso.action.ViewActions.click
-import androidx.test.espresso.action.ViewActions.scrollTo
-import androidx.test.espresso.action.ViewActions.typeText
-import androidx.test.espresso.assertion.ViewAssertions
-import androidx.test.espresso.matcher.ViewMatchers.withId
-import androidx.test.espresso.matcher.ViewMatchers.withText
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.LargeTest
-import androidx.test.platform.app.InstrumentationRegistry
-import androidx.test.rule.ActivityTestRule
-import com.zeapo.pwdstore.crypto.PgpActivity
-import java.io.File
-import org.apache.commons.io.FileUtils
-import org.apache.commons.io.IOUtils
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.openintents.openpgp.IOpenPgpService2
-
-@RunWith(AndroidJUnit4::class)
-@LargeTest
-class EncryptTest {
- private lateinit var targetContext: Context
- private lateinit var testContext: Context
- private lateinit var activity: PgpActivity
-
- private val name = "sub"
- private val parentPath = "/category/"
- private lateinit var path: String
- private lateinit var repoPath: String
-
- @Rule @JvmField
- var mActivityRule: ActivityTestRule<PgpActivity> = ActivityTestRule<PgpActivity>(PgpActivity::class.java, true, false)
-
- private fun init() {
- targetContext = InstrumentationRegistry.getInstrumentation().targetContext
- testContext = InstrumentationRegistry.getInstrumentation().context
-
- // have an empty store
- FileUtils.forceMkdir(File(targetContext.filesDir, "test-store"))
- FileUtils.cleanDirectory(File(targetContext.filesDir, "test-store"))
-
- repoPath = File(targetContext.filesDir, "test-store").absolutePath
-
- path = "$repoPath/$parentPath/".replace("//", "/")
-
- val intent = Intent(targetContext, PgpActivity::class.java)
- intent.putExtra("OPERATION", "ENCRYPT")
- intent.putExtra("FILE_PATH", path)
- intent.putExtra("REPO_PATH", repoPath)
-
- activity = mActivityRule.launchActivity(intent)
- }
-
- @SuppressLint("ApplySharedPref", "SetTextI18n")
- @Test
- fun shouldEncrypt() {
- init()
-
- onView(withId(R.id.crypto_password_category)).check(ViewAssertions.matches(withText(parentPath)))
- activity.onBound(object : IOpenPgpService2 {
- override fun createOutputPipe(p0: Int): ParcelFileDescriptor {
- TODO("Not yet implemented")
- }
-
- override fun asBinder(): IBinder {
- TODO("Not yet implemented")
- }
-
- override fun execute(p0: Intent?, p1: ParcelFileDescriptor?, p2: Int): Intent {
- TODO("Not yet implemented")
- }
- })
- val clearPass = IOUtils.toString(testContext.assets.open("clear-store/category/sub"), Charsets.UTF_8.name())
- val passEntry = PasswordEntry(clearPass)
-
- onView(withId(R.id.crypto_password_file_edit)).perform(typeText("sub"))
- onView(withId(R.id.crypto_password_edit)).perform(typeText(passEntry.password))
- onView(withId(R.id.crypto_extra_edit)).perform(scrollTo(), click())
- onView(withId(R.id.crypto_extra_edit)).perform(typeText(passEntry.extraContent))
-
- // we should return to the home screen once we confirm
- onView(withId(R.id.crypto_confirm_add)).perform(click())
-
- // The resulting file should exist
- assert(File("$path/$name.gpg").exists())
- }
-}