IOSAD-163 testNoBeaconOnMyselfOnSecondIdentity (failing) IOSAD-163
authorDirk Zimmermann <dz@pep.security>
Wed, 08 Jan 2020 13:36:06 +0100
branchIOSAD-163
changeset 1383d73588490e8a
parent 1382 4a37f6aaff39
child 1384 ac3d4231e448
IOSAD-163 testNoBeaconOnMyselfOnSecondIdentity (failing)
pEpObjCTests/PEPSessionTest.m
     1.1 --- a/pEpObjCTests/PEPSessionTest.m	Wed Jan 08 13:36:06 2020 +0100
     1.2 +++ b/pEpObjCTests/PEPSessionTest.m	Wed Jan 08 13:36:06 2020 +0100
     1.3 @@ -1292,6 +1292,51 @@
     1.4      [self shutdownSync];
     1.5  }
     1.6  
     1.7 +/// Test creating an identity with pEp sync enabled,
     1.8 +/// starting the sync loop and then creating a 2nd own identity with pEp sync disabled.
     1.9 +/// Make sure there is a beacon sent out for the 1st, but not for the 2nd identity.
    1.10 +- (void)testNoBeaconOnMyselfOnSecondIdentity
    1.11 +{
    1.12 +    PEPSession *session = [PEPSession new];
    1.13 +
    1.14 +    XCTAssertEqual(self.sendMessageDelegate.messages.count, 0);
    1.15 +    XCTAssertNil(self.sendMessageDelegate.lastMessage);
    1.16 +
    1.17 +    PEPIdentity *identMe1 = [[PEPIdentity alloc]
    1.18 +                             initWithAddress:@"me-myself-and-i-1@pep-project.org"
    1.19 +                             userID:@"me-myself-and-i-1"
    1.20 +                             userName:@"pEp Me"
    1.21 +                             isOwn:YES];
    1.22 +
    1.23 +    NSError *error = nil;
    1.24 +    XCTAssertTrue([session mySelf:identMe1 pEpSyncEnabled:YES error:&error]);
    1.25 +    XCTAssertNil(error);
    1.26 +
    1.27 +    [self startSync];
    1.28 +
    1.29 +    XCTKVOExpectation *expHaveMessage1 = [[XCTKVOExpectation alloc]
    1.30 +                                          initWithKeyPath:@"lastMessage"
    1.31 +                                          object:self.sendMessageDelegate];
    1.32 +    [self waitForExpectations:@[expHaveMessage1] timeout:PEPTestInternalSyncTimeout];
    1.33 +    XCTAssertNotNil(self.sendMessageDelegate.lastMessage);
    1.34 +    XCTAssertEqual(self.sendMessageDelegate.messages.count, 1);
    1.35 +
    1.36 +    PEPIdentity *identMe2 = [[PEPIdentity alloc]
    1.37 +                             initWithAddress:@"me-myself-and-i-2@pep-project.org"
    1.38 +                             userID:@"me-myself-and-i-2"
    1.39 +                             userName:@"pEp Me"
    1.40 +                             isOwn:YES];
    1.41 +
    1.42 +    XCTAssertTrue([session mySelf:identMe2 pEpSyncEnabled:NO error:&error]);
    1.43 +    XCTAssertNil(error);
    1.44 +
    1.45 +    [NSThread sleepForTimeInterval:2];
    1.46 +
    1.47 +    XCTAssertEqual(self.sendMessageDelegate.messages.count, 1);
    1.48 +
    1.49 +    [self shutdownSync];
    1.50 +}
    1.51 +
    1.52  /// ENGINE-684
    1.53  - (void)testMyselfWithQueryKeySyncEnabledForIdentity
    1.54  {