-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #714 from ndw/send-mail2
New and updated p:send-mail tests
- Loading branch information
Showing
3 changed files
with
194 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0" | ||
expected="pass" features="send-mail"> | ||
<t:info> | ||
<t:title>p:send-mail-002</t:title> | ||
<t:revision-history> | ||
<t:revision> | ||
<t:date>2024-05-30</t:date> | ||
<t:author> | ||
<t:name>Norm Tovey-Walsh</t:name> | ||
</t:author> | ||
<t:description xmlns="http://www.w3.org/1999/xhtml"> | ||
<p>Test for the p:send-mail step.</p> | ||
</t:description> | ||
</t:revision> | ||
</t:revision-history> | ||
</t:info> | ||
<t:description xmlns="http://www.w3.org/1999/xhtml"> | ||
<p>Test p:send-mail sending HTML mail. </p> | ||
</t:description> | ||
<t:pipeline> | ||
<p:declare-step version="3.0" xmlns:p="http://www.w3.org/ns/xproc"> | ||
<p:output port="result" /> | ||
|
||
<!-- Clear the Sendria log --> | ||
<p:http-request href="http://localhost:1080/api/messages/" method="delete"> | ||
<p:with-input> | ||
<p:empty/> | ||
</p:with-input> | ||
</p:http-request> | ||
|
||
<!-- Make sure that succeeded --> | ||
<p:if test=".?code != 'OK'"> | ||
<p:error code="Q{http://example.com/}irrelevant"/> | ||
</p:if> | ||
|
||
<p:send-mail parameters="map{'host':'localhost', 'port':1025}" | ||
auth="map{'username':'username','password':'password'}"> | ||
<p:with-input> | ||
<p:inline> | ||
<emx:Message | ||
xmlns:emx='URN:ietf:params:email-xml:' | ||
xmlns:rfc822='URN:ietf:params:rfc822:'> | ||
<rfc822:from> | ||
<emx:Address> | ||
<emx:adrs>mailto:[email protected]</emx:adrs> | ||
<emx:name>Example User</emx:name> | ||
</emx:Address> | ||
</rfc822:from> | ||
<rfc822:to> | ||
<emx:Address> | ||
<emx:adrs>mailto:[email protected]</emx:adrs> | ||
<emx:name>Another User</emx:name> | ||
</emx:Address> | ||
</rfc822:to> | ||
<rfc822:subject>HTML Email</rfc822:subject> | ||
<emx:content type='text/plain'> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title>Hello, World</title> | ||
</head> | ||
<body> | ||
<h1>Hello, World!</h1> | ||
<p>This is an email message encoded in HTML. This is <em>evil</em>. Don’t do this.</p> | ||
</body> | ||
</html> | ||
</emx:content> | ||
</emx:Message> | ||
</p:inline> | ||
</p:with-input> | ||
</p:send-mail> | ||
|
||
<!-- Check the Sendria log --> | ||
<p:http-request href="http://localhost:1080/api/messages/" method="get"/> | ||
<p:http-request href="http://localhost:1080/api/messages/" method="get"/> | ||
<p:http-request href="http://localhost:1080/api/messages/" method="get"/> | ||
<p:cast-content-type content-type="application/xml"/> | ||
|
||
</p:declare-step> | ||
</t:pipeline> | ||
<t:schematron> | ||
<s:schema queryBinding="xslt2" | ||
xmlns:s="http://purl.oclc.org/dsdl/schematron"> | ||
<s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/> | ||
<s:pattern name="Root must be map"> | ||
<s:rule context="/fn:map"> | ||
<s:assert test="fn:string[@key='code'] = 'OK'">Code must be 'OK'</s:assert> | ||
<s:assert test="fn:array[@key='data']/fn:map/fn:string[@key='subject'] | ||
= 'HTML Email'">The subject must be correct</s:assert> | ||
<s:assert test="fn:array[@key='data']/fn:map/fn:string[@key='type'] | ||
= 'text/html'">The content type must be HTML</s:assert> | ||
</s:rule> | ||
</s:pattern> | ||
</s:schema> | ||
</t:schematron> | ||
</t:test> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0" | ||
expected="pass" features="send-mail"> | ||
<t:info> | ||
<t:title>p:send-mail-003</t:title> | ||
<t:revision-history> | ||
<t:revision> | ||
<t:date>2024-05-30</t:date> | ||
<t:author> | ||
<t:name>Norm Tovey-Walsh</t:name> | ||
</t:author> | ||
<t:description xmlns="http://www.w3.org/1999/xhtml"> | ||
<p>Test for the p:send-mail step.</p> | ||
</t:description> | ||
</t:revision> | ||
</t:revision-history> | ||
</t:info> | ||
<t:description xmlns="http://www.w3.org/1999/xhtml"> | ||
<p>Test p:send-mail sending multipart mail. </p> | ||
</t:description> | ||
<t:pipeline> | ||
<p:declare-step version="3.0" xmlns:p="http://www.w3.org/ns/xproc"> | ||
<p:output port="result" /> | ||
|
||
<!-- Clear the Sendria log --> | ||
<p:http-request href="http://localhost:1080/api/messages/" method="delete"> | ||
<p:with-input> | ||
<p:empty/> | ||
</p:with-input> | ||
</p:http-request> | ||
|
||
<!-- Make sure that succeeded --> | ||
<p:if test=".?code != 'OK'"> | ||
<p:error code="Q{http://example.com/}irrelevant"/> | ||
</p:if> | ||
|
||
<p:send-mail parameters="map{'host':'localhost', 'port':1025}" | ||
auth="map{'username':'username','password':'password'}"> | ||
<p:with-input> | ||
<p:inline> | ||
<emx:Message | ||
xmlns:emx='URN:ietf:params:email-xml:' | ||
xmlns:rfc822='URN:ietf:params:rfc822:'> | ||
<rfc822:from> | ||
<emx:Address> | ||
<emx:adrs>mailto:[email protected]</emx:adrs> | ||
<emx:name>Example User</emx:name> | ||
</emx:Address> | ||
</rfc822:from> | ||
<rfc822:to> | ||
<emx:Address> | ||
<emx:adrs>mailto:[email protected]</emx:adrs> | ||
<emx:name>Another User</emx:name> | ||
</emx:Address> | ||
</rfc822:to> | ||
<rfc822:subject>Multi-part Email</rfc822:subject> | ||
<emx:content type='text/plain'> | ||
This is my text message. | ||
</emx:content> | ||
</emx:Message> | ||
</p:inline> | ||
<p:inline> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title>Hello, World</title> | ||
</head> | ||
<body> | ||
<h1>Hello, World!</h1> | ||
<p>This is my attachment.</p> | ||
</body> | ||
</html> | ||
</p:inline> | ||
</p:with-input> | ||
</p:send-mail> | ||
|
||
<!-- Check the Sendria log --> | ||
<p:http-request href="http://localhost:1080/api/messages/" method="get"/> | ||
<p:http-request href="http://localhost:1080/api/messages/" method="get"/> | ||
<p:http-request href="http://localhost:1080/api/messages/" method="get"/> | ||
<p:cast-content-type content-type="application/xml"/> | ||
|
||
</p:declare-step> | ||
</t:pipeline> | ||
<t:schematron> | ||
<s:schema queryBinding="xslt2" | ||
xmlns:s="http://purl.oclc.org/dsdl/schematron"> | ||
<s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/> | ||
<s:pattern name="Root must be map"> | ||
<s:rule context="/fn:map"> | ||
<s:assert test="fn:string[@key='code'] = 'OK'">Code must be 'OK'</s:assert> | ||
<s:assert test="fn:array[@key='data']/fn:map/fn:string[@key='subject'] | ||
= 'Multi-part Email'">The subject must be correct</s:assert> | ||
<s:assert test="fn:array[@key='data']/fn:map/fn:string[@key='type'] | ||
= 'multipart/mixed'">The content type must be multipart/mixed</s:assert> | ||
</s:rule> | ||
</s:pattern> | ||
</s:schema> | ||
</t:schematron> | ||
</t:test> |