Add required fields to adfs password reset request
This commit is contained in:
parent
b061de8c7f
commit
081542bced
6 changed files with 25 additions and 19 deletions
|
@ -196,7 +196,7 @@ class Scrapper {
|
|||
|
||||
fun getPasswordResetCaptcha(registerBaseUrl: String, symbol: String) = account.getPasswordResetCaptcha(registerBaseUrl, symbol)
|
||||
|
||||
fun sendPasswordResetRequest(registerBaseUrl: String, symbol: String, email: String, captchaCode: String): Single<Pair<Boolean, String>> {
|
||||
fun sendPasswordResetRequest(registerBaseUrl: String, symbol: String, email: String, captchaCode: String): Single<String> {
|
||||
return account.sendPasswordResetRequest(registerBaseUrl, symbol, email, captchaCode)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package io.github.wulkanowy.sdk.scrapper.register
|
||||
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.nodes.Element
|
||||
import pl.droidsonroids.jspoon.annotation.Selector
|
||||
|
||||
class SentUnlockAccountResponse {
|
||||
|
||||
@Selector("html")
|
||||
lateinit var html: Document
|
||||
lateinit var html: Element
|
||||
|
||||
@Selector("title")
|
||||
lateinit var title: String
|
||||
|
|
|
@ -31,8 +31,12 @@ class AccountRepository(private val account: AccountService) {
|
|||
return getPasswordResetUrl(registerBaseUrl, symbol).flatMap { (type, url) ->
|
||||
when (type) {
|
||||
STANDARD -> account.sendPasswordResetRequest(url, email, captchaCode)
|
||||
ADFS, ADFSCards -> account.sendPasswordResetRequestADFS(url, email, captchaCode)
|
||||
ADFSLight, ADFSLightScoped, ADFSLightCufs -> account.sendPasswordResetRequestADFSLight(url, email, captchaCode)
|
||||
ADFS, ADFSCards -> account.getPasswordResetPageADFS(url).flatMap {
|
||||
account.sendPasswordResetRequestADFS(url, email, captchaCode, (it.html.select("[type=hidden]").map { input ->
|
||||
input.attr("name") to input.attr("value")
|
||||
}).toMap().plus("btSend.x" to "5").plus("btSend.y" to "6"))
|
||||
}
|
||||
else -> throw ScrapperException("Never happen")
|
||||
}
|
||||
}.map { res ->
|
||||
|
@ -40,7 +44,7 @@ class AccountRepository(private val account: AccountService) {
|
|||
select(".ErrorMessage")?.text()?.let { // STANDARD
|
||||
if (it.contains("Niepoprawny adres email")) throw InvalidEmailException(it)
|
||||
}
|
||||
select("#ErrorTextLabel, #lblStatus")?.text()?.let { // ADFSLight, ADFSCards
|
||||
select(".ErrorMessage, #ErrorTextLabel, #lblStatus")?.text()?.let { // STANDARD, ADFSLight, ADFSCards
|
||||
if (it.contains("nie zostało odnalezione lub zostało zablokowane")) throw NoAccountFoundException(it)
|
||||
if (it.contains("żądanie nie zostało poprawnie autoryzowane")) throw InvalidCaptchaException(it)
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import io.github.wulkanowy.sdk.scrapper.register.SentUnlockAccountResponse
|
|||
import io.github.wulkanowy.sdk.scrapper.register.UnlockAccountResponse
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.Field
|
||||
import retrofit2.http.FieldMap
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
|
@ -26,14 +27,6 @@ interface AccountService {
|
|||
@Field("g-recaptcha-response") captchaCode: String
|
||||
): Single<SentUnlockAccountResponse>
|
||||
|
||||
@POST
|
||||
@FormUrlEncoded
|
||||
fun sendPasswordResetRequestADFS(
|
||||
@Url url: String,
|
||||
@Field("txtUserID") username: String,
|
||||
@Field("g-recaptcha-response") captchaCode: String
|
||||
): Single<SentUnlockAccountResponse>
|
||||
|
||||
@POST
|
||||
@FormUrlEncoded
|
||||
fun sendPasswordResetRequestADFSLight(
|
||||
|
@ -41,4 +34,16 @@ interface AccountService {
|
|||
@Field("UserId") username: String,
|
||||
@Field("g-recaptcha-response") captchaCode: String
|
||||
): Single<SentUnlockAccountResponse>
|
||||
|
||||
@GET
|
||||
fun getPasswordResetPageADFS(@Url url: String): Single<SentUnlockAccountResponse>
|
||||
|
||||
@POST
|
||||
@FormUrlEncoded
|
||||
fun sendPasswordResetRequestADFS(
|
||||
@Url url: String,
|
||||
@Field("txtUserID") username: String,
|
||||
@Field("g-recaptcha-response") captchaCode: String,
|
||||
@FieldMap viewStateParams: Map<String, String>
|
||||
): Single<SentUnlockAccountResponse>
|
||||
}
|
||||
|
|
|
@ -77,14 +77,11 @@ class ScrapperRemoteTest : BaseTest() {
|
|||
@Test
|
||||
fun sendPasswordResetRequest() {
|
||||
val res = api.sendPasswordResetRequest("https://fakelog.cf", "Default", "jan@fakelog.cf", "03AOLTBLQRPyr0pWvWLRAgD4hRLfxktoqD2IVweeMuXwbkpR_8S9YQtcS3cAXqUOyEw3NxfvwzV0lTjgFWyl8j3UXGQpsc2nvQcqIofj1N8DYfxvtZO-h24W_S0Z9-fDnfXErd7vERS-Ny4d5IU1FupBAEKvT8rrf3OA3GYYbMM7TwB8b_o9Tt192TqYnSxkyIYE4UdaZnLBA0KIXxlBAoqM6QGlPEsSPK9gmCGx-0hn68w-UBQkv_ghRruf4kpv2Shw5emcP-qHBlv3YjAagsb_358K0v8uGJeyLrx4dXN9Ky02TXFMKYWNHz29fjhfunxT73u_PrsLj56f-MjOXrqO894NkUlJ7RkTTclwIsqXtJ794LEBH--mtsqZBND0miR5-odmZszqiNB3V5UsS5ObsqF_fWMl2TCWyNTTvF4elOGwOEeKiumVpjB6e740COxvxN3vbkNWxP9eeghpd5nPN5l2wUV3VL2R5s44TbqHqkrkNpUOd3h7efs3cQtCfGc-tCXoqLC26LxT7aztvKpjXMuqGEf-7wbQ")
|
||||
val resObserver = TestObserver<Pair<Boolean, String>>()
|
||||
val resObserver = TestObserver<String>()
|
||||
res.subscribe(resObserver)
|
||||
resObserver.assertComplete()
|
||||
|
||||
with(resObserver.values()[0]) {
|
||||
assertEquals(true, first)
|
||||
assertTrue(second.startsWith("Wysłano wiadomość na zapisany w systemie adres e-mail"))
|
||||
}
|
||||
assertTrue(resObserver.values()[0].startsWith("Wysłano wiadomość na zapisany w systemie adres e-mail"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -169,7 +169,7 @@ class Sdk {
|
|||
|
||||
fun getPasswordResetCaptchaCode(registerBaseUrl: String, symbol: String) = scrapper.getPasswordResetCaptcha(registerBaseUrl, symbol)
|
||||
|
||||
fun sendPasswordResetRequest(registerBaseUrl: String, symbol: String, email: String, captchaCode: String): Single<Pair<Boolean, String>> {
|
||||
fun sendPasswordResetRequest(registerBaseUrl: String, symbol: String, email: String, captchaCode: String): Single<String> {
|
||||
return scrapper.sendPasswordResetRequest(registerBaseUrl, symbol, email, captchaCode)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue