Complete eom with Status::Continue, cosmetics
This commit is contained in:
parent
4522f377c5
commit
b5ad9ce0dd
21 changed files with 33 additions and 28 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
## 0.2.1 (unreleased)
|
||||
|
||||
* Various cosmetic improvements in code and tests, and updates to
|
||||
documentation.
|
||||
* Update dependencies.
|
||||
|
||||
## 0.2.0 (2021-08-26)
|
||||
|
|
|
@ -55,7 +55,7 @@ provided `milter.pc` file. Put this file on the pkg-config path when running any
|
|||
Cargo command:
|
||||
|
||||
```
|
||||
PKG_CONFIG_PATH=. cargo build
|
||||
PKG_CONFIG_PATH=/path/to/milter.pc cargo build
|
||||
```
|
||||
|
||||
SpamAssassin Milter uses the `spamc` program for communication with SpamAssassin
|
||||
|
|
|
@ -292,7 +292,7 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(Status::Accept)
|
||||
Ok(Status::Continue)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ mod tests {
|
|||
|
||||
let status = client.process("id", &actions, &config).unwrap();
|
||||
|
||||
assert_eq!(status, Status::Accept);
|
||||
assert_eq!(status, Status::Continue);
|
||||
assert_eq!(
|
||||
actions.called.borrow().as_slice(),
|
||||
[
|
||||
|
@ -588,7 +588,7 @@ mod tests {
|
|||
|
||||
let status = client.process("id", &actions, &config).unwrap();
|
||||
|
||||
assert_eq!(status, Status::Accept);
|
||||
assert_eq!(status, Status::Continue);
|
||||
|
||||
let called = actions.called.borrow();
|
||||
assert!(called.contains(&Action::InsertHeader(0, "X-Spam-Level".into(), " *****".into())));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- An authenticated sender is accepted, the message is not processed.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- ‘Happy path’ processing of an ordinary ham (not spam) message.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||||
|
@ -65,7 +65,7 @@ assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
|||
|
||||
local err = mt.eom(conn)
|
||||
assert(err == nil, err)
|
||||
assert(mt.getreply(conn) == SMFIR_ACCEPT)
|
||||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||||
|
||||
assert(mt.eom_check(conn, MT_HDRINSERT, "X-Spam-Custom", " Custom-Value"))
|
||||
assert(mt.eom_check(conn, MT_HDRDELETE, "X-Spam-Checker-Version"))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
#[test]
|
||||
|
@ -23,6 +23,7 @@ fn ham_message() {
|
|||
|
||||
Ok(ham)
|
||||
});
|
||||
|
||||
let miltertest = spawn_miltertest_runner(file!());
|
||||
|
||||
run("inet:3333@localhost", config).expect("milter execution failed");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- Live test against a real SpamAssassin server.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||||
|
@ -65,7 +65,7 @@ assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
|||
|
||||
local err = mt.eom(conn)
|
||||
assert(err == nil, err)
|
||||
assert(mt.getreply(conn) == SMFIR_ACCEPT)
|
||||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||||
|
||||
local err = mt.disconnect(conn)
|
||||
assert(err == nil, err)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
/// Runs a ‘live’ test against a real SpamAssassin server instance. This test is
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- 1) A connection from the loopback IP address is accepted.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, nil, "127.0.0.1")
|
||||
|
@ -13,7 +13,7 @@ assert(err == nil, err)
|
|||
-- 2) A connection from an ‘unknown’ IP address (for example, from a UNIX
|
||||
-- domain socket) is also accepted.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, nil, "unspec")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- A spam message is rejected with an SMTP error reply.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||||
|
@ -56,7 +56,7 @@ local err = mt.bodystring(conn, "Test message body")
|
|||
assert(err == nil, err)
|
||||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||||
|
||||
-- A `miltertest` (or milter protocol?) pitfall: Even though we return the
|
||||
-- A `miltertest` (or milter protocol) pitfall: Even though we return the
|
||||
-- `SMFIR_REJECT` status in the application code, because we use a custom error
|
||||
-- reply, we must check for `SMFIR_REPLYCODE` instead.
|
||||
local err = mt.eom(conn)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
#[test]
|
||||
|
@ -16,6 +16,7 @@ fn reject_spam() {
|
|||
let server = spawn_mock_spamd_server(SPAMD_PORT, |spam| {
|
||||
Err(spam.replacen("\r\n\r\n", "\r\nX-Spam-Flag: YES\r\n\r\n", 1))
|
||||
});
|
||||
|
||||
let miltertest = spawn_miltertest_runner(file!());
|
||||
|
||||
run("inet:3333@localhost", config).expect("milter execution failed");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
-- reached, the rest is skipped (oversized messages are not processed by
|
||||
-- SpamAssassin, so it is futile to send the whole message in this case).
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||||
|
@ -72,7 +72,7 @@ assert(mt.getreply(conn) == SMFIR_SKIP)
|
|||
|
||||
local err = mt.eom(conn)
|
||||
assert(err == nil, err)
|
||||
assert(mt.getreply(conn) == SMFIR_ACCEPT)
|
||||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||||
|
||||
local err = mt.disconnect(conn)
|
||||
assert(err == nil, err)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- ‘Happy path’ processing of a spam message.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||||
|
@ -65,7 +65,7 @@ assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
|||
|
||||
local err = mt.eom(conn)
|
||||
assert(err == nil, err)
|
||||
assert(mt.getreply(conn) == SMFIR_ACCEPT)
|
||||
assert(mt.getreply(conn) == SMFIR_CONTINUE)
|
||||
|
||||
assert(mt.eom_check(conn, MT_HDRDELETE, "X-Spam-Checker-Version"))
|
||||
assert(mt.eom_check(conn, MT_HDRADD, "X-Spam-Checker-Version", " MyChecker 1.0.0"))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
#[test]
|
||||
|
@ -37,6 +37,7 @@ fn spam_message() {
|
|||
|
||||
Err(spam)
|
||||
});
|
||||
|
||||
let miltertest = spawn_miltertest_runner(file!());
|
||||
|
||||
run("inet:3333@localhost", config).expect("milter execution failed");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- When no `spamd` server is available, `spamc` fails to connect.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- A connection from a trusted network is accepted.
|
||||
|
||||
conn = mt.connect("inet:3333@localhost")
|
||||
local conn = mt.connect("inet:3333@localhost")
|
||||
assert(conn, "could not open connection")
|
||||
|
||||
local err = mt.conninfo(conn, "client.gluet.ch", "123.123.123.123")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod common;
|
||||
|
||||
pub use common::*; // `pub` only to silence unused code warnings
|
||||
pub use common::*;
|
||||
use spamassassin_milter::*;
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue