IOS-1943 Minimal test reproducing the problem. IOS-1943
authorDirk Zimmermann <dz@pep.security>
Fri, 25 Oct 2019 12:05:24 +0200
branchIOS-1943
changeset 132579fbbc66bd39
parent 1324 fe4c440db4df
child 1428 eaf959be81ab
IOS-1943 Minimal test reproducing the problem.
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Thu Oct 24 16:59:12 2019 +0200
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Fri Oct 25 12:05:24 2019 +0200
     1.3 @@ -1516,7 +1516,7 @@
     1.4      XCTAssertTrue([session mySelf:identMe error:&error]);
     1.5      XCTAssertNil(error);
     1.6  
     1.7 -    // Our test user :
     1.8 +    // Our extra keys user:
     1.9      // pEp Test Alice (test key don't use) <pep.test.alice@pep-project.org>
    1.10      // 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97
    1.11      XCTAssertTrue([PEPTestUtils importBundledKey:@"6FF00E97_sec.asc" session:session]);
    1.12 @@ -1533,20 +1533,12 @@
    1.13      PEPMessage *myMsg = [PEPMessage new];
    1.14      myMsg.direction = PEPMsgDirectionOutgoing;
    1.15      myMsg.from = identMe;
    1.16 -    myMsg.to = @[identAlice];
    1.17 +    myMsg.to = @[identMe];
    1.18  
    1.19      NSNumber *outRating = [session outgoingRatingForMessage:myMsg error:&error];
    1.20      XCTAssertNotNil(outRating);
    1.21      XCTAssertNil(error);
    1.22 -    XCTAssertEqual(outRating.intValue, PEPRatingReliable);
    1.23 -
    1.24 -    XCTAssertNil(error);
    1.25 -    XCTAssertTrue([session trustPersonalKey:identAlice error:&error]);
    1.26 -
    1.27 -    outRating = [session outgoingRatingForMessage:myMsg error:&error];
    1.28 -    XCTAssertNotNil(outRating);
    1.29 -    XCTAssertNil(error);
    1.30 -    XCTAssertEqual(outRating.intValue, PEPRatingTrusted);
    1.31 +    XCTAssertEqual(outRating.intValue, PEPRatingTrustedAndAnonymized);
    1.32  
    1.33      PEPStatus status;
    1.34      PEPMessage *encryptedMsgWithoutExtraKeys = [session
    1.35 @@ -1566,6 +1558,30 @@
    1.36      XCTAssertNotNil(encryptedMsgWithExtraKeys);
    1.37      XCTAssertNil(error);
    1.38      XCTAssertEqual(status, PEPStatusOK);
    1.39 +
    1.40 +    PEPDecryptFlags flags;
    1.41 +    PEPRating rating;
    1.42 +    NSArray *extraKeysWithoutExtraKeys;
    1.43 +    PEPMessage *decryptedMsgWithoutExtraKeys = [session
    1.44 +                                                decryptMessage:encryptedMsgWithoutExtraKeys
    1.45 +                                                flags:&flags
    1.46 +                                                rating:&rating
    1.47 +                                                extraKeys:&extraKeysWithoutExtraKeys
    1.48 +                                                status:&status
    1.49 +                                                error:&error];
    1.50 +    XCTAssertNotNil(decryptedMsgWithoutExtraKeys);
    1.51 +    XCTAssertEqual(rating, PEPRatingTrustedAndAnonymized);
    1.52 +
    1.53 +    NSArray *extraKeysWithExtraKeys;
    1.54 +    PEPMessage *decryptedMsgWithExtraKeys = [session
    1.55 +                                             decryptMessage:encryptedMsgWithExtraKeys
    1.56 +                                             flags:&flags
    1.57 +                                             rating:&rating
    1.58 +                                             extraKeys:&extraKeysWithExtraKeys
    1.59 +                                             status:&status
    1.60 +                                             error:&error];
    1.61 +    XCTAssertNotNil(decryptedMsgWithExtraKeys);
    1.62 +    XCTAssertEqual(rating, PEPRatingTrustedAndAnonymized);
    1.63  }
    1.64  
    1.65  #pragma mark - Helpers