Skip to content

Commit 6e91af7

Browse files
committed
tests(imap): init fastmail and stalwart tests
1 parent bfc25cb commit 6e91af7

21 files changed

Lines changed: 512 additions & 66 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Fastmail IMAP tests
2+
3+
on:
4+
push:
5+
branches:
6+
- v2
7+
8+
jobs:
9+
fastmail-imap-tests:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: dtolnay/rust-toolchain@stable
14+
- run: cargo test --no-default-features --features imap,rustls-ring --test fastmail-imap -- --ignored
15+
env:
16+
FASTMAIL_EMAIL: ${{ secrets.FASTMAIL_EMAIL }}
17+
FASTMAIL_APP_PASSWORD: ${{ secrets.FASTMAIL_APP_PASSWORD }}

.github/workflows/fastmail-jmap-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ jobs:
1414
- run: cargo test --no-default-features --features jmap,rustls-ring --test fastmail-jmap -- --ignored
1515
env:
1616
FASTMAIL_EMAIL: ${{ secrets.FASTMAIL_EMAIL }}
17-
FASTMAIL_BEARER_TOKEN: ${{ secrets.FASTMAIL_BEARER_TOKEN }}
17+
FASTMAIL_API_TOKEN: ${{ secrets.FASTMAIL_API_TOKEN }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Stalwart IMAP tests
2+
3+
on:
4+
push:
5+
branches:
6+
- v2
7+
8+
jobs:
9+
stalwart-imap-tests:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: dtolnay/rust-toolchain@stable
14+
- run: ./tests/stalwart.sh
15+
- run: cargo test --no-default-features --features imap,rustls-ring --test stalwart-imap -- --ignored
16+
- run: docker stop himalaya-tests

.github/workflows/stalwart-jmap-tests.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v4
1313
- uses: dtolnay/rust-toolchain@stable
14-
- run: docker run -d --rm --name stalwart-test-for-himalaya -p 8080:8080 stalwartlabs/stalwart:latest-alpine
15-
- run: sleep 1
16-
- run: |
17-
echo "ADMIN_PASSWORD=$(docker logs stalwart-test-for-himalaya 2>&1 | grep -oP "(?<=with password ')[^']+")" >> $GITHUB_ENV
18-
- run: |
19-
curl -X POST \
20-
-u "admin:${ADMIN_PASSWORD}" \
21-
-H 'Content-Type: application/json' \
22-
-d '{"type":"domain","name":"pimalaya.org"}' \
23-
http://localhost:8080/api/principal
24-
- run: |
25-
curl -X POST \
26-
-u "admin:${ADMIN_PASSWORD}" \
27-
-H 'Content-Type: application/json' \
28-
-d '{"type":"individual","name":"test","emails":["test@pimalaya.org"],"secrets":["test"],"roles":["user"]}' \
29-
http://localhost:8080/api/principal
14+
- run: ./tests/stalwart.sh
3015
- run: cargo test --no-default-features --features jmap,rustls-ring --test stalwart-jmap -- --ignored
31-
- run: docker stop stalwart-test-for-himalaya
16+
- run: docker stop himalaya-tests

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ rustdoc-args = ["--cfg", "docsrs"]
1818
[features]
1919
default = ["imap", "maildir", "smtp", "rustls-ring"]
2020

21-
imap = ["dep:io-imap", "dep:rfc2047-decoder", "pimalaya-toolbox/imap"]
21+
imap = ["dep:io-imap", "dep:mail-parser", "dep:rfc2047-decoder", "pimalaya-toolbox/imap"]
2222
jmap = ["dep:io-jmap", "dep:serde_json", "pimalaya-toolbox/jmap"]
23-
smtp = ["dep:io-smtp", "pimalaya-toolbox/smtp"]
24-
maildir = ["dep:convert_case", "dep:io-fs", "dep:io-maildir", "dep:mime_guess"]
23+
smtp = ["dep:io-smtp", "dep:mail-parser", "pimalaya-toolbox/smtp"]
24+
maildir = ["dep:convert_case", "dep:io-fs", "dep:io-maildir", "dep:mail-parser", "dep:mime_guess"]
2525

2626
native-tls = ["pimalaya-toolbox/native-tls"]
2727
rustls-aws = ["pimalaya-toolbox/rustls-aws"]
@@ -48,7 +48,7 @@ io-process = { version = "0.0.2", default-features = false }
4848
io-smtp = { version = "0.0.1", default-features = false, features = ["ext_auth", "starttls"], optional = true }
4949
io-stream = { version = "0.0.2", default-features = false, features = ["std"] }
5050
log = "0.4"
51-
mail-parser = "0.11"
51+
mail-parser = { version = "0.11", features = ["serde"], optional = true }
5252
mime_guess = { version = "2", optional = true }
5353
open = "5"
5454
pimalaya-toolbox = { version = "0.0.4", default-features = false, features = ["config", "terminal", "secret"] }

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/imap/envelope/search.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,30 +242,30 @@ fn parse_term(term: &str) -> Result<SearchKey<'static>> {
242242
}
243243
}
244244

245-
bail!("Unknown search term: {term}")
245+
bail!("Unknown search term `{term}`")
246246
}
247247

248248
fn parse_date(s: &str) -> Result<NaiveDate> {
249249
// Parse YYYY-MM-DD format
250250
let parts: Vec<&str> = s.split('-').collect();
251251
if parts.len() != 3 {
252-
bail!("Invalid date format '{s}'. Expected YYYY-MM-DD");
252+
bail!("Invalid date format `{s}`, expected YYYY-MM-DD");
253253
}
254254

255255
let year: i32 = parts[0]
256256
.parse()
257-
.map_err(|_| anyhow!("Invalid year in date '{s}'"))?;
257+
.map_err(|_| anyhow!("Invalid year in date `{s}`"))?;
258258
let month: u32 = parts[1]
259259
.parse()
260-
.map_err(|_| anyhow!("Invalid month in date '{s}'"))?;
260+
.map_err(|_| anyhow!("Invalid month in date `{s}`"))?;
261261
let day: u32 = parts[2]
262262
.parse()
263-
.map_err(|_| anyhow!("Invalid day in date '{s}'"))?;
263+
.map_err(|_| anyhow!("Invalid day in date `{s}`"))?;
264264

265265
// Create chrono::NaiveDate first
266266
let chrono_date = chrono::NaiveDate::from_ymd_opt(year, month, day)
267-
.ok_or_else(|| anyhow!("Invalid date '{s}'"))?;
267+
.ok_or_else(|| anyhow!("Invalid date `{s}`"))?;
268268

269269
// Convert to imap-types NaiveDate
270-
NaiveDate::try_from(chrono_date).map_err(|e| anyhow!("Invalid date '{s}': {e}"))
270+
NaiveDate::try_from(chrono_date).map_err(|e| anyhow!("Invalid date `{s}`: {e}"))
271271
}

src/imap/envelope/sort.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn parse_sort_key(s: &str) -> Result<SortKey> {
110110
"subject" => Ok(SortKey::Subject),
111111
"size" => Ok(SortKey::Size),
112112
_ => bail!(
113-
"Unknown sort key: {s}. Valid options: date, arrival, from, to, cc, subject, size"
113+
"Unknown sort key `{s}`, valid options: date, arrival, from, to, cc, subject, size"
114114
),
115115
}
116116
}

src/imap/envelope/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn parse_algorithm(s: &str) -> Result<ThreadingAlgorithm<'static>> {
105105
match s.to_lowercase().as_str() {
106106
"references" => Ok(ThreadingAlgorithm::References),
107107
"orderedsubject" => Ok(ThreadingAlgorithm::OrderedSubject),
108-
_ => bail!("Unknown threading algorithm: {s}. Valid options: references, orderedsubject"),
108+
_ => bail!("Unknown threading algorithm `{s}`, valid options: references, orderedsubject"),
109109
}
110110
}
111111

0 commit comments

Comments
 (0)