IOS-1300 prove that space in ODT attachment is no problem for decryption
authorDirk Zimmermann <dirk@pep-project.org>
Tue, 04 Sep 2018 08:57:26 +0200
changeset 646b183619870df
parent 643 ea0df7273ea2
child 647 d8830e5d240e
IOS-1300 prove that space in ODT attachment is no problem for decryption
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Wed Aug 08 10:45:05 2018 +0200
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Tue Sep 04 08:57:26 2018 +0200
     1.3 @@ -1261,6 +1261,57 @@
     1.4      [self testPassiveModeEnabled:YES];
     1.5  }
     1.6  
     1.7 +#pragma mark - Decryption
     1.8 +
     1.9 +- (void)testDecryptionOfUnencryptedMessageWithOdtAttachmentContainingSpace
    1.10 +{
    1.11 +    PEPSession *session = [PEPSession new];
    1.12 +
    1.13 +    PEPIdentity *me = [PEPTestUtils ownPepIdentityWithAddress:@"me@peptest.ch"
    1.14 +                                                     userName:@"userName"];
    1.15 +    NSError *error = nil;
    1.16 +    XCTAssertTrue([session mySelf:me error:&error]);
    1.17 +    XCTAssertNil(error);
    1.18 +
    1.19 +    const char *dataString = "blahblah";
    1.20 +    const size_t dataSize = strlen(dataString);
    1.21 +    char *rawData = strndup(dataString, dataSize);
    1.22 +
    1.23 +    PEPAttachment *attachment = [[PEPAttachment alloc]
    1.24 +                                 initWithData:[NSData
    1.25 +                                               dataWithBytesNoCopy:rawData length:dataSize]];
    1.26 +    attachment.filename = @"Someone andTextIncludingTheSpace.odt";
    1.27 +    attachment.mimeType = @"application/vnd.oasis.opendocument.text";
    1.28 +
    1.29 +    NSString *shortMessage = @"Subject";
    1.30 +    NSString *longMessage = @"Oh, this is a long body text!";
    1.31 +    PEPMessage *mail = [PEPTestUtils mailFrom:me
    1.32 +                                      toIdent:me
    1.33 +                                 shortMessage:shortMessage
    1.34 +                                  longMessage:longMessage
    1.35 +                                     outgoing:YES];
    1.36 +
    1.37 +    mail.attachments = @[attachment];
    1.38 +
    1.39 +    error = nil;
    1.40 +    PEPStringList *keys;
    1.41 +    PEP_rating rating = PEP_rating_undefined;
    1.42 +    PEPMessage *decmsg = [session
    1.43 +                          decryptMessage:mail
    1.44 +                          flags:nil
    1.45 +                          rating:&rating
    1.46 +                          extraKeys:&keys
    1.47 +                          status:nil
    1.48 +                          error:&error];
    1.49 +    XCTAssertNotNil(decmsg);
    1.50 +    XCTAssertNil(error);
    1.51 +    XCTAssertEqual(rating, PEP_rating_unencrypted);
    1.52 +
    1.53 +    PEPAttachment *decryptedAttachment = [decmsg.attachments objectAtIndex:0];
    1.54 +    XCTAssertEqualObjects(decryptedAttachment.mimeType, attachment.mimeType);
    1.55 +    XCTAssertEqualObjects(decryptedAttachment.filename, attachment.filename);
    1.56 +}
    1.57 +
    1.58  #pragma mark - Helpers
    1.59  
    1.60  - (void)testPassiveModeEnabled:(BOOL)passiveModeEnabled