Skip to content

Commit

Permalink
Adding apitest for email endpoints (excl. search)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Hinderberger committed Jul 4, 2024
1 parent 307fcff commit c3594de
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 0 deletions.
104 changes: 104 additions & 0 deletions test/email/checkbody.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[
{
"name": "raw message data is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/raw",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {
"md5sum": "0965d04dceb3003d88a9ea38f337e97a"
},
"format": {
"type": "binary"
}
}
},
{
"name": "top-level body is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/body",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {
"md5sum": "c182b42fda0cd2e929272dd328f0c45d"
},
"format": {
"type": "binary"
}
}
},
{
"name": "part 0 body is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/multipart/0/body",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {
"md5sum": "7883ef0e6c2f3da210febb5ca2b42ace"
},
"format": {
"type": "binary"
}
}
},
{
"name": "part 1 body is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/multipart/1/body",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {
"md5sum": "effe7461f030f3a58f85e4b736bd5c10"
},
"format": {
"type": "binary"
}
}
},
{
"name": "part 1/0 body is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/multipart/1/multipart/0/body",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {
"md5sum": "81c8d7e43a1c88daf9031518e8db3136"
},
"format": {
"type": "binary"
}
}
},
{
"name": "part 1/1 body is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/multipart/1/multipart/1/body",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {
"md5sum": "47ebf0f785a0788262472bf73a4801bb"
},
"format": {
"type": "binary"
}
}
}
]
75 changes: 75 additions & 0 deletions test/email/checkmetadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{{ $decodedMetadata := file "expected_metadata.json" | unmarshal }}
[
{
"name": "top-level index is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {{ file "expected_index.json" }}
}
},
{
"name": "top-level metadata is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {{ marshal $decodedMetadata }}
}
},
{
"name": "part 0 metadata is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/multipart/0",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {{ index $decodedMetadata "multiparts" 0 | marshal }}
}
},
{
"name": "part 1 metadata is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/multipart/1",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {{ index $decodedMetadata "multiparts" 1 | marshal }}
}
},
{
"name": "part 1/0 metadata is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/multipart/1/multipart/0",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {{ index $decodedMetadata "multiparts" 1 "multiparts" 0 | marshal }}
}
},
{
"name": "part 1/1 metadata is returned as expected",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/0/multipart/1/multipart/1",
"method": "GET"
},
"response": {
"statuscode": 200,
"body": {{ index $decodedMetadata "multiparts" 1 "multiparts" 1 | marshal }}
}
}
]
23 changes: 23 additions & 0 deletions test/email/expected_index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"count": 1,
"messages": [
{
"from": [
"testsender123@programmfabrik.de"
],
"idx": 0,
"isMultipart": true,
"receivedAt:control": {
"match": "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]+\\+[0-9]{2}:[0-9]{2}"
},
"smtpFrom": "testsender123@programmfabrik.de",
"smtpRcptTo": [
"testreceiver123@programmfabrik.de"
],
"subject": "Example Nested Message",
"to": [
"testreceiver123@programmfabrik.de"
]
}
]
}
102 changes: 102 additions & 0 deletions test/email/expected_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"bodySize": 549,
"contentType": "multipart/alternative",
"contentTypeParams": {
"boundary": "d36c3118be4745f9a1cb4556d11fe92d"
},
"from": [
"testsender123@programmfabrik.de"
],
"headers": {
"Content-Type": [
"multipart/alternative; boundary=\"d36c3118be4745f9a1cb4556d11fe92d\""
],
"Date": [
"Tue, 25 Jun 2024 11:15:57 +0200"
],
"From": [
"testsender123@programmfabrik.de"
],
"Subject": [
"Example Nested Message"
],
"To": [
"testreceiver123@programmfabrik.de"
]
},
"idx": 0,
"isMultipart": true,
"multiparts": [
{
"bodySize": 57,
"contentType": "text/plain",
"contentTypeParams": {
"charset": "utf-8"
},
"headers": {
"Content-Type": [
"text/plain; charset=utf-8"
]
},
"idx": 0,
"isMultipart": false
},
{
"bodySize": 257,
"contentType": "multipart/mixed",
"contentTypeParams": {
"boundary": "710d3e95c17247d4bb35d621f25e094e"
},
"headers": {
"Content-Type": [
"multipart/mixed; boundary=\"710d3e95c17247d4bb35d621f25e094e\""
]
},
"idx": 1,
"isMultipart": true,
"multiparts": [
{
"bodySize": 26,
"contentType": "text/plain",
"contentTypeParams": {
"charset": "ascii"
},
"headers": {
"Content-Type": [
"text/plain; charset=ascii"
]
},
"idx": 0,
"isMultipart": false
},
{
"bodySize": 34,
"contentType": "text/html",
"contentTypeParams": {
"charset": "utf-8"
},
"headers": {
"Content-Type": [
"text/html; charset=utf-8"
]
},
"idx": 1,
"isMultipart": false
}
],
"multipartsCount": 2
}
],
"multipartsCount": 2,
"receivedAt:control": {
"match": "[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]+\\+[0-9]{2}:[0-9]{2}"
},
"smtpFrom": "testsender123@programmfabrik.de",
"smtpRcptTo": [
"testreceiver123@programmfabrik.de"
],
"subject": "Example Nested Message",
"to": [
"testreceiver123@programmfabrik.de"
]
}
14 changes: 14 additions & 0 deletions test/email/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"http_server": {
"addr": ":9999"
},
"smtp_server": {
"addr": ":9925"
},
"name": "testing HTTP endpoints for mock SMTP server",
"tests": [
"@postmessage.json",
"@checkmetadata.json",
"@checkbody.json"
]
}
13 changes: 13 additions & 0 deletions test/email/postmessage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "post message",
"request": {
"server_url": "http://localhost:9999",
"endpoint": "smtp/postmessage",
"method": "POST",
"body_type": "file",
"body_file": "testmessage.eml"
},
"response": {
"statuscode": 200
}
}
23 changes: 23 additions & 0 deletions test/email/testmessage.eml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
From: testsender123@programmfabrik.de
To: testreceiver123@programmfabrik.de
Date: Tue, 25 Jun 2024 11:15:57 +0200
Subject: Example Nested Message
Content-type: multipart/alternative; boundary="d36c3118be4745f9a1cb4556d11fe92d"

--d36c3118be4745f9a1cb4556d11fe92d
Content-Type: text/plain; charset=utf-8
Some plain text for clients that don't support multipart.
--d36c3118be4745f9a1cb4556d11fe92d
Content-Type: multipart/mixed; boundary="710d3e95c17247d4bb35d621f25e094e"
--710d3e95c17247d4bb35d621f25e094e
Content-Type: text/plain; charset=ascii
This is the first subpart.
--710d3e95c17247d4bb35d621f25e094e
Content-Type: text/html; charset=utf-8

This is the <i>second</i> subpart.
--710d3e95c17247d4bb35d621f25e094e--
--d36c3118be4745f9a1cb4556d11fe92d--

0 comments on commit c3594de

Please sign in to comment.