Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic test that all SSH key types can be created #254

Merged
merged 1 commit into from
May 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()))
}
}
}