Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add inverse validation functions #58

Merged
merged 10 commits into from
Oct 31, 2023
Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.5.2-dev
- match "http://example.com/example.css", "/path/to/example.css", and "path/to/example.css" formatted paths for all types of static assets
- introduce `not_status()`, `not_title()`, `not_text()`, `not_texts()`, `not_header()`, and `not_header_value()`

## 0.5.1 January 28, 2023
- in `drupal::log_in`
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ default = ["goose/default", "reqwest/default-tls"]
rustls-tls = ["goose/rustls-tls", "reqwest/rustls-tls"]

[dev-dependencies]
gumdrop = "0.8"
gumdrop = "0.8"
httpmock = "0.6"
8 changes: 4 additions & 4 deletions src/drupal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,11 @@ pub async fn log_in(
};

// Load the log in page.
let goose = if validate.status.is_some() {
let goose = if let Some(validate_status) = validate.status.as_ref() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool pattern, I haven't seen this before

// Build request manually if validating a specific status code.
let goose_request = GooseRequest::builder()
.path(login.url)
.expect_status_code(validate.status.unwrap())
.expect_status_code(validate_status.status_code)
.build();
user.request(goose_request).await.unwrap()
} else {
Expand Down Expand Up @@ -672,15 +672,15 @@ pub async fn log_in(
("op", &"Log+in".to_string()),
];
// Post the log in form.
let mut logged_in_user = if validate.status.is_some() {
let mut logged_in_user = if let Some(validate_status) = validate.status.as_ref() {
// Build request manually if validating a specific status code.
let url = user.build_url(login.url)?;
// A request builder object is necessary to post a form.
let reqwest_request_builder = user.client.post(&url);
let goose_request = GooseRequest::builder()
.path(login.url)
.method(GooseMethod::Post)
.expect_status_code(validate.status.unwrap())
.expect_status_code(validate_status.status_code)
.set_request_builder(reqwest_request_builder.form(&params))
.build();
user.request(goose_request).await.unwrap()
Expand Down
Loading
Loading