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>

source

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();
source

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();
source

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();
source

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();
source

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();
source

pub fn build(self) -> Login<'a>

Build the Login object which is then passed to the log_in function.

Example
use goose_eggs::drupal::SearchParams;

// Use the default search form to search for `example keys`.
let search_params = SearchParams::builder()
    .keys("example keys")
    .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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> GooseUserData for Twhere T: Send + Sync + 'static,