Browse Source

Merge branch 'master' into IOS-217_IOS-2295

IOS-217_IOS-2295
Dirk Zimmermann 1 year ago
parent
commit
9bb35a0ae2
6 changed files with 116 additions and 0 deletions
  1. +3
    -0
      PEPObjCAdapterTypes/PublicHeaders/PEPSessionProtocol.h
  2. +3
    -0
      pEpObjCAdapter/PEPInternalSession.h
  3. +13
    -0
      pEpObjCAdapter/PEPInternalSession.m
  4. +12
    -0
      pEpObjCAdapter/PEPSession.m
  5. +43
    -0
      pEpObjCTests/PEPInternalSessionTest.m
  6. +42
    -0
      pEpObjCTests/PEPSessionTest.m

+ 3
- 0
PEPObjCAdapterTypes/PublicHeaders/PEPSessionProtocol.h View File

@ -231,6 +231,9 @@ extern NSString *const _Nonnull PEPObjCAdapterErrorDomain;
/// Wraps color_from_rating.
- (PEPColor)colorFromRating:(PEPRating)rating;
/// Wraps `disable_all_sync_channels` (`sync_api.h`).
- (BOOL)disableAllSyncChannels:(NSError * _Nullable * _Nullable)error;
@end
NS_ASSUME_NONNULL_END

+ 3
- 0
pEpObjCAdapter/PEPInternalSession.h View File

@ -337,4 +337,7 @@
- (BOOL)configurePassphrase:(NSString * _Nonnull)passphrase
error:(NSError * _Nullable * _Nullable)error;
/// Wraps `disable_all_sync_channels` (`sync_api.h`).
- (BOOL)disableAllSyncChannels:(NSError * _Nullable * _Nullable)error;
@end

+ 13
- 0
pEpObjCAdapter/PEPInternalSession.m View File

@ -1033,4 +1033,17 @@ static NSDictionary *stringToRating;
return [PEPPassphraseCache sharedInstance];
}
- (BOOL)disableAllSyncChannels:(NSError * _Nullable * _Nullable)error
{
PEPStatus theStatus = (PEPStatus) [self runWithPasswords:^PEP_STATUS(PEP_SESSION session) {
return disable_all_sync_channels(self.session);
}];
if ([NSError setError:error fromPEPStatus:theStatus]) {
return NO;
} else {
return YES;
}
}
@end

+ 12
- 0
pEpObjCAdapter/PEPSession.m View File

@ -650,4 +650,16 @@ successCallback:(void (^)(NSString *log))successCallback
return [session colorFromRating:rating];
}
- (BOOL)disableAllSyncChannels:(NSError * _Nullable * _Nullable)error
{
PEPInternalSession *session = [PEPSessionProvider session];
if (session == nil) {
if (error) {
*error = [NSError errorWithPEPStatusInternal:PEP_UNKNOWN_ERROR];
}
return NO;
}
return [session disableAllSyncChannels:error];
}
@end

+ 43
- 0
pEpObjCTests/PEPInternalSessionTest.m View File

@ -1161,6 +1161,49 @@
}
}
- (void)testDisableAllSyncChannels
{
PEPInternalSession *session = [PEPSessionProvider session];
PEPIdentity *ident1 = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i-1@pep-project.org"
userID:@"me-myself-and-i-1"
userName:@"me-myself-and-i-1"
isOwn:YES];
PEPIdentity *ident2 = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i-2@pep-project.org"
userID:@"me-myself-and-i-2"
userName:@"me-myself-and-i-2"
isOwn:YES];
for (PEPIdentity *ident in @[ident1, ident2]) {
NSError *error = nil;
XCTAssertTrue([session mySelf:ident error:&error]);
XCTAssertNil(error);
NSNumber *enabledNum = [session queryKeySyncEnabledForIdentity:ident error:&error];
XCTAssertNotNil(enabledNum);
XCTAssertNil(error);
XCTAssertEqual([enabledNum boolValue], YES);
}
NSError *error = nil;
XCTAssertTrue([session disableAllSyncChannels:&error]);
XCTAssertNil(error);
for (PEPIdentity *ident in @[ident1, ident2]) {
NSError *error = nil;
NSNumber *enabledNum = [session queryKeySyncEnabledForIdentity:ident error:&error];
XCTAssertNotNil(enabledNum);
XCTAssertNil(error);
XCTAssertEqual([enabledNum boolValue], NO);
}
}
#pragma mark - key_reset_user
- (void)testKeyResetIdentityOnOwnKeyIsIllegal


+ 42
- 0
pEpObjCTests/PEPSessionTest.m View File

@ -380,6 +380,48 @@
XCTAssertNotEqual(fprOriginal, fprAfterReset);
}
- (void)testDisableAllSyncChannels
{
PEPIdentity *ident1 = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i-1@pep-project.org"
userID:@"me-myself-and-i-1"
userName:@"me-myself-and-i-1"
isOwn:YES];
PEPIdentity *ident2 = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i-2@pep-project.org"
userID:@"me-myself-and-i-2"
userName:@"me-myself-and-i-2"
isOwn:YES];
for (PEPIdentity *ident in @[ident1, ident2]) {
NSError *error = nil;
NSNumber *enabledNum = [self queryKeySyncEnabledForIdentity:ident error:&error];
XCTAssertNotNil(enabledNum);
XCTAssertNil(error);
XCTAssertEqual([enabledNum boolValue], YES);
}
PEPSession *asyncSession = [PEPSession new];
NSError *error = nil;
XCTAssertTrue([asyncSession disableAllSyncChannels:&error]);
XCTAssertNil(error);
for (PEPIdentity *ident in @[ident1, ident2]) {
NSError *error = nil;
XCTAssertTrue([self mySelf:ident error:&error]);
XCTAssertNil(error);
NSNumber *enabledNum = [self queryKeySyncEnabledForIdentity:ident error:&error];
XCTAssertNotNil(enabledNum);
XCTAssertNil(error);
XCTAssertEqual([enabledNum boolValue], NO);
}
}
#pragma mark - Helpers
- (PEPMessage *)mailWrittenToMySelf


Loading…
Cancel
Save