init
This commit is contained in:
commit
4d0fa68c06
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
1181
Cargo.lock
generated
Normal file
1181
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "test-ssowat"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.11", features = [ "cookies", "blocking" ] }
|
43
src/main.rs
Normal file
43
src/main.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
use reqwest::blocking::Client;
|
||||
|
||||
pub type Form<'a> = [(&'a str, &'a str); 2];
|
||||
pub type Counter = u64;
|
||||
|
||||
const FORM: Form = [ ("username", "package_checker"), ("password", "SomeSuperStrongPassword" ) ];
|
||||
const URL: &'static str = "https://domain.tld/ssowat/login/";
|
||||
|
||||
fn post(client: &mut Client, count: Counter, uri: &str, form: &Form) -> String {
|
||||
let res = client.post(uri)
|
||||
.form(form)
|
||||
.send()
|
||||
.expect(&format!("[TEST{}] FAILED", count));
|
||||
res.text().expect(&format!("[TEST{}] UTF8 FAILED", count))
|
||||
}
|
||||
|
||||
fn login(client: &mut Client, count: Counter) {
|
||||
let body = post(client, count, URL, &FORM);
|
||||
|
||||
if ! body.starts_with("Welcome package_checker") {
|
||||
panic!("[TEST{}] Login does not contain string:\n{}", count, body);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn check_login(client: &mut Client, count: Counter) {
|
||||
if ! post(client, count, URL, &FORM).starts_with("Welcome back, package_checker") {
|
||||
panic!("[TEST{}] Check does not contain string", count);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut client = Client::builder()
|
||||
.danger_accept_invalid_certs(true)
|
||||
.cookie_store(true)
|
||||
.build().unwrap();
|
||||
let mut counter: Counter = 1;
|
||||
login(&mut client, counter);
|
||||
while counter < 1000 {
|
||||
counter += 1;
|
||||
check_login(&mut client, counter);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user