IOSAD-131 Test case for ENGINE-604. IOSAD-131
authorDirk Zimmermann <dz@pep.security>
Mon, 02 Sep 2019 12:17:11 +0200
branchIOSAD-131
changeset 11795edad01bb8bd
parent 1178 b48176815596
IOSAD-131 Test case for ENGINE-604.
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Mon Sep 02 11:56:47 2019 +0200
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Mon Sep 02 12:17:11 2019 +0200
     1.3 @@ -1376,6 +1376,61 @@
     1.4      XCTAssertFalse(enabled);
     1.5  }
     1.6  
     1.7 +#pragma mark - ENGINE-604
     1.8 +
     1.9 +- (void)testMyselfUpdatesFlags
    1.10 +{
    1.11 +    PEPSession *session = [PEPSession new];
    1.12 +
    1.13 +    PEPIdentity *identMe = [[PEPIdentity alloc]
    1.14 +                            initWithAddress:@"me-yes@example.com"
    1.15 +                            userID:@"yes-me"
    1.16 +                            userName:@"Yes Me"
    1.17 +                            isOwn:YES];
    1.18 +
    1.19 +    NSError *error = nil;
    1.20 +
    1.21 +    XCTAssertTrue([session mySelf:identMe error:&error]);
    1.22 +    XCTAssertNil(error);
    1.23 +    XCTAssertNotNil(identMe.fingerPrint);
    1.24 +
    1.25 +    BOOL enabled;
    1.26 +    XCTAssertTrue([identMe queryKeySyncEnabled:&enabled session:session error:&error]);
    1.27 +    XCTAssertNil(error);
    1.28 +    XCTAssertFalse(enabled);
    1.29 +
    1.30 +    error = nil;
    1.31 +
    1.32 +    XCTAssertTrue([identMe enableKeySync:YES session:session error:&error]);
    1.33 +    XCTAssertNil(error);
    1.34 +
    1.35 +    error = nil;
    1.36 +
    1.37 +    // query 1st time
    1.38 +    XCTAssertTrue([identMe queryKeySyncEnabled:&enabled session:session error:&error]);
    1.39 +    XCTAssertNil(error);
    1.40 +    XCTAssertTrue(enabled);
    1.41 +
    1.42 +    error = nil;
    1.43 +
    1.44 +    // clone
    1.45 +
    1.46 +    PEPIdentity *identMe2 = [[PEPIdentity alloc]
    1.47 +                             initWithAddress:@"me-yes@example.com"
    1.48 +                             userID:@"yes-me"
    1.49 +                             userName:@"Yes Me"
    1.50 +                             isOwn:YES];
    1.51 +    identMe2.fingerPrint = identMe.fingerPrint;
    1.52 +
    1.53 +    // Set a breakpoint here, and watch how mySelf updates the flags.
    1.54 +    // (set _PEP_SQLITE_DEBUG to 1).
    1.55 +    XCTAssertTrue([session mySelf:identMe2 error:&error]);
    1.56 +
    1.57 +    XCTAssertNil(error);
    1.58 +    XCTAssertNotNil(identMe2.fingerPrint);
    1.59 +    XCTAssertEqualObjects(identMe.fingerPrint, identMe2.fingerPrint);
    1.60 +}
    1.61 +
    1.62  #pragma mark - Helpers
    1.63  
    1.64  - (void)testSendMessageOnSession:(PEPSession *)session