Authentication and form for newsletter publishing
This commit is contained in:
@@ -182,11 +182,25 @@ impl TestApp {
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn post_newsletters(&self, body: serde_json::Value) -> reqwest::Response {
|
||||
reqwest::Client::new()
|
||||
.post(format!("{}/newsletters", self.address))
|
||||
.json(&body)
|
||||
.basic_auth(&self.test_user.username, Some(&self.test_user.password))
|
||||
pub async fn get_newsletter_form(&self) -> reqwest::Response {
|
||||
self.api_client
|
||||
.get(format!("{}/admin/password", &self.address))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
}
|
||||
|
||||
pub async fn get_newsletter_form_html(&self) -> String {
|
||||
self.get_newsletter_form().await.text().await.unwrap()
|
||||
}
|
||||
|
||||
pub async fn post_newsletters<Body>(&self, body: &Body) -> reqwest::Response
|
||||
where
|
||||
Body: serde::Serialize,
|
||||
{
|
||||
self.api_client
|
||||
.post(format!("{}/admin/newsletters", self.address))
|
||||
.form(body)
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to execute request")
|
||||
|
||||
Reference in New Issue
Block a user