IOS-937 prove that identityRating works correctly
authorDirk Zimmermann <dirk@pep-project.org>
Fri, 09 Feb 2018 14:21:36 +0100
changeset 4391fd920a2ce00
parent 438 0cf0dad6d7c6
child 440 d8cf857a5fc2
IOS-937 prove that identityRating works correctly
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Fri Feb 09 14:08:48 2018 +0100
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Fri Feb 09 14:21:36 2018 +0100
     1.3 @@ -164,6 +164,25 @@
     1.4                          fingerPrint:@"BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39"];
     1.5  }
     1.6  
     1.7 +- (void)testIdentityRating
     1.8 +{
     1.9 +    PEPSession *session = [PEPSession new];
    1.10 +
    1.11 +    PEPIdentity *me = [self
    1.12 +                       checkMySelfImportingKeyFilePath:@"6FF00E97_sec.asc"
    1.13 +                       address:@"pep.test.alice@pep-project.org"
    1.14 +                       userID:@"Alice_User_ID"
    1.15 +                       fingerPrint:@"4ABE3AAF59AC32CFE4F86500A9411D176FF00E97"];
    1.16 +    XCTAssertEqual([session identityRating:me], PEP_rating_trusted_and_anonymized);
    1.17 +
    1.18 +    PEPIdentity *alice = [self
    1.19 +                          checkImportingKeyFilePath:@"6FF00E97_sec.asc"
    1.20 +                          address:@"pep.test.alice@pep-project.org"
    1.21 +                          userID:@"This Is Alice"
    1.22 +                          fingerPrint:@"4ABE3AAF59AC32CFE4F86500A9411D176FF00E97"];
    1.23 +    XCTAssertEqual([session identityRating:alice], PEP_rating_reliable);
    1.24 +}
    1.25 +
    1.26  - (void)testOutgoingColors
    1.27  {
    1.28      PEPSession *session = [PEPSession new];
    1.29 @@ -739,9 +758,9 @@
    1.30  
    1.31  #pragma mark - Helpers
    1.32  
    1.33 -- (void)checkImportingKeyFilePath:(NSString *)filePath address:(NSString *)address
    1.34 -                           userID:(NSString *)userID
    1.35 -                      fingerPrint:(NSString *)fingerPrint
    1.36 +- (PEPIdentity *)checkImportingKeyFilePath:(NSString *)filePath address:(NSString *)address
    1.37 +                                    userID:(NSString *)userID
    1.38 +                               fingerPrint:(NSString *)fingerPrint
    1.39  {
    1.40      PEPSession *session = [PEPSession new];
    1.41  
    1.42 @@ -751,12 +770,37 @@
    1.43      PEPIdentity *identTest = [[PEPIdentity alloc]
    1.44                                initWithAddress:address
    1.45                                userID:userID
    1.46 -                              userName:@"Some User Name"
    1.47 +                              userName:[NSString stringWithFormat:@"Some User Name %@", userID]
    1.48                                isOwn:NO];
    1.49  
    1.50      [session updateIdentity:identTest];
    1.51      XCTAssertNotNil(identTest.fingerPrint);
    1.52      XCTAssertEqualObjects(identTest.fingerPrint, fingerPrint);
    1.53 +
    1.54 +    return identTest;
    1.55 +}
    1.56 +
    1.57 +- (PEPIdentity *)checkMySelfImportingKeyFilePath:(NSString *)filePath address:(NSString *)address
    1.58 +                                          userID:(NSString *)userID
    1.59 +                                     fingerPrint:(NSString *)fingerPrint
    1.60 +{
    1.61 +    PEPSession *session = [PEPSession new];
    1.62 +
    1.63 +    [PEPTestUtils importBundledKey:filePath];
    1.64 +
    1.65 +    // Our test user:
    1.66 +    PEPIdentity *identTest = [[PEPIdentity alloc]
    1.67 +                              initWithAddress:address
    1.68 +                              userID:userID
    1.69 +                              userName:[NSString stringWithFormat:@"Some User Name %@", userID]
    1.70 +                              isOwn:YES
    1.71 +                              fingerPrint: fingerPrint];
    1.72 +
    1.73 +    [session mySelf:identTest];
    1.74 +    XCTAssertNotNil(identTest.fingerPrint);
    1.75 +    XCTAssertEqualObjects(identTest.fingerPrint, fingerPrint);
    1.76 +
    1.77 +    return identTest;
    1.78  }
    1.79  
    1.80  /**