IOS-923 verify engine result for encryption to (gray) recipient
authorDirk Zimmermann <dirk@pep-project.org>
Mon, 12 Feb 2018 12:01:06 +0100
changeset 452b5bf2590069a
parent 451 60b4e92999bf
child 453 029688b5e6cc
IOS-923 verify engine result for encryption to (gray) recipient
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Sat Feb 10 14:36:07 2018 +0100
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Mon Feb 12 12:01:06 2018 +0100
     1.3 @@ -767,7 +767,7 @@
     1.4      PEPIdentity *identMe = [[PEPIdentity alloc]
     1.5                              initWithAddress:@"me-myself-and-i@pep-project.org"
     1.6                              userID:@"me-myself-and-i"
     1.7 -                            userName:@"pEp Test Alice"
     1.8 +                            userName:@"pEp Me"
     1.9                              isOwn:YES];
    1.10      [session mySelf:identMe];
    1.11      XCTAssertNotNil(identMe.fingerPrint);
    1.12 @@ -975,7 +975,7 @@
    1.13      PEPIdentity *identMe = [[PEPIdentity alloc]
    1.14                                 initWithAddress:@"me-myself-and-i@pep-project.org"
    1.15                                 userID:@"me-myself-and-i"
    1.16 -                               userName:@"pEp Test Alice"
    1.17 +                               userName:@"pEp Me"
    1.18                                 isOwn:YES];
    1.19      [session mySelf:identMe];
    1.20      XCTAssertNotNil(identMe.fingerPrint);
    1.21 @@ -1023,4 +1023,47 @@
    1.22      }
    1.23  }
    1.24  
    1.25 +- (void)testEncryptMessagesWithoutKeys
    1.26 +{
    1.27 +    PEPSession *session = [PEPSession new];
    1.28 +
    1.29 +    PEPIdentity *identMe = [[PEPIdentity alloc]
    1.30 +                            initWithAddress:@"me-myself-and-i@pep-project.org"
    1.31 +                            userID:@"me-myself-and-i"
    1.32 +                            userName:@"pEp Me"
    1.33 +                            isOwn:YES];
    1.34 +    [session mySelf:identMe];
    1.35 +    XCTAssertNotNil(identMe.fingerPrint);
    1.36 +
    1.37 +    PEPIdentity *identAlice = [[PEPIdentity alloc]
    1.38 +                               initWithAddress:@"alice@pep-project.org"
    1.39 +                               userID:@"alice"
    1.40 +                               userName:@"pEp Test Alice"
    1.41 +                               isOwn:NO];
    1.42 +
    1.43 +    PEPMessage *msg = [PEPMessage new];
    1.44 +    msg.from = identMe;
    1.45 +    msg.to = @[identAlice];
    1.46 +    msg.shortMessage = @"Mail to Alice";
    1.47 +    msg.longMessage = @"Alice?";
    1.48 +    msg.direction = PEP_dir_outgoing;
    1.49 +
    1.50 +    PEP_rating clr = [session outgoingColorForMessage:msg];
    1.51 +    XCTAssertEqual(clr, PEP_rating_unencrypted);
    1.52 +
    1.53 +    PEPMessage *encMsg;
    1.54 +
    1.55 +    PEP_STATUS statusEnc = statusEnc = [session encryptMessage:msg extra:@[] dest:&encMsg];
    1.56 +
    1.57 +    XCTAssertEqual(statusEnc, PEP_UNENCRYPTED);
    1.58 +
    1.59 +    XCTAssertNotNil(encMsg);
    1.60 +
    1.61 +    PEPMessage *decMsg;
    1.62 +    PEPStringList *keys;
    1.63 +    PEP_rating pEpRating = [session decryptMessage:encMsg dest:&decMsg keys:&keys];
    1.64 +    XCTAssertEqual(pEpRating, PEP_rating_unencrypted);
    1.65 +    XCTAssertNotNil(decMsg);
    1.66 +}
    1.67 +
    1.68  @end