@@ -924,6 +924,32 @@ func TestEncryptDecryptKey(t *testing.T) {
924924 }
925925}
926926
927+ func TestEncryptDecryptStreamTrimmedLines (t * testing.T ) {
928+ for _ , material := range testMaterialForProfiles {
929+ t .Run (material .profileName , func (t * testing.T ) {
930+ encHandle , _ := material .pgp .Encryption ().
931+ Recipients (material .keyRingTestPublic ).
932+ SigningKeys (material .keyRingTestPrivate ).
933+ TrimLines ().
934+ New ()
935+ decHandle , _ := material .pgp .Decryption ().
936+ DecryptionKeys (material .keyRingTestPrivate ).
937+ VerificationKeys (material .keyRingTestPublic ).
938+ New ()
939+ testEncryptDecryptStreamWithExpected (
940+ t ,
941+ []byte ("text with \r \t \n trimmed\n \t " ),
942+ []byte ("text with\n trimmed\n " ),
943+ nil ,
944+ encHandle ,
945+ decHandle ,
946+ len (material .keyRingTestPrivate .entities ),
947+ Bytes ,
948+ )
949+ })
950+ }
951+ }
952+
927953func TestEncryptCompressionApplied (t * testing.T ) {
928954 const numReplicas = 10
929955 builder := strings.Builder {}
@@ -1169,6 +1195,28 @@ func testEncryptDecryptStream(
11691195 decHandle PGPDecryption ,
11701196 numberOfSigsToVerify int ,
11711197 encoding int8 ,
1198+ ) {
1199+ testEncryptDecryptStreamWithExpected (
1200+ t ,
1201+ messageBytes ,
1202+ messageBytes ,
1203+ metadata ,
1204+ encHandle ,
1205+ decHandle ,
1206+ numberOfSigsToVerify ,
1207+ encoding ,
1208+ )
1209+ }
1210+
1211+ func testEncryptDecryptStreamWithExpected (
1212+ t * testing.T ,
1213+ messageBytes []byte ,
1214+ expected []byte ,
1215+ metadata * LiteralMetadata ,
1216+ encHandle PGPEncryption ,
1217+ decHandle PGPDecryption ,
1218+ numberOfSigsToVerify int ,
1219+ encoding int8 ,
11721220) {
11731221 messageReader := bytes .NewReader (messageBytes )
11741222 var ciphertextBuf bytes.Buffer
@@ -1200,7 +1248,7 @@ func testEncryptDecryptStream(
12001248 if err != nil {
12011249 t .Fatal ("Expected no error while reading the decrypted data, got:" , err )
12021250 }
1203- if ! bytes .Equal (decryptedBytes , messageBytes ) {
1251+ if ! bytes .Equal (decryptedBytes , expected ) {
12041252 t .Fatalf ("Expected the decrypted data to be %s got %s" , string (decryptedBytes ), string (messageBytes ))
12051253 }
12061254 if numberOfSigsToVerify > 0 {
0 commit comments