test: fix test content types

This commit is contained in:
James Houlahan
2020-08-05 10:57:44 +02:00
parent 64fbd0655f
commit 33d705a39d
2 changed files with 15 additions and 11 deletions

View File

@ -95,11 +95,13 @@ func (b *sendPreferencesBuilder) shouldEncrypt() bool {
return false return false
} }
func (b *sendPreferencesBuilder) withSign(v bool) { func (b *sendPreferencesBuilder) withSign() {
v := true
b.sign = &v b.sign = &v
} }
func (b *sendPreferencesBuilder) withSignDefault(v bool) { func (b *sendPreferencesBuilder) withSignDefault() {
v := true
if b.sign == nil { if b.sign == nil {
b.sign = &v b.sign = &v
} }
@ -256,7 +258,7 @@ func (b *sendPreferencesBuilder) setInternalPGPSettings(
// We always encrypt and sign internal mail. // We always encrypt and sign internal mail.
b.withEncrypt(true) b.withEncrypt(true)
b.withSign(true) b.withSign()
// We use a custom scheme for internal messages. // We use a custom scheme for internal messages.
b.withScheme(pmInternal) b.withScheme(pmInternal)
@ -367,7 +369,7 @@ func (b *sendPreferencesBuilder) setExternalPGPSettingsWithWKDKeys(
// We always encrypt and sign external mail if WKD keys are present. // We always encrypt and sign external mail if WKD keys are present.
b.withEncrypt(true) b.withEncrypt(true)
b.withSign(true) b.withSign()
// If the contact has a specific Scheme preference, we set it (otherwise we // If the contact has a specific Scheme preference, we set it (otherwise we
// leave it unset to allow it to be filled in with the default value later). // leave it unset to allow it to be filled in with the default value later).
@ -402,7 +404,7 @@ func (b *sendPreferencesBuilder) setExternalPGPSettingsWithoutWKDKeys(
// Sign must be enabled whenever encrypt is. // Sign must be enabled whenever encrypt is.
if vCardData.Sign || vCardData.Encrypt { if vCardData.Sign || vCardData.Encrypt {
b.withSign(true) b.withSign()
} }
// If the contact has a specific Scheme preference, we set it (otherwise we // If the contact has a specific Scheme preference, we set it (otherwise we
@ -468,10 +470,12 @@ func (b *sendPreferencesBuilder) setEncryptionPreferences(mailSettings pmapi.Mai
// mail setting "Sign External messages". Otherwise we keep the defined value // mail setting "Sign External messages". Otherwise we keep the defined value
// unless it conflicts with the encrypt flag (we do not allow to send // unless it conflicts with the encrypt flag (we do not allow to send
// encrypted but not signed). // encrypted but not signed).
b.withSignDefault(mailSettings.Sign > 0) if mailSettings.Sign > 0 {
b.withSignDefault()
}
if b.shouldEncrypt() { if b.shouldEncrypt() {
b.withSign(true) b.withSign()
} }
// If undefined, default to the user mail setting "Default PGP scheme". // If undefined, default to the user mail setting "Default PGP scheme".

View File

@ -56,7 +56,7 @@ func TestPreferencesBuilder(t *testing.T) {
wantEncrypt: true, wantEncrypt: true,
wantSign: true, wantSign: true,
wantScheme: pmapi.InternalPackage, wantScheme: pmapi.InternalPackage,
wantMIMEType: "multipart/mixed", wantMIMEType: "text/html",
wantPublicKey: testPublicKey, wantPublicKey: testPublicKey,
}, },
@ -71,7 +71,7 @@ func TestPreferencesBuilder(t *testing.T) {
wantEncrypt: true, wantEncrypt: true,
wantSign: true, wantSign: true,
wantScheme: pmapi.InternalPackage, wantScheme: pmapi.InternalPackage,
wantMIMEType: "multipart/mixed", wantMIMEType: "text/plain",
wantPublicKey: testPublicKey, wantPublicKey: testPublicKey,
}, },
@ -86,7 +86,7 @@ func TestPreferencesBuilder(t *testing.T) {
wantEncrypt: true, wantEncrypt: true,
wantSign: true, wantSign: true,
wantScheme: pmapi.InternalPackage, wantScheme: pmapi.InternalPackage,
wantMIMEType: "multipart/mixed", wantMIMEType: "text/html",
wantPublicKey: testPublicKey, wantPublicKey: testPublicKey,
}, },
@ -102,7 +102,7 @@ func TestPreferencesBuilder(t *testing.T) {
wantEncrypt: true, wantEncrypt: true,
wantSign: true, wantSign: true,
wantScheme: pmapi.InternalPackage, wantScheme: pmapi.InternalPackage,
wantMIMEType: "multipart/mixed", wantMIMEType: "text/html",
wantPublicKey: testPublicKey, wantPublicKey: testPublicKey,
}, },