From 3c5a4d66cef427e4a6b5caa0d505897c83d008d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Fri, 30 Dec 2022 18:20:24 +0100 Subject: [PATCH] Update account unlock error validation --- .../sdk/scrapper/repository/AccountRepository.kt | 8 +++++--- .../io/github/wulkanowy/sdk/scrapper/BaseLocalTest.kt | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/AccountRepository.kt b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/AccountRepository.kt index 616778af..317be40d 100644 --- a/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/AccountRepository.kt +++ b/sdk-scrapper/src/main/kotlin/io/github/wulkanowy/sdk/scrapper/repository/AccountRepository.kt @@ -8,11 +8,11 @@ import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.ADFSLightCufs import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.ADFSLightScoped import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.AUTO import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.STANDARD -import io.github.wulkanowy.sdk.scrapper.exception.ScrapperException import io.github.wulkanowy.sdk.scrapper.exception.InvalidCaptchaException import io.github.wulkanowy.sdk.scrapper.exception.InvalidEmailException import io.github.wulkanowy.sdk.scrapper.exception.NoAccountFoundException import io.github.wulkanowy.sdk.scrapper.exception.PasswordResetErrorException +import io.github.wulkanowy.sdk.scrapper.exception.ScrapperException import io.github.wulkanowy.sdk.scrapper.login.UrlGenerator import io.github.wulkanowy.sdk.scrapper.service.AccountService import java.net.URL @@ -63,9 +63,11 @@ class AccountRepository(private val account: AccountService) { if (it.contains("żądanie nie zostało poprawnie autoryzowane")) throw InvalidCaptchaException(it) } } - if (!res.message.startsWith("Wysłano wiadomość")) throw PasswordResetErrorException("Unexpected message: ${res.message}") + if (res.message.isNotBlank() && !res.message.startsWith("Wysłano wiadomość")) { + throw PasswordResetErrorException("Unexpected message: ${res.message}") + } - return res.message + return res.message.ifBlank { "Wysłano wiadomość na zapisany w systemie adres e-mail" } } private suspend fun getPasswordResetUrl(registerBaseUrl: String, symbol: String): Pair { diff --git a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/BaseLocalTest.kt b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/BaseLocalTest.kt index 56201272..2eb4476f 100644 --- a/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/BaseLocalTest.kt +++ b/sdk-scrapper/src/test/kotlin/io/github/wulkanowy/sdk/scrapper/BaseLocalTest.kt @@ -83,7 +83,7 @@ abstract class BaseLocalTest : BaseTest() { autoLoginInterceptor: AutoLoginInterceptor = getAutoLoginInterceptor(loginType, autoLogin) ): OkHttpClient = OkHttpClient.Builder() .apply { - if (errorInterceptor) addInterceptor(ErrorInterceptor(cookies)) + if (errorInterceptor) addInterceptor(ErrorInterceptor(CookieManager())) if (autoLoginInterceptorOn) addInterceptor(autoLoginInterceptor) } .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC))