IOSAD-92 testEncryptedMailFromMuttWithReencryption IOSAD-92
authorDirk Zimmermann <dirk@pep-project.org>
Tue, 24 Apr 2018 13:29:15 +0200
branchIOSAD-92
changeset 5905cf796a94b87
parent 589 addf605406d0
child 591 6f43608139c8
IOSAD-92 testEncryptedMailFromMuttWithReencryption
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Tue Apr 24 13:29:14 2018 +0200
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Tue Apr 24 13:29:15 2018 +0200
     1.3 @@ -854,7 +854,7 @@
     1.4      XCTAssertEqual(rating, PEP_rating_trusted_and_anonymized);
     1.5  }
     1.6  
     1.7 -- (void)testEncryptedMailFromMutt
     1.8 +- (void)testEncryptedMailFromMuttWithReencryption
     1.9  {
    1.10      PEPSession *session = [PEPSession new];
    1.11  
    1.12 @@ -889,18 +889,30 @@
    1.13      NSArray* keys;
    1.14      PEPMessage *msg = [PEPMessage new];
    1.15      [msg setValuesForKeysWithDictionary:msgDict];
    1.16 +    PEPMessage *msgOriginal = [PEPMessage new];
    1.17 +    [msgOriginal setValuesForKeysWithDictionary:msgDict];
    1.18  
    1.19 -    // Technically, the mail is encrypted, but the signatures don't match
    1.20 +    XCTAssertEqualObjects(msg, msgOriginal);
    1.21 +
    1.22 +    PEP_rating rating = PEP_rating_b0rken;
    1.23 +    PEP_decrypt_flags flags = PEP_decrypt_flag_untrusted_server;
    1.24 +
    1.25      PEPMessage *pepDecryptedMail = [session
    1.26                                      decryptMessage:msg
    1.27 -                                    flags:nil
    1.28 -                                    rating:nil
    1.29 +                                    flags:&flags
    1.30 +                                    rating:&rating
    1.31                                      extraKeys:&keys
    1.32                                      status:nil
    1.33                                      error:&error];
    1.34      XCTAssertNotNil(pepDecryptedMail);
    1.35      XCTAssertNil(error);
    1.36  
    1.37 +    // Technically, the mail is encrypted, but the signatures don't match
    1.38 +    XCTAssertEqual(rating, PEP_rating_unreliable);
    1.39 +
    1.40 +    // Since we're requesting re-encryption, src should have been changed
    1.41 +    XCTAssertNotEqualObjects(msg, msgOriginal);
    1.42 +
    1.43      XCTAssertNotNil(pepDecryptedMail.longMessage);
    1.44  }
    1.45