mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-30 13:57:47 +00:00
check that encryption works
This commit is contained in:
@@ -44,16 +44,15 @@ android {
|
|||||||
signingConfigs {
|
signingConfigs {
|
||||||
release {
|
release {
|
||||||
storeFile file(mStoreFile)
|
storeFile file(mStoreFile)
|
||||||
storePassword mStorePassword
|
storePassword mStorePassword
|
||||||
keyAlias mKeyAlias
|
keyAlias mKeyAlias
|
||||||
keyPassword mKeyPassword
|
keyPassword mKeyPassword
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buildTypes.release.signingConfig = signingConfigs.release
|
buildTypes.release.signingConfig = signingConfigs.release
|
||||||
} else {
|
} else {
|
||||||
buildTypes.release.signingConfig = null
|
buildTypes.release.signingConfig = null
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@@ -99,7 +99,7 @@ class DecryptTest {
|
|||||||
45
|
45
|
||||||
}
|
}
|
||||||
// second set the new timer
|
// second set the new timer
|
||||||
activity.settings.edit().putString("general_show_time", "3").commit()
|
activity.settings.edit().putString("general_show_time", "2").commit()
|
||||||
|
|
||||||
activity.onBound(null)
|
activity.onBound(null)
|
||||||
|
|
||||||
|
@@ -8,15 +8,13 @@ import android.support.test.espresso.Espresso.onView
|
|||||||
import android.support.test.espresso.action.ViewActions.*
|
import android.support.test.espresso.action.ViewActions.*
|
||||||
import android.support.test.espresso.assertion.ViewAssertions
|
import android.support.test.espresso.assertion.ViewAssertions
|
||||||
import android.support.test.espresso.matcher.ViewMatchers.withId
|
import android.support.test.espresso.matcher.ViewMatchers.withId
|
||||||
|
import android.support.test.espresso.matcher.ViewMatchers.withText
|
||||||
import android.support.test.filters.LargeTest
|
import android.support.test.filters.LargeTest
|
||||||
import android.support.test.rule.ActivityTestRule
|
import android.support.test.rule.ActivityTestRule
|
||||||
import android.support.test.runner.AndroidJUnit4
|
import android.support.test.runner.AndroidJUnit4
|
||||||
import com.zeapo.pwdstore.crypto.PgpActivity
|
import com.zeapo.pwdstore.crypto.PgpActivity
|
||||||
import kotlinx.android.synthetic.main.encrypt_layout.*
|
|
||||||
import org.apache.commons.io.FileUtils
|
import org.apache.commons.io.FileUtils
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Assert.assertNotNull
|
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@@ -58,35 +56,26 @@ class EncryptTest {
|
|||||||
activity = mActivityRule.launchActivity(intent)
|
activity = mActivityRule.launchActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun activityShouldShowCategory() {
|
|
||||||
init()
|
|
||||||
|
|
||||||
val categoryView = activity.crypto_password_category
|
|
||||||
assertNotNull(categoryView)
|
|
||||||
assertEquals(parentPath, categoryView.text.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("ApplySharedPref", "SetTextI18n")
|
@SuppressLint("ApplySharedPref", "SetTextI18n")
|
||||||
@Test
|
@Test
|
||||||
fun shouldEncrypt() {
|
fun shouldEncrypt() {
|
||||||
init()
|
init()
|
||||||
|
|
||||||
|
onView(withId(R.id.crypto_password_category)).check(ViewAssertions.matches(withText(parentPath)))
|
||||||
activity.onBound(null)
|
activity.onBound(null)
|
||||||
val clearPass = IOUtils.toString(testContext.assets.open("clear-store/category/sub"), Charsets.UTF_8.name())
|
val clearPass = IOUtils.toString(testContext.assets.open("clear-store/category/sub"), Charsets.UTF_8.name())
|
||||||
val passEntry = PasswordEntry(clearPass)
|
val passEntry = PasswordEntry(clearPass)
|
||||||
val encryptedEntry = IOUtils.toByteArray(testContext.assets.open("clear-store/category/sub"))
|
|
||||||
|
|
||||||
onView(withId(R.id.crypto_password_file_edit)).perform(typeText("category/sub"))
|
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_password_edit)).perform(typeText(passEntry.password))
|
||||||
onView(withId(R.id.crypto_extra_edit)).perform(scrollTo(), click())
|
onView(withId(R.id.crypto_extra_edit)).perform(scrollTo(), click())
|
||||||
onView(withId(R.id.crypto_extra_edit)).perform(typeText(passEntry.extraContent))
|
onView(withId(R.id.crypto_extra_edit)).perform(typeText(passEntry.extraContent))
|
||||||
|
|
||||||
// we should return to the home screen once we confirm
|
// we should return to the home screen once we confirm
|
||||||
onView(withId(R.id.crypto_confirm_add)).perform(click()).check(ViewAssertions.matches(withId(R.id.fab)))
|
onView(withId(R.id.crypto_confirm_add)).perform(click())
|
||||||
|
|
||||||
val resultEntry = FileUtils.readFileToByteArray(File("$path/$name.gpg"))
|
|
||||||
|
|
||||||
|
// The resulting file should exist
|
||||||
|
assert(File("$path/$name.gpg").exists())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user