merge IOSAD-164
authorDirk Zimmermann <dz@pep.security>
Tue, 14 Jan 2020 08:20:57 +0100
changeset 14017915afcc725c
parent 1379 13b2d34e6ba9
parent 1400 6aa3b1399aa2
child 1402 50072975bfbc
merge IOSAD-164
     1.1 --- a/pEpObjCAdapter.xcodeproj/project.pbxproj	Thu Dec 05 16:31:46 2019 +0100
     1.2 +++ b/pEpObjCAdapter.xcodeproj/project.pbxproj	Tue Jan 14 08:20:57 2020 +0100
     1.3 @@ -137,9 +137,9 @@
     1.4  		15D3D77C2010DDC500A0DA20 /* PEPTestUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PEPTestUtils.m; sourceTree = "<group>"; };
     1.5  		35FB0ABB1B57F97E00377032 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
     1.6  		35FB0ABD1B57F99D00377032 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
     1.7 -		430CD9B02292AC4900AAC37F /* PEPSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPSync.h; path = pEpObjCAdapterFramework/PEPSync.h; sourceTree = SOURCE_ROOT; };
     1.8 -		430CD9B52292ADAC00AAC37F /* PEPSendMessageDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPSendMessageDelegate.h; path = pEpObjCAdapterFramework/PEPSendMessageDelegate.h; sourceTree = SOURCE_ROOT; };
     1.9 -		430CD9BA2292AEDD00AAC37F /* PEPNotifyHandshakeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPNotifyHandshakeDelegate.h; path = pEpObjCAdapterFramework/PEPNotifyHandshakeDelegate.h; sourceTree = SOURCE_ROOT; };
    1.10 +		430CD9B02292AC4900AAC37F /* PEPSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPSync.h; path = PEPObjCAdapterFramework/PEPSync.h; sourceTree = SOURCE_ROOT; };
    1.11 +		430CD9B52292ADAC00AAC37F /* PEPSendMessageDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPSendMessageDelegate.h; path = PEPObjCAdapterFramework/PEPSendMessageDelegate.h; sourceTree = SOURCE_ROOT; };
    1.12 +		430CD9BA2292AEDD00AAC37F /* PEPNotifyHandshakeDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPNotifyHandshakeDelegate.h; path = PEPObjCAdapterFramework/PEPNotifyHandshakeDelegate.h; sourceTree = SOURCE_ROOT; };
    1.13  		430CD9BF2292B1EA00AAC37F /* PEPSync_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPSync_Internal.h; sourceTree = "<group>"; };
    1.14  		43209B261ECC2ACD007E7E2E /* NSArray+Extension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+Extension.h"; sourceTree = "<group>"; };
    1.15  		43209B271ECC2ACD007E7E2E /* NSArray+Extension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+Extension.m"; sourceTree = "<group>"; };
    1.16 @@ -173,11 +173,11 @@
    1.17  		435665CB2080A6CB00EC5B10 /* NSNumber+PEPRating.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSNumber+PEPRating.m"; sourceTree = "<group>"; };
    1.18  		435796E11FB5E51A00395A9E /* PEPMessage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPMessage.h; sourceTree = "<group>"; };
    1.19  		435796E21FB5E51A00395A9E /* PEPMessage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPMessage.m; sourceTree = "<group>"; };
    1.20 -		435C0CA022292E7C0025C6B5 /* PEPTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PEPTypes.h; path = pEpObjCAdapterFramework/PEPTypes.h; sourceTree = SOURCE_ROOT; };
    1.21 +		435C0CA022292E7C0025C6B5 /* PEPTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PEPTypes.h; path = PEPObjCAdapterFramework/PEPTypes.h; sourceTree = SOURCE_ROOT; };
    1.22  		435C0CAA222930340025C6B5 /* PEPConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPConstants.h; sourceTree = "<group>"; };
    1.23  		435C0CAB222930340025C6B5 /* PEPConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPConstants.m; sourceTree = "<group>"; };
    1.24 -		435F5163222045FB006EB11F /* PEPIdentity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPIdentity.h; path = pEpObjCAdapterFramework/PEPIdentity.h; sourceTree = SOURCE_ROOT; };
    1.25 -		435F518F22204A67006EB11F /* PEPSessionProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPSessionProtocol.h; path = pEpObjCAdapterFramework/PEPSessionProtocol.h; sourceTree = SOURCE_ROOT; };
    1.26 +		435F5163222045FB006EB11F /* PEPIdentity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPIdentity.h; path = PEPObjCAdapterFramework/PEPIdentity.h; sourceTree = SOURCE_ROOT; };
    1.27 +		435F518F22204A67006EB11F /* PEPSessionProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PEPSessionProtocol.h; path = PEPObjCAdapterFramework/PEPSessionProtocol.h; sourceTree = SOURCE_ROOT; };
    1.28  		4360A9FD2227CFA300E62E5A /* NSError+PEP+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSError+PEP+Internal.h"; sourceTree = "<group>"; };
    1.29  		4360A9FE2227EBB200E62E5A /* NSNumber+PEPRating+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSNumber+PEPRating+Internal.h"; sourceTree = "<group>"; };
    1.30  		43676B631C57EA1A00233933 /* 0xB623F674.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 0xB623F674.asc; sourceTree = "<group>"; };
    1.31 @@ -209,7 +209,7 @@
    1.32  		43E3985E221D7E56008E7983 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
    1.33  		43E3986A221D7EDD008E7983 /* libiconv.2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.2.tbd; path = usr/lib/libiconv.2.tbd; sourceTree = SDKROOT; };
    1.34  		43F73BE92166248E00AB4524 /* PEPSync.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPSync.m; sourceTree = "<group>"; };
    1.35 -		43FF2ECC2226AE7E000D9567 /* PEPEngineTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PEPEngineTypes.h; path = pEpObjCAdapterFramework/PEPEngineTypes.h; sourceTree = SOURCE_ROOT; };
    1.36 +		43FF2ECC2226AE7E000D9567 /* PEPEngineTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PEPEngineTypes.h; path = PEPObjCAdapterFramework/PEPEngineTypes.h; sourceTree = SOURCE_ROOT; };
    1.37  		640F79211C9B517C00DBEC4E /* 5CB2C182_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 5CB2C182_sec.asc; sourceTree = "<group>"; };
    1.38  		640F79221C9B517C00DBEC4E /* 5CB2C182.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 5CB2C182.asc; sourceTree = "<group>"; };
    1.39  		64415E171BE94FCB00F6CBB2 /* pEpObjCAdapterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = pEpObjCAdapterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
     2.1 --- a/pEpObjCAdapter/PEPIdentity.m	Thu Dec 05 16:31:46 2019 +0100
     2.2 +++ b/pEpObjCAdapter/PEPIdentity.m	Tue Jan 14 08:20:57 2020 +0100
     2.3 @@ -198,6 +198,7 @@
     2.4      self.userID = nil;
     2.5      self.userName = nil;
     2.6      self.isOwn = NO;
     2.7 +    self.flags = 0;
     2.8  }
     2.9  
    2.10  - (BOOL)enableKeySync:(NSError * _Nullable * _Nullable)error
    2.11 @@ -225,7 +226,8 @@
    2.12      NSMutableArray *result = [@[ @[kPepAddress, self.address],
    2.13                                   @[kPepCommType,
    2.14                                     [NSNumber numberWithInteger:(NSInteger) self.commType]],
    2.15 -                                 @[kPepIsOwnIdentity, [NSNumber numberWithBool:self.isOwn]]]
    2.16 +                                 @[kPepIsOwnIdentity, [NSNumber numberWithBool:self.isOwn]],
    2.17 +                                 @[kPepFlags, [NSNumber numberWithInt:self.flags]]]
    2.18                                mutableCopy];
    2.19  
    2.20      if (self.fingerPrint) {
     3.1 --- a/pEpObjCAdapter/PEPInternalSession.m	Thu Dec 05 16:31:46 2019 +0100
     3.2 +++ b/pEpObjCAdapter/PEPInternalSession.m	Tue Jan 14 08:20:57 2020 +0100
     3.3 @@ -536,23 +536,9 @@
     3.4  }
     3.5  
     3.6  - (BOOL)mySelf:(PEPIdentity * _Nonnull)identity
     3.7 -         error:(NSError * _Nullable * _Nullable)error
     3.8 -{
     3.9 -    // The default for pEpSyncEnabled is YES, that means the adapter
    3.10 -    // will not change the engine identity in that regard after new_identity
    3.11 -    // (called by PEP_identityToStruct).
    3.12 -    return [self mySelf:identity pEpSyncEnabled:YES error:error];
    3.13 -}
    3.14 -
    3.15 -- (BOOL)mySelf:(PEPIdentity * _Nonnull)identity
    3.16 -pEpSyncEnabled:(BOOL)pEpSyncEnabled
    3.17           error:(NSError * _Nullable * _Nullable)error {
    3.18      pEp_identity *ident = PEP_identityToStruct(identity);
    3.19  
    3.20 -    if (!pEpSyncEnabled) {
    3.21 -        ident->flags |= PEP_idf_not_for_sync;
    3.22 -    }
    3.23 -
    3.24      PEPStatus status = (PEPStatus) myself(_session, ident);
    3.25  
    3.26      if ([NSError setError:error fromPEPStatus:status]) {
    3.27 @@ -969,11 +955,14 @@
    3.28  {
    3.29      pEp_identity *ident = PEP_identityToStruct(identity);
    3.30      PEPStatus status = (PEPStatus) set_identity_flags(self.session, ident, flags);
    3.31 -    free_identity(ident);
    3.32  
    3.33      if ([NSError setError:error fromPEPStatus:status]) {
    3.34 +        free_identity(ident);
    3.35          return NO;
    3.36      } else {
    3.37 +        [identity reset];
    3.38 +        [identity setValuesForKeysWithDictionary:PEP_identityDictFromStruct(ident)];
    3.39 +        free_identity(ident);
    3.40          return YES;
    3.41      }
    3.42  }
     4.1 --- a/pEpObjCAdapter/PEPMessageUtil.m	Thu Dec 05 16:31:46 2019 +0100
     4.2 +++ b/pEpObjCAdapter/PEPMessageUtil.m	Tue Jan 14 08:20:57 2020 +0100
     4.3 @@ -146,6 +146,10 @@
     4.4      }
     4.5  
     4.6      if (dict && ident) {
     4.7 +        if ([dict objectForKey:kPepFlags]) {
     4.8 +            ident->flags = [[dict objectForKey:kPepFlags] intValue];
     4.9 +        }
    4.10 +
    4.11          if ([dict objectForKey:@"lang"])
    4.12              strncpy(ident->lang, [[[dict objectForKey:@"lang"]
    4.13                                     precomposedStringWithCanonicalMapping] UTF8String], 2);
    4.14 @@ -180,6 +184,7 @@
    4.15              [dict setObject:[NSString stringWithUTF8String:ident->lang] forKey:@"lang"];
    4.16          
    4.17          [dict setObject:[NSNumber numberWithInt: ident->comm_type] forKey:kPepCommType];
    4.18 +        [dict setObject:[NSNumber numberWithInt: ident->flags] forKey:kPepFlags];
    4.19      }
    4.20      return dict;
    4.21  }
    4.22 @@ -198,6 +203,7 @@
    4.23                                           precomposedStringWithCanonicalMapping] UTF8String]);
    4.24  
    4.25      ident->me = identity.isOwn;
    4.26 +    ident->flags = identity.flags;
    4.27  
    4.28      if (identity.language) {
    4.29          strncpy(ident->lang, [[identity.language
    4.30 @@ -236,6 +242,7 @@
    4.31      identity.commType = (PEPCommType) ident->comm_type;
    4.32  
    4.33      identity.isOwn = ident->me;
    4.34 +    identity.flags = ident->flags;
    4.35  
    4.36      return identity;
    4.37  }
     5.1 --- a/pEpObjCAdapter/PEPSession.m	Thu Dec 05 16:31:46 2019 +0100
     5.2 +++ b/pEpObjCAdapter/PEPSession.m	Tue Jan 14 08:20:57 2020 +0100
     5.3 @@ -179,14 +179,6 @@
     5.4      return [session mySelf:identity error:error];
     5.5  }
     5.6  
     5.7 -- (BOOL)mySelf:(PEPIdentity * _Nonnull)identity
     5.8 -pEpSyncEnabled:(BOOL)pEpSyncEnabled
     5.9 -         error:(NSError * _Nullable * _Nullable)error {
    5.10 -    PEPInternalSession *session = [PEPSessionProvider session];
    5.11 -    RETURN_ON_ERROR(session, error, NO);
    5.12 -    return [session mySelf:identity pEpSyncEnabled:pEpSyncEnabled error:error];
    5.13 -}
    5.14 -
    5.15  - (BOOL)updateIdentity:(PEPIdentity * _Nonnull)identity
    5.16                   error:(NSError * _Nullable * _Nullable)error
    5.17  {
     6.1 --- a/pEpObjCAdapterFramework/PEPConstants.h	Thu Dec 05 16:31:46 2019 +0100
     6.2 +++ b/pEpObjCAdapterFramework/PEPConstants.h	Tue Jan 14 08:20:57 2020 +0100
     6.3 @@ -101,3 +101,6 @@
     6.4  
     6.5  /** The positive value of the header for "pEp-auto-consume". */
     6.6  extern NSString *const _Nonnull kPepValueAutoConsumeYes;
     6.7 +
     6.8 +/// The key to the flags, which control pEp sync behaviour of an identity
     6.9 +extern NSString *const _Nonnull kPepFlags;
     7.1 --- a/pEpObjCAdapterFramework/PEPConstants.m	Thu Dec 05 16:31:46 2019 +0100
     7.2 +++ b/pEpObjCAdapterFramework/PEPConstants.m	Tue Jan 14 08:20:57 2020 +0100
     7.3 @@ -66,3 +66,5 @@
     7.4  NSString *const _Nonnull kPepHeaderAutoConsume = @"pEp-auto-consume";
     7.5  
     7.6  NSString *const _Nonnull kPepValueAutoConsumeYes = @"yes";
     7.7 +
     7.8 +NSString *const _Nonnull kPepFlags = @"flags";
     8.1 --- a/pEpObjCAdapterFramework/PEPIdentity.h	Thu Dec 05 16:31:46 2019 +0100
     8.2 +++ b/pEpObjCAdapterFramework/PEPIdentity.h	Tue Jan 14 08:20:57 2020 +0100
     8.3 @@ -9,6 +9,7 @@
     8.4  #import <Foundation/Foundation.h>
     8.5  
     8.6  #import "PEPSessionProtocol.h"
     8.7 +#import "PEPEngineTypes.h"
     8.8  
     8.9  @class PEPSession;
    8.10  
    8.11 @@ -49,6 +50,10 @@
    8.12   */
    8.13  @property BOOL isOwn;
    8.14  
    8.15 +/// Flags controlling pEp sync behaviour, consisting of PEPIdentityFlags enums
    8.16 +/// ORed together.
    8.17 +@property int flags;
    8.18 +
    8.19  /**
    8.20   Comm type contains the PEP_ct_confirmed flag?
    8.21   */
     9.1 --- a/pEpObjCAdapterFramework/PEPSessionProtocol.h	Thu Dec 05 16:31:46 2019 +0100
     9.2 +++ b/pEpObjCAdapterFramework/PEPSessionProtocol.h	Tue Jan 14 08:20:57 2020 +0100
     9.3 @@ -97,22 +97,6 @@
     9.4  - (BOOL)mySelf:(PEPIdentity * _Nonnull)identity
     9.5           error:(NSError * _Nullable * _Nullable)error;
     9.6  
     9.7 -/// Marks an identity as an own identity, and decides about participation in pEp sync.
     9.8 -///
     9.9 -/// @return Returns YES on success, NO on error, setting `*error` accordingly if possible.
    9.10 -///
    9.11 -/// @note See the engine's myself function for details.
    9.12 -///
    9.13 -/// @param identity The identity to mark as own.
    9.14 -///
    9.15 -/// @param pEpSyncEnabled Whether to enable sync, or not. Will set PEP_idf_not_for_sync
    9.16 -/// accordingly.
    9.17 -///
    9.18 -/// @param error Standard cocoa error handling.
    9.19 -- (BOOL)mySelf:(PEPIdentity * _Nonnull)identity
    9.20 -pEpSyncEnabled:(BOOL)pEpSyncEnabled
    9.21 -         error:(NSError * _Nullable * _Nullable)error;
    9.22 -
    9.23  /// Calls the engine's update_identity on the given identity.
    9.24  ///
    9.25  /// @note Prior this was invoking myself if the identity was identified as being an own
    10.1 --- a/pEpObjCTests/PEPSessionTest.m	Thu Dec 05 16:31:46 2019 +0100
    10.2 +++ b/pEpObjCTests/PEPSessionTest.m	Tue Jan 14 08:20:57 2020 +0100
    10.3 @@ -1124,6 +1124,8 @@
    10.4          error = nil;
    10.5          XCTAssertTrue([session setFlags:(PEPIdentityFlags) aFlag forIdentity:me error:&error]);
    10.6          XCTAssertNil(error);
    10.7 +
    10.8 +        XCTAssertTrue(me.flags & theFlags[i]);
    10.9      }
   10.10  }
   10.11  
   10.12 @@ -1264,7 +1266,7 @@
   10.13      }
   10.14  }
   10.15  
   10.16 -/// Test the disable of sync via myself.
   10.17 +/// Test creating a new own identity with pEp sync disabled.
   10.18  - (void)testNoBeaconOnMyself
   10.19  {
   10.20      PEPSession *session = [PEPSession new];
   10.21 @@ -1277,20 +1279,76 @@
   10.22                              userID:@"me-myself-and-i"
   10.23                              userName:@"pEp Me"
   10.24                              isOwn:YES];
   10.25 +    identMe.flags |= PEPIdentityFlagsNotForSync;
   10.26  
   10.27      NSError *error = nil;
   10.28 -    XCTAssertTrue([session mySelf:identMe pEpSyncEnabled:NO error:&error]);
   10.29 +    XCTAssertTrue([session mySelf:identMe error:&error]);
   10.30 +    XCTAssertNil(error);
   10.31 +    XCTAssertTrue([session disableSyncForIdentity:identMe error:&error]);
   10.32      XCTAssertNil(error);
   10.33  
   10.34      [self startSync];
   10.35  
   10.36 -    [NSThread sleepForTimeInterval:2];
   10.37 +    [NSThread sleepForTimeInterval:1];
   10.38      XCTAssertNil(self.sendMessageDelegate.lastMessage);
   10.39  
   10.40      XCTAssertEqual(self.sendMessageDelegate.messages.count, 0);
   10.41      [self shutdownSync];
   10.42  }
   10.43  
   10.44 +/// Test creating a new own identity with pEp sync disabled,
   10.45 +/// and then creating one with sync enabled, ensuring that
   10.46 +/// the beacon (on the 2nd identity with sync enabled) gets send out.
   10.47 +- (void)testMyselfSyncDisabledMyselfSyncEnabled
   10.48 +{
   10.49 +    PEPSession *session = [PEPSession new];
   10.50 +
   10.51 +    XCTAssertEqual(self.sendMessageDelegate.messages.count, 0);
   10.52 +    XCTAssertNil(self.sendMessageDelegate.lastMessage);
   10.53 +
   10.54 +    PEPIdentity *identMeDisabled = [[PEPIdentity alloc]
   10.55 +                                    initWithAddress:@"me-myself-and-i@pep-project.org"
   10.56 +                                    userID:@"me-myself-and-i"
   10.57 +                                    userName:@"pEp Me"
   10.58 +                                    isOwn:YES];
   10.59 +    identMeDisabled.flags |= PEPIdentityFlagsNotForSync;
   10.60 +
   10.61 +    NSError *error = nil;
   10.62 +    XCTAssertTrue([session mySelf:identMeDisabled error:&error]);
   10.63 +    XCTAssertNil(error);
   10.64 +    XCTAssertTrue([session disableSyncForIdentity:identMeDisabled error:&error]);
   10.65 +    XCTAssertNil(error);
   10.66 +
   10.67 +    [self startSync];
   10.68 +
   10.69 +    [NSThread sleepForTimeInterval:1];
   10.70 +    XCTAssertNil(self.sendMessageDelegate.lastMessage);
   10.71 +
   10.72 +    XCTAssertEqual(self.sendMessageDelegate.messages.count, 0);
   10.73 +
   10.74 +    PEPIdentity *identMeEnsabled = [[PEPIdentity alloc]
   10.75 +                                    initWithAddress:@"me-myself-and-i_enabled@pep-project.org"
   10.76 +                                    userID:@"me-myself-and-i_enabled"
   10.77 +                                    userName:@"pEp Me_enabled"
   10.78 +                                    isOwn:YES];
   10.79 +
   10.80 +    error = nil;
   10.81 +    XCTAssertTrue([session mySelf:identMeEnsabled error:&error]);
   10.82 +    XCTAssertNil(error);
   10.83 +
   10.84 +    XCTKVOExpectation *expHaveMessage1 = [[XCTKVOExpectation alloc]
   10.85 +                                          initWithKeyPath:@"lastMessage"
   10.86 +                                          object:self.sendMessageDelegate];
   10.87 +    [self waitForExpectations:@[expHaveMessage1] timeout:PEPTestInternalSyncTimeout];
   10.88 +    XCTAssertNotNil(self.sendMessageDelegate.lastMessage);
   10.89 +    XCTAssertGreaterThan(self.sendMessageDelegate.messages.count, 0);
   10.90 +
   10.91 +    XCTAssertEqualObjects(self.sendMessageDelegate.lastMessage.from.address,
   10.92 +                          identMeEnsabled.address);
   10.93 +
   10.94 +    [self shutdownSync];
   10.95 +}
   10.96 +
   10.97  /// ENGINE-684
   10.98  - (void)testMyselfWithQueryKeySyncEnabledForIdentity
   10.99  {
  10.100 @@ -1311,11 +1369,20 @@
  10.101      for (PEPIdentity *ident in @[identMeEnabled, identMeDisabled]) {
  10.102          BOOL expectEnabled = ident == identMeEnabled ? YES : NO;
  10.103  
  10.104 +        if (!expectEnabled) {
  10.105 +            ident.flags |= PEPIdentityFlagsNotForSync;
  10.106 +        }
  10.107 +
  10.108          NSError *error = nil;
  10.109 -        XCTAssertTrue([session mySelf:identMeEnabled pEpSyncEnabled:expectEnabled error:&error]);
  10.110 +        XCTAssertTrue([session mySelf:ident error:&error]);
  10.111          XCTAssertNil(error);
  10.112  
  10.113 -        NSNumber *enabledNum = [session queryKeySyncEnabledForIdentity:identMeEnabled error:&error];
  10.114 +        if (!expectEnabled) {
  10.115 +            XCTAssertTrue([session disableSyncForIdentity:ident error:&error]);
  10.116 +            XCTAssertNil(error);
  10.117 +        }
  10.118 +
  10.119 +        NSNumber *enabledNum = [session queryKeySyncEnabledForIdentity:ident error:&error];
  10.120          XCTAssertNotNil(enabledNum);
  10.121          XCTAssertNil(error);
  10.122