From e1dcc09d7503fb3c0ada70a4976c9a447016eb51 Mon Sep 17 00:00:00 2001 From: Lukas Burkhalter Date: Mon, 11 Nov 2024 16:17:34 +0100 Subject: [PATCH] chore: Move expected error to the old position --- openpgp/read_test.go | 4 ++-- openpgp/v2/read_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openpgp/read_test.go b/openpgp/read_test.go index bf604004..23fd4aec 100644 --- a/openpgp/read_test.go +++ b/openpgp/read_test.go @@ -800,7 +800,6 @@ func TestSymmetricAeadEaxOpenPGPJsMessage(t *testing.T) { func TestCorruptedMessageInvalidSigHeader(t *testing.T) { // Decrypt message with corrupted MDC and invalid one-pass-signature header // Expect parsing errors over unverified decrypted data to be opaque - var expectedErr string = "openpgp: decryption with session key failed: parsing error" passphrase := []byte("password") file, err := os.Open("test_data/sym-corrupted-message-invalid-sig-header.asc") if err != nil { @@ -820,6 +819,7 @@ func TestCorruptedMessageInvalidSigHeader(t *testing.T) { promptFunc := func(keys []Key, symmetric bool) ([]byte, error) { return passphrase, nil } + const expectedErr string = "openpgp: decryption with session key failed: parsing error" _, observedErr := ReadMessage(raw.Body, nil, promptFunc, nil) if observedErr.Error() != expectedErr { t.Errorf("Expected error '%s', but got error '%s'", expectedErr, observedErr) @@ -829,11 +829,11 @@ func TestCorruptedMessageInvalidSigHeader(t *testing.T) { func TestCorruptedMessageWrongLength(t *testing.T) { // Decrypt message with wrong length in Literal packet header (length too long) // Expect parsing errors over unverified decrypted data to be opaque - var expectedErr string = "openpgp: decryption with session key failed: parsing error" passphrase := []byte("password") promptFunc := func(keys []Key, symmetric bool) ([]byte, error) { return passphrase, nil } + const expectedErr string = "openpgp: decryption with session key failed: parsing error" file, err := os.Open("test_data/sym-corrupted-message-long-length.asc") if err != nil { diff --git a/openpgp/v2/read_test.go b/openpgp/v2/read_test.go index b5f31860..24eec2f4 100644 --- a/openpgp/v2/read_test.go +++ b/openpgp/v2/read_test.go @@ -832,7 +832,6 @@ func TestSymmetricAeadEaxOpenPGPJsMessage(t *testing.T) { func TestCorruptedMessageInvalidSigHeader(t *testing.T) { // Decrypt message with corrupted MDC and invalid one-pass-signature header // Expect parsing errors over unverified decrypted data to be opaque - var expectedErr string = "openpgp: decryption with session key failed: parsing error" passphrase := []byte("password") file, err := os.Open("../test_data/sym-corrupted-message-invalid-sig-header.asc") if err != nil { @@ -852,6 +851,7 @@ func TestCorruptedMessageInvalidSigHeader(t *testing.T) { promptFunc := func(keys []Key, symmetric bool) ([]byte, error) { return passphrase, nil } + const expectedErr string = "openpgp: decryption with session key failed: parsing error" _, observedErr := ReadMessage(raw.Body, nil, promptFunc, nil) if observedErr.Error() != expectedErr { t.Errorf("Expected error '%s', but got error '%s'", expectedErr, observedErr) @@ -861,11 +861,11 @@ func TestCorruptedMessageInvalidSigHeader(t *testing.T) { func TestCorruptedMessageWrongLength(t *testing.T) { // Decrypt message with wrong length in Literal packet header (length too long) // Expect parsing errors over unverified decrypted data to be opaque - var expectedErr string = "openpgp: decryption with session key failed: parsing error" passphrase := []byte("password") promptFunc := func(keys []Key, symmetric bool) ([]byte, error) { return passphrase, nil } + const expectedErr string = "openpgp: decryption with session key failed: parsing error" file, err := os.Open("../test_data/sym-corrupted-message-long-length.asc") if err != nil {