mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-25 15:10:48 +01:00
added content type, mime type and content disposition for S/MIME singing purpose
This commit is contained in:
parent
158c1b0458
commit
6fda661dc7
2 changed files with 39 additions and 0 deletions
15
encoding.go
15
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)
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue