mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 21:37:55 +08:00
tests: add fastmail and stalwart integration tests
This commit is contained in:
+5
-1
@@ -289,8 +289,11 @@ pub struct JmapConfig {
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
|
||||
pub enum JmapAuthConfig {
|
||||
Header(Secret),
|
||||
/// Bearer token (OAuth 2.0 access token).
|
||||
Bearer { token: Secret },
|
||||
Bearer {
|
||||
token: Secret,
|
||||
},
|
||||
/// HTTP Basic authentication (username + password).
|
||||
Basic {
|
||||
#[serde(deserialize_with = "shell_expanded_string")]
|
||||
@@ -305,6 +308,7 @@ impl TryFrom<JmapAuthConfig> for pimalaya_toolbox::stream::jmap::JmapAuth {
|
||||
|
||||
fn try_from(config: JmapAuthConfig) -> Result<Self, Self::Error> {
|
||||
match config {
|
||||
JmapAuthConfig::Header(token) => Ok(Self::Header(token.get()?)),
|
||||
JmapAuthConfig::Bearer { token } => Ok(Self::Bearer(token.get()?)),
|
||||
JmapAuthConfig::Basic { username, password } => Ok(Self::Basic {
|
||||
username,
|
||||
|
||||
+14
-11
@@ -1,4 +1,4 @@
|
||||
use anyhow::{anyhow, bail, Result};
|
||||
use anyhow::{bail, Result};
|
||||
use clap::Parser;
|
||||
use io_jmap::{
|
||||
rfc8621::coroutines::identity_set::{
|
||||
@@ -50,7 +50,7 @@ impl JmapIdentityCreateCommand {
|
||||
let mut coroutine = JmapIdentitySet::new(&jmap.session, &jmap.http_auth, args)?;
|
||||
let mut arg = None;
|
||||
|
||||
let errs = loop {
|
||||
let not_created = loop {
|
||||
match coroutine.resume(arg.take()) {
|
||||
JmapIdentitySetResult::Io { io } => arg = Some(handle(&mut jmap.stream, io)?),
|
||||
JmapIdentitySetResult::Ok { not_created, .. } => break not_created,
|
||||
@@ -58,19 +58,22 @@ impl JmapIdentityCreateCommand {
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(err) = errs.get(create_id) {
|
||||
let mut ctx = anyhow!("Create identity for `{}` error", &self.email);
|
||||
|
||||
if let Some(desc) = &err.description {
|
||||
ctx = anyhow!("{desc}").context(ctx);
|
||||
}
|
||||
if let Some(err) = not_created.get(create_id) {
|
||||
let mut msg = format!("Create identity for `{}` error", self.email);
|
||||
|
||||
if !err.properties.is_empty() {
|
||||
let props = err.properties.join(", ");
|
||||
ctx = anyhow!("Invalid properties {props}").context(ctx);
|
||||
msg.push_str(": invalid propertie(s) `");
|
||||
msg.push_str(&err.properties.join("`, `"));
|
||||
msg.push('`');
|
||||
}
|
||||
|
||||
bail!(ctx);
|
||||
if let Some(desc) = &err.description {
|
||||
msg.push_str(" (");
|
||||
msg.push_str(desc.to_lowercase().trim_end_matches(['.', '\n']));
|
||||
msg.push_str(")");
|
||||
}
|
||||
|
||||
bail!(msg);
|
||||
}
|
||||
|
||||
printer.out(Message::new("Identity successfully created"))
|
||||
|
||||
Reference in New Issue
Block a user