Skip to content

Commit

Permalink
Merge #105
Browse files Browse the repository at this point in the history
105: fix: harden login routine r=crepererum a=crepererum



Co-authored-by: Marco Neumann <[email protected]>
  • Loading branch information
bors[bot] and crepererum authored Oct 28, 2023
2 parents 9175e16 + 4168cfd commit 8271257
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions src/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,38 @@ pub async fn perform_login(config: LoginCLIConfig, webdriver: &WebDriver) -> Res
.context("find password input")?;
debug!("found username and password inputs");

input_username
.send_keys(config.username)
.await
.context("enter username")?;
input_password
.send_keys(config.password)
.await
.context("enter password")?;
tokio::time::timeout(Duration::from_secs(20), async {
loop {
input_username
.send_keys(&config.username)
.await
.context("enter username")?;
input_password
.send_keys(&config.password)
.await
.context("enter password")?;

// in some cases the UI seems to swallow the value (maybe because some JS wasn't loaded
// yet, who knows), so double-check the data and retry if the values are missing
let username = input_username
.prop("value")
.await
.context("check username value")?;
let password = input_password
.prop("value")
.await
.context("check password value")?;
if username.as_ref() == Some(&config.username)
&& password.as_ref() == Some(&config.password)
{
return Ok(()) as Result<()>;
}

tokio::time::sleep(Duration::from_secs(1)).await;
}
})
.await
.context("wait for login fields to converge")??;
debug!("entered username and password");

let login_button = webdriver
Expand Down

0 comments on commit 8271257

Please sign in to comment.