Skip to content

Commit

Permalink
Merge pull request #254 from amberin/test-ssh-key-generation
Browse files Browse the repository at this point in the history
Add basic test that all SSH key types can be created
  • Loading branch information
amberin authored May 14, 2024
2 parents e74a25f + 8181bf2 commit 1c08c23
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.orgzly.android.espresso

import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.Espresso.pressBack
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import com.orgzly.R
import com.orgzly.android.OrgzlyTest
import com.orgzly.android.espresso.util.EspressoUtils
import com.orgzly.android.ui.main.MainActivity
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized


@RunWith(value = Parameterized::class)
class SshKeyCreationTest(private val param: Parameter) : OrgzlyTest() {
data class Parameter(val keyType: Int)
companion object {
@JvmStatic
@Parameterized.Parameters
fun data(): Collection<Parameter> {
return listOf(
Parameter(keyType = R.string.ssh_keygen_label_rsa),
Parameter(keyType = R.string.ssh_keygen_label_ecdsa),
Parameter(keyType = R.string.ssh_keygen_label_ed25519),
)
}
}

@Test
fun testCreateUnprotectedKey() {
ActivityScenario.launch(MainActivity::class.java).use {
EspressoUtils.onActionItemClick(R.id.activity_action_settings, R.string.settings)
EspressoUtils.clickSetting(null, R.string.app)
EspressoUtils.clickSetting(null, R.string.developer_options)
EspressoUtils.clickSetting(null, R.string.git_repository_type)
pressBack()
pressBack()
EspressoUtils.clickSetting(null, R.string.sync)
EspressoUtils.clickSetting(null, R.string.ssh_keygen_preference_title)
onView(withText(param.keyType)).perform(click())
onView(withText(R.string.ssh_keygen_generate)).perform(click())
getInstrumentation().waitForIdleSync()
onView(withText(R.string.your_public_key)).inRoot(isDialog())
.check(matches(isDisplayed()))
}
}
}

0 comments on commit 1c08c23

Please sign in to comment.