diff --git a/encoding.go b/encoding.go index 47213da..0640d31 100644 --- a/encoding.go +++ b/encoding.go @@ -19,6 +19,9 @@ type MIMEVersion string // MIMEType represents the MIME type for the mail type MIMEType string +// Disposition represents a content disposition for the Msg +type Disposition string + // List of supported encodings const ( // EncodingB64 represents the Base64 encoding as specified in RFC 2045. @@ -149,6 +152,7 @@ const ( TypePGPEncrypted ContentType = "application/pgp-encrypted" TypeTextHTML ContentType = "text/html" TypeTextPlain ContentType = "text/plain" + typeSMimeSigned ContentType = `application/pkcs7-signature; name="smime.p7s"` ) // List of MIMETypes @@ -156,6 +160,12 @@ const ( MIMEAlternative MIMEType = "alternative" MIMEMixed MIMEType = "mixed" MIMERelated MIMEType = "related" + MIMESMime MIMEType = `signed; protocol="application/pkcs7-signature"; micalg=sha256` +) + +// List of common content disposition +const ( + DispositionSMime Disposition = `attachment; filename="smime.p7s"` ) // String is a standard method to convert an Charset into a printable format @@ -172,3 +182,8 @@ func (c ContentType) String() string { func (e Encoding) String() string { return string(e) } + +// String is a standard method to convert an Disposition into a printable format +func (d Disposition) String() string { + return string(d) +} diff --git a/encoding_test.go b/encoding_test.go index 14711b7..3084063 100644 --- a/encoding_test.go +++ b/encoding_test.go @@ -61,6 +61,11 @@ func TestContentType_String(t *testing.T) { "ContentType: application/pgp-encrypted", TypePGPEncrypted, "application/pgp-encrypted", }, + + { + "ContentType: pkcs7-signature", typeSMimeSigned, + `application/pkcs7-signature; name="smime.p7s"; smime-type=signed-data`, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -121,3 +126,22 @@ func TestCharset_String(t *testing.T) { }) } } + +// TestDisposition_String tests the string method of the Disposition object +func TestDisposition_String(t *testing.T) { + tests := []struct { + name string + d Disposition + want string + }{ + {"Disposition: S/Mime", DispositionSMime, `attachment; filename="smime.p7s"`}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if tt.d.String() != tt.want { + t.Errorf("wrong string for Disposition returned. Expected: %s, got: %s", + tt.want, tt.d.String()) + } + }) + } +}