feat(proto): enum hygiene for rule export format and account TLS #356
No files matched your search
@@ -53,6 +53,20 @@ fn parse_account_protocol(protocol: &str) -> Result<nuncio_proto::v1::AccountPro
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses a `filter export --format` CLI string into its wire-format
|
||||
/// `nuncio.v1.RuleExportFormat` value. Rejects anything else rather than
|
||||
/// silently falling back to one rendering, since a typo'd format should
|
||||
/// surface as an error, not a surprising output shape.
|
||||
fn parse_rule_export_format(format: &str) -> Result<nuncio_proto::v1::RuleExportFormat, String> {
|
||||
match format.to_ascii_lowercase().as_str() {
|
||||
"sql" => Ok(nuncio_proto::v1::RuleExportFormat::Sql),
|
||||
"json" => Ok(nuncio_proto::v1::RuleExportFormat::Json),
|
||||
other => Err(format!(
|
||||
"invalid export format '{other}' (expected sql or json)"
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Renders a wire-format `google.protobuf.Timestamp` as an RFC 3339 UTC
|
||||
/// string for human-readable and `--json` output. `nanos` outside
|
||||
/// `0..1_000_000_000` (never produced by the daemon's own mappers) and an
|
||||
@@ -1561,6 +1575,11 @@ impl HeadlessRunner {
|
||||
/// the daemon's real, persistent store -- not this runner's own
|
||||
/// ephemeral local `db`.
|
||||
async fn handle_filter_export(&self, format: &str, json_mode: bool) -> String {
|
||||
let format = match parse_rule_export_format(format) {
|
||||
Ok(f) => f,
|
||||
Err(e) => return Self::render_error(&e, json_mode),
|
||||
};
|
||||
|
||||
let mut client = match self.connect_filters_client().await {
|
||||
Ok(client) => client,
|
||||
Err(e) => return Self::render_error(&e, json_mode),
|
||||
@@ -1568,7 +1587,7 @@ impl HeadlessRunner {
|
||||
|
||||
match client
|
||||
.export_rules(nuncio_proto::v1::ExportRulesRequest {
|
||||
format: format.to_string(),
|
||||
format: format.into(),
|
||||
})
|
||||
.await
|
||||
{
|
||||
@@ -1863,7 +1882,6 @@ impl HeadlessRunner {
|
||||
imap_host.to_string()
|
||||
},
|
||||
server_port: if is_caldav { 0 } else { u32::from(imap_port) },
|
||||
use_tls: true,
|
||||
imap_tls_mode: map_tls_mode_to_proto(imap_tls_mode).into(),
|
||||
smtp_tls_mode: map_tls_mode_to_proto(smtp_tls_mode).into(),
|
||||
keyring_secret_key: keyring_key.clone(),
|
||||
@@ -1974,7 +1992,6 @@ impl HeadlessRunner {
|
||||
"server_port": a.server_port,
|
||||
"smtp_host": a.smtp_host,
|
||||
"smtp_port": a.smtp_port,
|
||||
"use_tls": a.use_tls,
|
||||
"imap_tls_mode": a.imap_tls_mode().as_str_name(),
|
||||
"smtp_tls_mode": a.smtp_tls_mode().as_str_name(),
|
||||
"keyring_secret_key": a.keyring_secret_key,
|
||||
@@ -1997,15 +2014,16 @@ impl HeadlessRunner {
|
||||
));
|
||||
} else {
|
||||
out.push_str(&format!(
|
||||
"\n [{}] {} <{}> IMAP {}:{} SMTP {}:{} TLS={}",
|
||||
"\n [{}] {} <{}> IMAP {}:{} ({}) SMTP {}:{} ({})",
|
||||
a.id,
|
||||
a.name,
|
||||
a.email_address,
|
||||
a.server_host,
|
||||
a.server_port,
|
||||
a.imap_tls_mode().as_str_name(),
|
||||
a.smtp_host,
|
||||
a.smtp_port,
|
||||
a.use_tls,
|
||||
a.smtp_tls_mode().as_str_name(),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -2069,7 +2087,6 @@ impl HeadlessRunner {
|
||||
"server_port": account.server_port,
|
||||
"smtp_host": account.smtp_host,
|
||||
"smtp_port": account.smtp_port,
|
||||
"use_tls": account.use_tls,
|
||||
"imap_tls_mode": account.imap_tls_mode().as_str_name(),
|
||||
"smtp_tls_mode": account.smtp_tls_mode().as_str_name(),
|
||||
"keyring_secret_key": account.keyring_secret_key,
|
||||
@@ -3103,7 +3120,6 @@ mod tests {
|
||||
protocol: AccountProtocolProto::ImapSmtp.into(),
|
||||
server_host: "imap.nuncio.mx".to_string(),
|
||||
server_port: 993,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsModeProto::ImplicitTls.into(),
|
||||
smtp_tls_mode: TlsModeProto::ImplicitTls.into(),
|
||||
keyring_secret_key: "nuncio/acct-stub-1".to_string(),
|
||||
@@ -4320,7 +4336,7 @@ mod tests {
|
||||
request: tonic::Request<ExportRulesRequest>,
|
||||
) -> Result<tonic::Response<ExportRulesResponse>, tonic::Status> {
|
||||
let req = request.into_inner();
|
||||
let content = if req.format == "json" {
|
||||
let content = if req.format() == nuncio_proto::v1::RuleExportFormat::Json {
|
||||
r#"[{"id":"rule-stub-1"}]"#.to_string()
|
||||
} else {
|
||||
"SELECT * FROM emails WHERE subject CONTAINS 'Urgent' ACTION MARK READ"
|
||||
|
||||
@@ -95,8 +95,6 @@ pub struct AccountConfig {
|
||||
pub smtp_host: String,
|
||||
/// SMTP server port number, used for outbound mail.
|
||||
pub smtp_port: u16,
|
||||
/// Whether TLS connection encryption is enabled.
|
||||
pub use_tls: bool,
|
||||
/// IMAP connection security transport mode.
|
||||
pub imap_tls_mode: TlsMode,
|
||||
/// SMTP connection security transport mode.
|
||||
@@ -247,7 +245,6 @@ mod tests {
|
||||
server_port: 443,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-123".to_string(),
|
||||
@@ -266,7 +263,6 @@ mod tests {
|
||||
server_port: 0,
|
||||
smtp_host: String::new(),
|
||||
smtp_port: 0,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-cal-1".to_string(),
|
||||
|
||||
Binary file not shown.
@@ -270,8 +270,8 @@ message AccountConfig {
|
||||
string server_host = 5;
|
||||
// Server port number (1..=65535) (IMAP/JMAP).
|
||||
uint32 server_port = 6;
|
||||
// Whether TLS connection encryption is enabled.
|
||||
bool use_tls = 7;
|
||||
reserved 7;
|
||||
reserved "use_tls";
|
||||
// IMAP connection security transport mode.
|
||||
TlsMode imap_tls_mode = 8;
|
||||
// SMTP connection security transport mode.
|
||||
@@ -844,10 +844,21 @@ message UpdateRuleResponse {
|
||||
FilterRule rule = 1;
|
||||
}
|
||||
|
||||
// Rendering format for `ExportRules`. Kept distinct from `ExportFormat`
|
||||
// (the mailbox `Export` service's format enum) because the two have no
|
||||
// overlapping members and no shared meaning -- rule export renders lossless
|
||||
// NSQL source or a JSON array of rule definitions, never MBOX/EML/JSONL.
|
||||
enum RuleExportFormat {
|
||||
RULE_EXPORT_FORMAT_UNSPECIFIED = 0;
|
||||
// Lossless NSQL source text, one rule per line.
|
||||
RULE_EXPORT_FORMAT_SQL = 1;
|
||||
// JSON array of rule definitions.
|
||||
RULE_EXPORT_FORMAT_JSON = 2;
|
||||
}
|
||||
|
||||
// ExportRulesRequest names the rendering format for `ExportRules`.
|
||||
message ExportRulesRequest {
|
||||
// "sql" or "json".
|
||||
string format = 1;
|
||||
RuleExportFormat format = 1;
|
||||
}
|
||||
|
||||
// ExportRulesResponse carries every persisted rule pre-rendered as a single
|
||||
|
||||
@@ -499,7 +499,11 @@ impl DatabaseEngine {
|
||||
protocol TEXT NOT NULL,
|
||||
server_host TEXT NOT NULL,
|
||||
server_port INTEGER NOT NULL,
|
||||
use_tls INTEGER NOT NULL,
|
||||
-- Retained (with a default) for on-disk compatibility with
|
||||
-- rows written before `imap_tls_mode`/`smtp_tls_mode` became
|
||||
-- the authoritative transport-security setting; no code
|
||||
-- reads or writes this column anymore.
|
||||
use_tls INTEGER NOT NULL DEFAULT 1,
|
||||
keyring_secret_key TEXT NOT NULL,
|
||||
sync_interval_secs INTEGER NOT NULL,
|
||||
smtp_host TEXT,
|
||||
@@ -964,7 +968,13 @@ impl DatabaseEngine {
|
||||
.bind(protocol_str)
|
||||
.bind(&config.server_host)
|
||||
.bind(config.server_port as i64)
|
||||
.bind(if config.use_tls { 1i64 } else { 0i64 })
|
||||
// `use_tls` is a retained-but-unread on-disk column (see the
|
||||
// `CREATE TABLE`'s comment) -- written as a fixed placeholder since
|
||||
// no `AccountConfig` field backs it anymore, satisfying its
|
||||
// pre-existing `NOT NULL` constraint on every accounts table
|
||||
// regardless of whether it was created before or after this column
|
||||
// stopped being read.
|
||||
.bind(1i64)
|
||||
.bind(&config.keyring_secret_key)
|
||||
.bind(config.sync_interval_secs as i64)
|
||||
.bind(&config.smtp_host)
|
||||
@@ -1010,7 +1020,6 @@ impl DatabaseEngine {
|
||||
String,
|
||||
String,
|
||||
i64,
|
||||
i64,
|
||||
String,
|
||||
i64,
|
||||
Option<String>,
|
||||
@@ -1020,7 +1029,7 @@ impl DatabaseEngine {
|
||||
Option<String>,
|
||||
)> = sqlx::query_as(
|
||||
r#"
|
||||
SELECT id, name, email_address, protocol, server_host, server_port, use_tls, keyring_secret_key, sync_interval_secs, smtp_host, smtp_port, imap_tls_mode, smtp_tls_mode, collection_url
|
||||
SELECT id, name, email_address, protocol, server_host, server_port, keyring_secret_key, sync_interval_secs, smtp_host, smtp_port, imap_tls_mode, smtp_tls_mode, collection_url
|
||||
FROM accounts
|
||||
"#,
|
||||
)
|
||||
@@ -1038,7 +1047,6 @@ impl DatabaseEngine {
|
||||
protocol_str,
|
||||
server_host,
|
||||
server_port,
|
||||
use_tls,
|
||||
keyring_secret_key,
|
||||
sync_interval_secs,
|
||||
smtp_host,
|
||||
@@ -1069,7 +1077,6 @@ impl DatabaseEngine {
|
||||
server_port: server_port as u16,
|
||||
smtp_host: resolved_smtp_host,
|
||||
smtp_port: resolved_smtp_port,
|
||||
use_tls: use_tls != 0,
|
||||
imap_tls_mode: tls_mode_from_db(&imap_tls_mode),
|
||||
smtp_tls_mode: tls_mode_from_db(&smtp_tls_mode),
|
||||
keyring_secret_key,
|
||||
@@ -2765,7 +2772,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-contended-1".to_string(),
|
||||
@@ -3345,7 +3351,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-test-1".to_string(),
|
||||
@@ -3389,7 +3394,6 @@ mod tests {
|
||||
server_port: 143,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 25,
|
||||
use_tls: false,
|
||||
imap_tls_mode: nuncio_core::TlsMode::StartTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::Plain,
|
||||
keyring_secret_key: "nuncio/acct-tls-1".to_string(),
|
||||
@@ -3430,7 +3434,6 @@ mod tests {
|
||||
server_port: 0,
|
||||
smtp_host: String::new(),
|
||||
smtp_port: 0,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-caldav-store-1".to_string(),
|
||||
@@ -3468,7 +3471,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-del-1".to_string(),
|
||||
@@ -3660,7 +3662,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 587,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::StartTls,
|
||||
keyring_secret_key: "nuncio/acct-post-migration".to_string(),
|
||||
|
||||
@@ -18,7 +18,6 @@ type SalvagedAccountRow = (
|
||||
String,
|
||||
String,
|
||||
i64,
|
||||
i64,
|
||||
String,
|
||||
i64,
|
||||
Option<String>,
|
||||
@@ -384,7 +383,7 @@ impl SqliteRecoveryEngine {
|
||||
|
||||
async fn salvage_accounts(pool: &sqlx::SqlitePool) -> Vec<nuncio_core::AccountConfig> {
|
||||
let rows: Result<Vec<SalvagedAccountRow>, _> = sqlx::query_as(
|
||||
"SELECT id, name, email_address, protocol, server_host, server_port, use_tls, keyring_secret_key, sync_interval_secs, smtp_host, smtp_port, imap_tls_mode, smtp_tls_mode, collection_url FROM accounts"
|
||||
"SELECT id, name, email_address, protocol, server_host, server_port, keyring_secret_key, sync_interval_secs, smtp_host, smtp_port, imap_tls_mode, smtp_tls_mode, collection_url FROM accounts"
|
||||
)
|
||||
.fetch_all(pool)
|
||||
.await;
|
||||
@@ -400,7 +399,6 @@ impl SqliteRecoveryEngine {
|
||||
protocol_str,
|
||||
server_host,
|
||||
server_port,
|
||||
use_tls,
|
||||
keyring_secret_key,
|
||||
sync_interval_secs,
|
||||
smtp_host,
|
||||
@@ -433,7 +431,6 @@ impl SqliteRecoveryEngine {
|
||||
server_port: server_port as u16,
|
||||
smtp_host: resolved_smtp_host,
|
||||
smtp_port: resolved_smtp_port,
|
||||
use_tls: use_tls != 0,
|
||||
imap_tls_mode,
|
||||
smtp_tls_mode,
|
||||
keyring_secret_key,
|
||||
@@ -606,7 +603,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-test-1".to_string(),
|
||||
@@ -668,7 +664,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-salvage-1".to_string(),
|
||||
@@ -806,7 +801,6 @@ mod tests {
|
||||
server_port: 143,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 587,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::StartTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::Plain,
|
||||
keyring_secret_key: "nuncio/acct-starttls-1".to_string(),
|
||||
|
||||
+39
-24
@@ -41,13 +41,14 @@ use nuncio_proto::v1::{
|
||||
ListFoldersResponse, ListMessagesRequest, ListMessagesResponse, ListRecordsRequest,
|
||||
ListRecordsResponse, ListRulesRequest, ListRulesResponse, MarkReadRequest, MarkReadResponse,
|
||||
Message as MessageProto, MessageFlagsChanged, MessageSearchHit, PreviewRuleRequest,
|
||||
PreviewRuleResponse, RemoveAccountRequest, RemoveAccountResponse, SearchMessagesRequest,
|
||||
SearchMessagesResponse, SendMessageRequest, SendMessageResponse, ShuttingDown,
|
||||
SubscribeRequest, SyncCompleted, SyncRequest, SyncResponse, SyncStarted,
|
||||
TestAccountConnectionRequest, TestAccountConnectionResponse, TlsMode as TlsModeProto,
|
||||
TriageProgress, TriageRequest, UpdateAccountRequest, UpdateAccountResponse, UpdateAvailable,
|
||||
UpdateRuleRequest, UpdateRuleResponse, ValidateRuleRequest, ValidateRuleResponse,
|
||||
VerifyChainRequest, VerifyChainResponse,
|
||||
PreviewRuleResponse, RemoveAccountRequest, RemoveAccountResponse,
|
||||
RuleExportFormat as RuleExportFormatProto, SearchMessagesRequest, SearchMessagesResponse,
|
||||
SendMessageRequest, SendMessageResponse, ShuttingDown, SubscribeRequest, SyncCompleted,
|
||||
SyncRequest, SyncResponse, SyncStarted, TestAccountConnectionRequest,
|
||||
TestAccountConnectionResponse, TlsMode as TlsModeProto, TriageProgress, TriageRequest,
|
||||
UpdateAccountRequest, UpdateAccountResponse, UpdateAvailable, UpdateRuleRequest,
|
||||
UpdateRuleResponse, ValidateRuleRequest, ValidateRuleResponse, VerifyChainRequest,
|
||||
VerifyChainResponse,
|
||||
};
|
||||
use nuncio_store::db::DatabaseEngine;
|
||||
use nuncio_store::search::SearchEngine;
|
||||
@@ -282,7 +283,6 @@ fn map_account_config_to_proto(config: nuncio_core::AccountConfig) -> AccountCon
|
||||
protocol: map_account_protocol_to_proto(config.protocol).into(),
|
||||
server_host: config.server_host,
|
||||
server_port: u32::from(config.server_port),
|
||||
use_tls: config.use_tls,
|
||||
imap_tls_mode: map_tls_mode_to_proto(config.imap_tls_mode).into(),
|
||||
smtp_tls_mode: map_tls_mode_to_proto(config.smtp_tls_mode).into(),
|
||||
keyring_secret_key: config.keyring_secret_key,
|
||||
@@ -321,7 +321,6 @@ fn map_account_config_from_proto(
|
||||
server_port,
|
||||
smtp_host: config.smtp_host,
|
||||
smtp_port,
|
||||
use_tls: config.use_tls,
|
||||
imap_tls_mode,
|
||||
smtp_tls_mode,
|
||||
keyring_secret_key: config.keyring_secret_key,
|
||||
@@ -2024,6 +2023,7 @@ impl Filters for FiltersGrpcService {
|
||||
request: Request<ExportRulesRequest>,
|
||||
) -> Result<Response<ExportRulesResponse>, Status> {
|
||||
let req = request.into_inner();
|
||||
let format = req.format();
|
||||
|
||||
let rules = self
|
||||
.db
|
||||
@@ -2031,15 +2031,17 @@ impl Filters for FiltersGrpcService {
|
||||
.await
|
||||
.map_err(|e| Status::internal(format!("failed to list filter rules: {e}")))?;
|
||||
|
||||
let content = if req.format == "json" {
|
||||
serde_json::to_string_pretty(&rules)
|
||||
.map_err(|e| Status::internal(format!("failed to render rules as JSON: {e}")))?
|
||||
} else {
|
||||
rules
|
||||
let content = match format {
|
||||
RuleExportFormatProto::Sql => rules
|
||||
.iter()
|
||||
.map(|r| r.to_nsql())
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
.join("\n"),
|
||||
RuleExportFormatProto::Json => serde_json::to_string_pretty(&rules)
|
||||
.map_err(|e| Status::internal(format!("failed to render rules as JSON: {e}")))?,
|
||||
RuleExportFormatProto::Unspecified => {
|
||||
return Err(Status::invalid_argument("rule export format is required"))
|
||||
}
|
||||
};
|
||||
|
||||
Ok(Response::new(ExportRulesResponse { content }))
|
||||
@@ -3342,7 +3344,6 @@ mod tests {
|
||||
protocol: AccountProtocolProto::ImapSmtp.into(),
|
||||
server_host: "imap.nuncio.mx".to_string(),
|
||||
server_port: 993,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsModeProto::ImplicitTls.into(),
|
||||
smtp_tls_mode: TlsModeProto::ImplicitTls.into(),
|
||||
keyring_secret_key: keyring_secret_key.to_string(),
|
||||
@@ -3737,7 +3738,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: key.to_string(),
|
||||
@@ -3781,7 +3781,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: key.to_string(),
|
||||
@@ -4349,7 +4348,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "127.0.0.1".to_string(),
|
||||
smtp_port: 1,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-send-1".to_string(),
|
||||
@@ -4518,7 +4516,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-injected-send-1".to_string(),
|
||||
@@ -4635,7 +4632,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-injected-send-fail-1".to_string(),
|
||||
@@ -4789,7 +4785,7 @@ mod tests {
|
||||
|
||||
let err = client
|
||||
.export_rules(ExportRulesRequest {
|
||||
format: "sql".to_string(),
|
||||
format: RuleExportFormatProto::Sql.into(),
|
||||
})
|
||||
.await
|
||||
.expect_err("missing bearer token must be rejected");
|
||||
@@ -5366,7 +5362,7 @@ mod tests {
|
||||
|
||||
let sql_export = client
|
||||
.export_rules(authed_bearer_request(ExportRulesRequest {
|
||||
format: "sql".to_string(),
|
||||
format: RuleExportFormatProto::Sql.into(),
|
||||
}))
|
||||
.await
|
||||
.expect("export_rules succeeds")
|
||||
@@ -5376,7 +5372,7 @@ mod tests {
|
||||
|
||||
let json_export = client
|
||||
.export_rules(authed_bearer_request(ExportRulesRequest {
|
||||
format: "json".to_string(),
|
||||
format: RuleExportFormatProto::Json.into(),
|
||||
}))
|
||||
.await
|
||||
.expect("export_rules succeeds")
|
||||
@@ -5385,6 +5381,25 @@ mod tests {
|
||||
assert!(json_export.content.contains("Export Me"));
|
||||
}
|
||||
|
||||
/// `ExportRules` rejects an unspecified format rather than silently
|
||||
/// defaulting to one rendering.
|
||||
#[tokio::test]
|
||||
async fn export_rules_rejects_unspecified_format() {
|
||||
let (addr, _handle, _db, _engine, _dir) = spawn_filters_test_server("correct-token").await;
|
||||
|
||||
let mut client = FiltersClient::connect(format!("http://{addr}"))
|
||||
.await
|
||||
.expect("client connects");
|
||||
|
||||
let err = client
|
||||
.export_rules(authed_bearer_request(ExportRulesRequest {
|
||||
format: RuleExportFormatProto::Unspecified.into(),
|
||||
}))
|
||||
.await
|
||||
.expect_err("unspecified format must be rejected");
|
||||
assert_eq!(err.code(), Code::InvalidArgument);
|
||||
}
|
||||
|
||||
/// `ImportRules` persists every line that parses AND reports the parse
|
||||
/// error for every line that does not -- proving failures are surfaced
|
||||
/// rather than silently dropped.
|
||||
|
||||
@@ -157,7 +157,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: "nuncio/acct-orch-1".to_string(),
|
||||
|
||||
@@ -238,7 +238,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "127.0.0.1".to_string(),
|
||||
smtp_port: 1,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: TlsMode::ImplicitTls,
|
||||
keyring_secret_key: format!("nuncio/{id}"),
|
||||
|
||||
@@ -520,7 +520,6 @@ mod tests {
|
||||
server_port: 443,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: TlsMode::ImplicitTls,
|
||||
keyring_secret_key: format!("nuncio/{id}"),
|
||||
@@ -612,7 +611,6 @@ mod tests {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: TlsMode::ImplicitTls,
|
||||
keyring_secret_key: format!("nuncio/{id}"),
|
||||
|
||||
@@ -82,7 +82,6 @@ fn sample_account_config() -> AccountConfig {
|
||||
protocol: AccountProtocol::ImapSmtp.into(),
|
||||
server_host: "imap.nuncio.mx".to_string(),
|
||||
server_port: 143,
|
||||
use_tls: false,
|
||||
imap_tls_mode: TlsMode::StartTls.into(),
|
||||
smtp_tls_mode: TlsMode::Plain.into(),
|
||||
keyring_secret_key: KEYRING_KEY.to_string(),
|
||||
|
||||
@@ -161,7 +161,6 @@ async fn caldav_production_sync_builds_real_client_and_persists_events() {
|
||||
protocol: AccountProtocolProto::Caldav.into(),
|
||||
server_host: String::new(),
|
||||
server_port: 0,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsModeProto::ImplicitTls.into(),
|
||||
smtp_tls_mode: TlsModeProto::ImplicitTls.into(),
|
||||
keyring_secret_key: KEYRING_KEY.to_string(),
|
||||
|
||||
@@ -104,7 +104,6 @@ fn sample_account() -> nuncio_core::AccountConfig {
|
||||
server_port: 993,
|
||||
smtp_host: "smtp.nuncio.mx".to_string(),
|
||||
smtp_port: 465,
|
||||
use_tls: true,
|
||||
imap_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
smtp_tls_mode: nuncio_core::TlsMode::ImplicitTls,
|
||||
keyring_secret_key: format!("nuncio/{ACCOUNT_ID}"),
|
||||
|
||||
@@ -61,7 +61,6 @@ fn sample_account_config() -> AccountConfig {
|
||||
protocol: AccountProtocol::ImapSmtp.into(),
|
||||
server_host: "imap.nuncio.mx".to_string(),
|
||||
server_port: 993,
|
||||
use_tls: true,
|
||||
imap_tls_mode: TlsMode::ImplicitTls.into(),
|
||||
smtp_tls_mode: TlsMode::ImplicitTls.into(),
|
||||
keyring_secret_key: KEYRING_KEY.to_string(),
|
||||
|
||||
Reference in new issue
Block a user