IOS-937 importing keys still works
authorDirk Zimmermann <dirk@pep-project.org>
Fri, 09 Feb 2018 13:18:44 +0100
changeset 43728774351ee04
parent 436 3e2e18760184
child 438 0cf0dad6d7c6
IOS-937 importing keys still works
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Fri Feb 09 13:07:50 2018 +0100
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Fri Feb 09 13:18:44 2018 +0100
     1.3 @@ -153,31 +153,15 @@
     1.4      XCTAssertNil(identRandom.fingerPrint);
     1.5  }
     1.6  
     1.7 -- (void)testImportKey
     1.8 +- (void)testImportPartnerKeys
     1.9  {
    1.10 -    PEPSession *session = [PEPSession new];
    1.11 +    [self checkImportingKeyFilePath:@"6FF00E97_sec.asc" address:@"pep.test.alice@pep-project.org"
    1.12 +                             userID:@"This Is Alice"
    1.13 +                        fingerPrint:@"4ABE3AAF59AC32CFE4F86500A9411D176FF00E97"];
    1.14  
    1.15 -    // Our test user:
    1.16 -    // pEp Test Alice (test key don't use) <pep.test.alice@pep-project.org>
    1.17 -    // 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97
    1.18 -    [PEPTestUtils importBundledKey:@"6FF00E97_sec.asc"];
    1.19 -    NSString *identAliceFingerPrint = @"4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
    1.20 -
    1.21 -    // Our test user:
    1.22 -    PEPIdentity *identAlice = [[PEPIdentity alloc]
    1.23 -                               initWithAddress:@"pep.test.alice@pep-project.org"
    1.24 -                               userID:@"some_user_id"
    1.25 -                               userName:@"pEp Test Alice"
    1.26 -                               isOwn:NO];
    1.27 -
    1.28 -    [session updateIdentity:identAlice];
    1.29 -    XCTAssertNotNil(identAlice.fingerPrint);
    1.30 -    XCTAssertEqualObjects(identAlice.fingerPrint, identAliceFingerPrint);
    1.31 -
    1.32 -    identAlice.fingerPrint = identAliceFingerPrint;
    1.33 -    [session updateIdentity:identAlice];
    1.34 -    XCTAssertNotNil(identAlice.fingerPrint);
    1.35 -    XCTAssertEqualObjects(identAlice.fingerPrint, identAliceFingerPrint);
    1.36 +    [self checkImportingKeyFilePath:@"0xC9C2EE39.asc" address:@"pep.test.bob@pep-project.org"
    1.37 +                             userID:@"This Is Bob"
    1.38 +                        fingerPrint:@"BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39"];
    1.39  }
    1.40  
    1.41  - (void)testOutgoingColors
    1.42 @@ -757,6 +741,26 @@
    1.43  
    1.44  #pragma mark - Helpers
    1.45  
    1.46 +- (void)checkImportingKeyFilePath:(NSString *)filePath address:(NSString *)address
    1.47 +                           userID:(NSString *)userID
    1.48 +                      fingerPrint:(NSString *)fingerPrint
    1.49 +{
    1.50 +    PEPSession *session = [PEPSession new];
    1.51 +
    1.52 +    [PEPTestUtils importBundledKey:filePath];
    1.53 +
    1.54 +    // Our test user:
    1.55 +    PEPIdentity *identTest = [[PEPIdentity alloc]
    1.56 +                              initWithAddress:address
    1.57 +                              userID:userID
    1.58 +                              userName:@"Some User Name"
    1.59 +                              isOwn:NO];
    1.60 +
    1.61 +    [session updateIdentity:identTest];
    1.62 +    XCTAssertNotNil(identTest.fingerPrint);
    1.63 +    XCTAssertEqualObjects(identTest.fingerPrint, fingerPrint);
    1.64 +}
    1.65 +
    1.66  /**
    1.67   Verifies that a partner ID is really a correct Identity.
    1.68   Usually used on identities imported as keys, since the engine has problems with them.