IOS-1943 (Too convoluted): Test for reproducing it. IOS-1943
authorDirk Zimmermann <dz@pep.security>
Thu, 24 Oct 2019 16:59:12 +0200
branchIOS-1943
changeset 1324fe4c440db4df
parent 1323 2154f438ae70
child 1325 79fbbc66bd39
IOS-1943 (Too convoluted): Test for reproducing it.
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Thu Oct 24 16:23:38 2019 +0200
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Thu Oct 24 16:59:12 2019 +0200
     1.3 @@ -1502,6 +1502,72 @@
     1.4      [self shutdownSync];
     1.5  }
     1.6  
     1.7 +/// Reproduces the essential parts of IOS-1943.
     1.8 +- (void)testExtraKeysRating
     1.9 +{
    1.10 +    PEPSession *session = [PEPSession new];
    1.11 +
    1.12 +    PEPIdentity *identMe = [[PEPIdentity alloc]
    1.13 +                            initWithAddress:@"me-myself-and-i@pep-project.org"
    1.14 +                            userID:@"me-myself-and-i"
    1.15 +                            userName:@"pEp Me"
    1.16 +                            isOwn:YES];
    1.17 +    NSError *error = nil;
    1.18 +    XCTAssertTrue([session mySelf:identMe error:&error]);
    1.19 +    XCTAssertNil(error);
    1.20 +
    1.21 +    // Our test user :
    1.22 +    // pEp Test Alice (test key don't use) <pep.test.alice@pep-project.org>
    1.23 +    // 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97
    1.24 +    XCTAssertTrue([PEPTestUtils importBundledKey:@"6FF00E97_sec.asc" session:session]);
    1.25 +
    1.26 +    NSString *aliceFingerprint = @"4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
    1.27 +    PEPIdentity *identAlice = [[PEPIdentity alloc]
    1.28 +                               initWithAddress:@"pep.test.alice@pep-project.org"
    1.29 +                               userID:ownUserId
    1.30 +                               userName:@"pEp Test Alice"
    1.31 +                               isOwn:NO
    1.32 +                               fingerPrint:aliceFingerprint];
    1.33 +    [self updateAndVerifyPartnerIdentity:identAlice session:session];
    1.34 +
    1.35 +    PEPMessage *myMsg = [PEPMessage new];
    1.36 +    myMsg.direction = PEPMsgDirectionOutgoing;
    1.37 +    myMsg.from = identMe;
    1.38 +    myMsg.to = @[identAlice];
    1.39 +
    1.40 +    NSNumber *outRating = [session outgoingRatingForMessage:myMsg error:&error];
    1.41 +    XCTAssertNotNil(outRating);
    1.42 +    XCTAssertNil(error);
    1.43 +    XCTAssertEqual(outRating.intValue, PEPRatingReliable);
    1.44 +
    1.45 +    XCTAssertNil(error);
    1.46 +    XCTAssertTrue([session trustPersonalKey:identAlice error:&error]);
    1.47 +
    1.48 +    outRating = [session outgoingRatingForMessage:myMsg error:&error];
    1.49 +    XCTAssertNotNil(outRating);
    1.50 +    XCTAssertNil(error);
    1.51 +    XCTAssertEqual(outRating.intValue, PEPRatingTrusted);
    1.52 +
    1.53 +    PEPStatus status;
    1.54 +    PEPMessage *encryptedMsgWithoutExtraKeys = [session
    1.55 +                                                encryptMessage:myMsg
    1.56 +                                                extraKeys:@[]
    1.57 +                                                status:&status
    1.58 +                                                error:&error];
    1.59 +    XCTAssertNotNil(encryptedMsgWithoutExtraKeys);
    1.60 +    XCTAssertNil(error);
    1.61 +    XCTAssertEqual(status, PEPStatusOK);
    1.62 +
    1.63 +    PEPMessage *encryptedMsgWithExtraKeys = [session
    1.64 +                                             encryptMessage:myMsg
    1.65 +                                             extraKeys:@[aliceFingerprint]
    1.66 +                                             status:&status
    1.67 +                                             error:&error];
    1.68 +    XCTAssertNotNil(encryptedMsgWithExtraKeys);
    1.69 +    XCTAssertNil(error);
    1.70 +    XCTAssertEqual(status, PEPStatusOK);
    1.71 +}
    1.72 +
    1.73  #pragma mark - Helpers
    1.74  
    1.75  - (void)testSendMessageOnSession:(PEPSession *)session