Struct goose_eggs::drupal::LoginBuilder
source · pub struct LoginBuilder<'a> { /* private fields */ }
Expand description
Used to build a Login
object, necessary to invoke the log_in
function.
Sets parameters that define how to log into a Drupal website and validate that the user loged in successfully.
This object is passed to the log_in
function.
The defined username
and/or password
can be dynamically overridden by setting
the GOOSE_USER
and/or GOOSE_PASS
environment variables when starting the load
test.
Example
use goose_eggs::drupal::Login;
fn examples() {
// Manually build a Login structure with custom default username and password,
// and a custom log in path.
let _login = Login::builder()
.username("foo")
.password("bar")
.url("custom/user/login")
.build();
}
Implementations§
source§impl<'a> LoginBuilder<'a>
impl<'a> LoginBuilder<'a>
sourcepub fn username(self, username: impl Into<&'a str>) -> Self
pub fn username(self, username: impl Into<&'a str>) -> Self
Used with Login::builder
to configure login parameters.
Defaults to username
.
Once built, the resulting object is passed to the log_in
function. The
username and password can still be overridden by the GOOSE_USER
and
GOOSE_PASS
environment variables.
Example
use goose_eggs::drupal::Login;
// Login with username "foo", and the default password of "password".
let _login = Login::builder()
.username("foo")
.build();
sourcepub fn password(self, password: impl Into<&'a str>) -> Self
pub fn password(self, password: impl Into<&'a str>) -> Self
Used with Login::builder
to configure login parameters.
Defaults to password
.
Once built, the resulting object is passed to the log_in
function. The
username and password can still be overridden by the GOOSE_USER
and
GOOSE_PASS
environment variables.
Example
use goose_eggs::drupal::Login;
// Login with username "bar", and the default username of "username".
let _login = Login::builder()
.password("bar")
.build();
sourcepub fn url(self, url: impl Into<&'a str>) -> Self
pub fn url(self, url: impl Into<&'a str>) -> Self
Used with Login::builder
to configure login parameters.
Defaults to user/login
.
Once built, the resulting object is passed to the log_in
function.
Example
use goose_eggs::drupal::Login;
// Login at a custom path.
let _login = Login::builder()
.password("custom/user/login")
.build();
sourcepub fn log_in_page_validation(self, validation: &'a Validate<'_>) -> Self
pub fn log_in_page_validation(self, validation: &'a Validate<'_>) -> Self
Used with Login::builder
to tell the log_in
function to perform extra
validation of the page containing the log in form.
Defaults to None
, so no extra validation is performed. By default it will still
validate that <form class="user-login-form"
exists on the log in page, and it
will load all static assets on the page with the log in form.
What validation should be performed is defined by passing a reference to a
Validate
object.
Once built, the resulting object is passed to the log_in
function.
Example
use goose_eggs::{drupal, Validate};
// This validation is done by default.
let validate = Validate::builder()
.text(r#"<form class="user-login-form"#)
.build();
let _login = drupal::Login::builder()
.log_in_page_validation(&validate)
.build();
sourcepub fn logged_in_page_validation(self, validation: &'a Validate<'_>) -> Self
pub fn logged_in_page_validation(self, validation: &'a Validate<'_>) -> Self
Used with Login::builder
to tell the log_in
function to perform extra
validation of the page returned once the user logs in.
Defaults to None
, so no extra validation is performed. By default it will still
validate that the username of the user that logged in is in the title, and will
load all static assets on the returned page.
What validation should be performed is defined by passing a reference to a
Validate
object.
Once built, the resulting object is passed to the log_in
function.
Example
use goose_eggs::drupal::SearchParams;
// Use Drupal's default search form to search for "foo bar".
let search_params = SearchParams::builder()
.keys("foo bar")
.build();
Example
use goose_eggs::{drupal, Validate};
let username = "foo";
// This validation is done by default.
let validate = Validate::builder()
.title(username)
.build();
let _login = drupal::Login::builder()
.username(username)
.logged_in_page_validation(&validate)
.build();
Auto Trait Implementations§
impl<'a> RefUnwindSafe for LoginBuilder<'a>
impl<'a> Send for LoginBuilder<'a>
impl<'a> Sync for LoginBuilder<'a>
impl<'a> Unpin for LoginBuilder<'a>
impl<'a> UnwindSafe for LoginBuilder<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.