fix: Url validation was not failing login. Added tests.
This commit is contained in:
parent
d5ec118679
commit
a1c98aa7d0
@ -60,9 +60,23 @@ class LoginActivityTest {
|
||||
fun urlError() {
|
||||
performLogin("10.0.2.2:8888")
|
||||
onView(withId(R.id.urlView)).perform(click())
|
||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.login_url_problem)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun connectError() {
|
||||
performLogin("http://10.0.2.2:8889")
|
||||
onView(withId(R.id.urlView)).perform(click())
|
||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.wrong_infos)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun urlSlashError() {
|
||||
performLogin("https://google.fr/toto")
|
||||
onView(withId(R.id.urlView)).perform(click())
|
||||
onView(withId(R.id.urlView)).check(matches(withError(R.string.login_url_problem)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun multiError() {
|
||||
onView(withId(R.id.signInButton)).perform(click())
|
||||
|
@ -149,9 +149,10 @@ class LoginActivity :
|
||||
.toString()
|
||||
.trim()
|
||||
|
||||
failInvalidUrl(url)
|
||||
failLoginDetails(password, login)
|
||||
|
||||
val cancelUrl = failInvalidUrl(url)
|
||||
if (cancelUrl) return
|
||||
val cancelDetails = failLoginDetails(password, login)
|
||||
if (cancelDetails) return
|
||||
showProgress(true)
|
||||
|
||||
appSettingsService.updateSelfSigned(binding.selfSigned.isChecked)
|
||||
@ -193,7 +194,7 @@ class LoginActivity :
|
||||
private fun failLoginDetails(
|
||||
password: String,
|
||||
login: String,
|
||||
) {
|
||||
): Boolean {
|
||||
var lastFocusedView: View? = null
|
||||
var cancel = false
|
||||
if (isWithLogin) {
|
||||
@ -210,9 +211,10 @@ class LoginActivity :
|
||||
}
|
||||
}
|
||||
maybeCancelAndFocusView(cancel, lastFocusedView)
|
||||
return cancel
|
||||
}
|
||||
|
||||
private fun failInvalidUrl(url: String) {
|
||||
private fun failInvalidUrl(url: String): Boolean {
|
||||
val focusView = binding.urlView
|
||||
var cancel = false
|
||||
if (url.isBaseUrlInvalid()) {
|
||||
@ -232,6 +234,7 @@ class LoginActivity :
|
||||
}
|
||||
}
|
||||
maybeCancelAndFocusView(cancel, focusView)
|
||||
return cancel
|
||||
}
|
||||
|
||||
private fun maybeCancelAndFocusView(
|
||||
|
Loading…
x
Reference in New Issue
Block a user