IOSAD-61 testMySelfCommType IOSAD-61
authorDirk Zimmermann <dirk@pep-project.org>
Thu, 02 Nov 2017 15:40:23 +0100
branchIOSAD-61
changeset 31833426789a1b0
parent 317 e119dc446c47
child 319 4800efd10ac6
IOSAD-61 testMySelfCommType
pEpObjCTests/iOSTests.m
     1.1 --- a/pEpObjCTests/iOSTests.m	Thu Nov 02 15:31:09 2017 +0100
     1.2 +++ b/pEpObjCTests/iOSTests.m	Thu Nov 02 15:40:23 2017 +0100
     1.3 @@ -346,14 +346,15 @@
     1.4  {
     1.5      [self pEpSetUp];
     1.6  
     1.7 -    NSMutableDictionary *identMe = @{ kPepUsername: @"pEp Test iOS GenKey",
     1.8 -                                      kPepAddress: @"pep.test.iosgenkey@pep-project.org",
     1.9 -                                      kPepUserID: @"Me" }.mutableCopy;
    1.10 +    PEPIdentity *identMe = [[PEPIdentity alloc]
    1.11 +                            initWithAddress:@"pep.test.iosgenkey@pep-project.org"
    1.12 +                            userID:@"Me"
    1.13 +                            userName:@"pEp Test iOS GenKey"];
    1.14  
    1.15      [session mySelf:identMe];
    1.16  
    1.17 -    XCTAssertNotNil(identMe[kPepFingerprint]);
    1.18 -    XCTAssertNotNil(identMe[kPepCommType]);
    1.19 +    XCTAssertNotNil(identMe.fingerPrint);
    1.20 +    XCTAssertNotEqual(identMe.commType, PEP_ct_unknown);
    1.21  
    1.22      // check that the comm type is not a PGP one
    1.23      XCTAssertFalse([identMe containsPGPCommType]);
    1.24 @@ -364,24 +365,28 @@
    1.25  
    1.26          // Now simulate an update from the app, which usually only caches
    1.27          // kPepUsername, kPepAddress and optionally kPepUserID.
    1.28 -        NSMutableDictionary *identMe2 = @{ kPepAddress: identMe[kPepAddress],
    1.29 -                                           kPepUsername: identMe[kPepUsername],
    1.30 -                                           kPepUserID: identMe[kPepUserID] }.mutableCopy;
    1.31 -        [session2 updateIdentity:identMe2];
    1.32 -        XCTAssertNotNil(identMe2[kPepFingerprint]);
    1.33 +        PEPIdentity *identMe2 = [[PEPIdentity alloc]
    1.34 +                                 initWithAddress:identMe.address
    1.35 +                                 userID:identMe.userID
    1.36 +                                 userName:identMe.userName];
    1.37 +        [session2 mySelf:identMe2];
    1.38 +        XCTAssertNotNil(identMe2.fingerPrint);
    1.39          XCTAssertFalse([identMe2 containsPGPCommType]);
    1.40 +        XCTAssertEqual(identMe2.fingerPrint, identMe.fingerPrint)
    1.41  
    1.42          // Now pretend the app only knows kPepUsername and kPepAddress
    1.43 -        NSMutableDictionary *identMe3 = @{ kPepAddress: identMe[kPepAddress],
    1.44 -                                           kPepUsername: identMe[kPepUsername] }.mutableCopy;
    1.45 -        [session2 updateIdentity:identMe3];
    1.46 -        XCTAssertNotNil(identMe3[kPepFingerprint]);
    1.47 +        PEPIdentity *identMe3 = [[PEPIdentity alloc]
    1.48 +                                 initWithAddress:identMe.address
    1.49 +                                 userName:identMe.userName];
    1.50 +        [session2 mySelf:identMe3];
    1.51 +        XCTAssertNotNil(identMe3.fingerPrint);
    1.52          XCTAssertFalse([identMe3 containsPGPCommType]);
    1.53 +        XCTAssertEqual(identMe3.fingerPrint, identMe.fingerPrint)
    1.54  
    1.55 -        XCTAssertEqualObjects(identMe[kPepAddress], identMe2[kPepAddress]);
    1.56 -        XCTAssertEqualObjects(identMe[kPepAddress], identMe3[kPepAddress]);
    1.57 -        XCTAssertEqualObjects(identMe[kPepCommType], identMe2[kPepCommType]);
    1.58 -        XCTAssertEqualObjects(identMe[kPepCommType], identMe3[kPepCommType]);
    1.59 +        XCTAssertEqualObjects(identMe.address, identMe2.address);
    1.60 +        XCTAssertEqualObjects(identMe.address, identMe3.address);
    1.61 +        XCTAssertEqual(identMe.commType, identMe2.commType);
    1.62 +        XCTAssertEqual(identMe.commType, identMe3.commType);
    1.63      });
    1.64  
    1.65      [self pEpCleanUp];