Treat the unexpected error on homepage endpoints as not logged in

This commit is contained in:
Mikołaj Pich 2019-08-11 19:37:38 +02:00
parent e0e12226ab
commit d95867e200
No known key found for this signature in database
GPG key ID: F62B26E36D4C4BAA
2 changed files with 12 additions and 0 deletions

View file

@ -13,6 +13,12 @@ class NotLoggedInErrorInterceptor(private val loginType: Api.LoginType) : Interc
val response = chain.proceed(chain.request())
val doc = Jsoup.parse(response.peekBody(Long.MAX_VALUE).string())
if (chain.request().url().toString().contains("/Start.mvc/")) {
doc.select(".errorBlock").let {
if (it.isNotEmpty()) throw NotLoggedInException("${it.select(".errorTitle").text()}}")
}
}
if (when (loginType) {
Api.LoginType.STANDARD -> doc.select(".loginButton, .LogOnBoard input[type=submit]")
Api.LoginType.ADFS -> doc.select("form[name=form1] #SubmitButton")

View file

@ -530,4 +530,10 @@ class ApiRemoteTest : BaseTest() {
//
// assertTrue(luckyNumberObserver.values().size == 0 || luckyNumberObserver.values()[0] != 0)
// }
@Test
fun freeDays() {
val freeDays = api.getFreeDays().blockingGet()
assertEquals(1, freeDays.size)
}
}