Skip to content

Commit

Permalink
chore: Move expected error to the old position
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Nov 11, 2024
1 parent 4e77fb5 commit e1dcc09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions openpgp/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions openpgp/v2/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit e1dcc09

Please sign in to comment.