The Content-Type header is eventually set by Message.add_header(),
which gets extra parameters from **_params and iterates over them with
_params.items(). _params is a dict, so .items() is not sorted.
Rather than using ELLIPSIS, I thought it was clearer if we explicitly
force our expected ordering in doctest output.
>>> message = encodedMIMEText('Hi\nBye')
>>> signed = sign(message, signers=['pgp-mime@invalid.com'])
>>> signed.set_boundary('boundsep')
>>> message = encodedMIMEText('Hi\nBye')
>>> signed = sign(message, signers=['pgp-mime@invalid.com'])
>>> signed.set_boundary('boundsep')
- >>> print(signed.as_string()) # doctest: +ELLIPSIS, +REPORT_UDIFF
+ >>> print(signed.as_string().replace(
+ ... 'micalg="pgp-sha1"; protocol="application/pgp-signature"',
+ ... 'protocol="application/pgp-signature"; micalg="pgp-sha1"'))
+ ... # doctest: +ELLIPSIS, +REPORT_UDIFF
Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
>>> message.attach(encodedMIMEText('Part B'))
>>> signed = sign(message, signers=['pgp-mime@invalid.com'])
>>> signed.set_boundary('boundsep')
>>> message.attach(encodedMIMEText('Part B'))
>>> signed = sign(message, signers=['pgp-mime@invalid.com'])
>>> signed.set_boundary('boundsep')
- >>> print(signed.as_string()) # doctest: +ELLIPSIS, +REPORT_UDIFF
+ >>> print(signed.as_string().replace(
+ ... 'micalg="pgp-sha1"; protocol="application/pgp-signature"',
+ ... 'protocol="application/pgp-signature"; micalg="pgp-sha1"'))
+ ... # doctest: +ELLIPSIS, +REPORT_UDIFF
Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
>>> message['To'] = 'pgp-mime-test <pgp-mime@invalid.com>'
>>> encrypted = encrypt(message, always_trust=True)
>>> encrypted.set_boundary('boundsep')
>>> message['To'] = 'pgp-mime-test <pgp-mime@invalid.com>'
>>> encrypted = encrypt(message, always_trust=True)
>>> encrypted.set_boundary('boundsep')
- >>> print(encrypted.as_string()) # doctest: +ELLIPSIS, +REPORT_UDIFF
+ >>> print(encrypted.as_string().replace(
+ ... 'micalg="pgp-sha1"; protocol="application/pgp-encrypted"',
+ ... 'protocol="application/pgp-encrypted"; micalg="pgp-sha1"'))
+ ... # doctest: +ELLIPSIS, +REPORT_UDIFF
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
>>> encrypted = encrypt(
... message, recipients=['pgp-mime@invalid.com'], always_trust=True)
>>> encrypted.set_boundary('boundsep')
>>> encrypted = encrypt(
... message, recipients=['pgp-mime@invalid.com'], always_trust=True)
>>> encrypted.set_boundary('boundsep')
- >>> print(encrypted.as_string()) # doctest: +ELLIPSIS, +REPORT_UDIFF
+ >>> print(encrypted.as_string().replace(
+ ... 'micalg="pgp-sha1"; protocol="application/pgp-encrypted"',
+ ... 'protocol="application/pgp-encrypted"; micalg="pgp-sha1"'))
+ ... # doctest: +ELLIPSIS, +REPORT_UDIFF
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
>>> encrypted = sign_and_encrypt(
... message, signers=['pgp-mime@invalid.com'], always_trust=True)
>>> encrypted.set_boundary('boundsep')
>>> encrypted = sign_and_encrypt(
... message, signers=['pgp-mime@invalid.com'], always_trust=True)
>>> encrypted.set_boundary('boundsep')
- >>> print(encrypted.as_string()) # doctest: +ELLIPSIS, +REPORT_UDIFF
+ >>> print(encrypted.as_string().replace(
+ ... 'micalg="pgp-sha1"; protocol="application/pgp-encrypted"',
+ ... 'protocol="application/pgp-encrypted"; micalg="pgp-sha1"'))
+ ... # doctest: +ELLIPSIS, +REPORT_UDIFF
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
... message, signers=['pgp-mime@invalid.com'],
... recipients=['pgp-mime@invalid.com'], always_trust=True)
>>> encrypted.set_boundary('boundsep')
... message, signers=['pgp-mime@invalid.com'],
... recipients=['pgp-mime@invalid.com'], always_trust=True)
>>> encrypted.set_boundary('boundsep')
- >>> print(encrypted.as_string()) # doctest: +ELLIPSIS, +REPORT_UDIFF
+ >>> print(encrypted.as_string().replace(
+ ... 'micalg="pgp-sha1"; protocol="application/pgp-encrypted"',
+ ... 'protocol="application/pgp-encrypted"; micalg="pgp-sha1"'))
+ ... # doctest: +ELLIPSIS, +REPORT_UDIFF
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline
Content-Type: multipart/encrypted; protocol="application/pgp-encrypted"; micalg="pgp-sha1"; boundary="boundsep"
MIME-Version: 1.0
Content-Disposition: inline