IOS-937 trying to make testOutgoingColors more stable
authorDirk Zimmermann <dirk@pep-project.org>
Fri, 09 Feb 2018 15:01:51 +0100
changeset 441b951138b7dd1
parent 440 d8cf857a5fc2
child 442 8de34676b7f5
IOS-937 trying to make testOutgoingColors more stable
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Fri Feb 09 14:23:49 2018 +0100
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Fri Feb 09 15:01:51 2018 +0100
     1.3 @@ -201,32 +201,39 @@
     1.4  
     1.5      //Message
     1.6  
     1.7 -    PEPIdentity *identBob = [[PEPIdentity alloc]
     1.8 -                             initWithAddress:@"pep.test.bob@pep-project.org"
     1.9 -                             userID:@"42" userName:@"pEp Test Bob"
    1.10 -                             isOwn:NO];
    1.11 +    {
    1.12 +        PEPIdentity *identUnknownBob = [[PEPIdentity alloc]
    1.13 +                                        initWithAddress:@"pep.test.unknown.bob@pep-project.org"
    1.14 +                                        userID:@"4242" userName:@"pEp Test Bob Unknown"
    1.15 +                                        isOwn:NO];
    1.16 +
    1.17 +        PEPMessage *msgGray = [PEPMessage new];
    1.18 +        msgGray.from = identAlice;
    1.19 +        msgGray.to = @[identUnknownBob];
    1.20 +        msgGray.shortMessage = @"All Gray Test";
    1.21 +        msgGray.longMessage = @"This is a text content";
    1.22 +        msgGray.direction = PEP_dir_outgoing;
    1.23 +
    1.24 +        // Test with unknown Bob
    1.25 +        PEP_rating clr = [session outgoingColorForMessage:msgGray];
    1.26 +        XCTAssertEqual(clr, PEP_rating_unencrypted);
    1.27 +    }
    1.28 +
    1.29 +    PEPIdentity *identBob = [self
    1.30 +                             checkImportingKeyFilePath:@"0xC9C2EE39.asc"
    1.31 +                             address:@"pep.test.bob@pep-project.org"
    1.32 +                             userID:@"42"
    1.33 +                             fingerPrint:@"BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39"];
    1.34  
    1.35      PEPMessage *msg = [PEPMessage new];
    1.36      msg.from = identAlice;
    1.37      msg.to = @[identBob];
    1.38 -    msg.shortMessage = @"All Green Test";
    1.39 +    msg.shortMessage = @"All Gray Test";
    1.40      msg.longMessage = @"This is a text content";
    1.41      msg.direction = PEP_dir_outgoing;
    1.42  
    1.43 -    // Test with unknown Bob
    1.44 +    // Should be yellow, since no handshake happened.
    1.45      PEP_rating clr = [session outgoingColorForMessage:msg];
    1.46 -    XCTAssertEqual(clr, PEP_rating_unencrypted);
    1.47 -
    1.48 -    // Now let see with bob's pubkey already known
    1.49 -    // pEp Test Bob (test key, don't use) <pep.test.bob@pep-project.org>
    1.50 -    // BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39
    1.51 -    [PEPTestUtils importBundledKey:@"0xC9C2EE39.asc"];
    1.52 -    identBob.fingerPrint = @"BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39";
    1.53 -
    1.54 -    [self updateAndVerifyPartnerIdentity:identBob session:session];
    1.55 -
    1.56 -    // Should be yellow, since no handshake happened.
    1.57 -    clr = [session outgoingColorForMessage:msg];
    1.58      XCTAssertEqual(clr, PEP_rating_reliable);
    1.59  
    1.60      clr = [session identityRating:identBob];
    1.61 @@ -252,6 +259,9 @@
    1.62      // mistrust Bob
    1.63      [session keyMistrusted:identBob];
    1.64  
    1.65 +    [session updateIdentity:identBob];
    1.66 +    XCTAssertNil(identBob.fingerPrint);
    1.67 +
    1.68      // Gray == PEP_rating_unencrypted
    1.69      clr = [session outgoingColorForMessage:msg];
    1.70      XCTAssertEqual(clr, PEP_rating_unencrypted);