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() {
|
fun urlError() {
|
||||||
performLogin("10.0.2.2:8888")
|
performLogin("10.0.2.2:8888")
|
||||||
onView(withId(R.id.urlView)).perform(click())
|
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)))
|
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
|
@Test
|
||||||
fun multiError() {
|
fun multiError() {
|
||||||
onView(withId(R.id.signInButton)).perform(click())
|
onView(withId(R.id.signInButton)).perform(click())
|
||||||
|
@ -149,9 +149,10 @@ class LoginActivity :
|
|||||||
.toString()
|
.toString()
|
||||||
.trim()
|
.trim()
|
||||||
|
|
||||||
failInvalidUrl(url)
|
val cancelUrl = failInvalidUrl(url)
|
||||||
failLoginDetails(password, login)
|
if (cancelUrl) return
|
||||||
|
val cancelDetails = failLoginDetails(password, login)
|
||||||
|
if (cancelDetails) return
|
||||||
showProgress(true)
|
showProgress(true)
|
||||||
|
|
||||||
appSettingsService.updateSelfSigned(binding.selfSigned.isChecked)
|
appSettingsService.updateSelfSigned(binding.selfSigned.isChecked)
|
||||||
@ -193,7 +194,7 @@ class LoginActivity :
|
|||||||
private fun failLoginDetails(
|
private fun failLoginDetails(
|
||||||
password: String,
|
password: String,
|
||||||
login: String,
|
login: String,
|
||||||
) {
|
): Boolean {
|
||||||
var lastFocusedView: View? = null
|
var lastFocusedView: View? = null
|
||||||
var cancel = false
|
var cancel = false
|
||||||
if (isWithLogin) {
|
if (isWithLogin) {
|
||||||
@ -210,9 +211,10 @@ class LoginActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
maybeCancelAndFocusView(cancel, lastFocusedView)
|
maybeCancelAndFocusView(cancel, lastFocusedView)
|
||||||
|
return cancel
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun failInvalidUrl(url: String) {
|
private fun failInvalidUrl(url: String): Boolean {
|
||||||
val focusView = binding.urlView
|
val focusView = binding.urlView
|
||||||
var cancel = false
|
var cancel = false
|
||||||
if (url.isBaseUrlInvalid()) {
|
if (url.isBaseUrlInvalid()) {
|
||||||
@ -232,6 +234,7 @@ class LoginActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
maybeCancelAndFocusView(cancel, focusView)
|
maybeCancelAndFocusView(cancel, focusView)
|
||||||
|
return cancel
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun maybeCancelAndFocusView(
|
private fun maybeCancelAndFocusView(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user