Browse Source

IOS-2735 rm queryKeySyncEnabled. Is needless now, other adapters do not have it and it even might deliver contradicting results from an app point of view.

IOS-2735
Andreas Buff 3 months ago
parent
commit
00e308e027
6 changed files with 0 additions and 306 deletions
  1. +0
    -4
      PEPObjCAdapterTypes/PublicHeaders/PEPSessionProtocol.h
  2. +0
    -11
      pEpObjCAdapter/PEPInternalSession.h
  3. +0
    -30
      pEpObjCAdapter/PEPInternalSession.m
  4. +0
    -17
      pEpObjCAdapter/PEPSession.m
  5. +0
    -172
      pEpObjCTests/PEPInternalSessionTest.m
  6. +0
    -72
      pEpObjCTests/PEPSessionTest.m

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

@ -122,10 +122,6 @@ extern NSString *const _Nonnull PEPObjCAdapterErrorDomain;
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(void))successCallback;
- (void)queryKeySyncEnabledForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(BOOL enabled))successCallback;
- (void)importKey:(NSString *)keydata
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<PEPIdentity *> *identities))successCallback;


+ 0
- 11
pEpObjCAdapter/PEPInternalSession.h View File

@ -181,17 +181,6 @@
- (BOOL)disableSyncForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
/**
Queries the given own identity on whether it has key sync disabled or not.
@param identity The (own) identity to query.
@param error The usual cocoa error handling.
@return An NSNumber containing a boolean denoting whether key sync is enabled or not, or
nil on error. YES means that key sync is allowed for this identity, otherwise it's NO.
*/
- (NSNumber * _Nullable)queryKeySyncEnabledForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error;
#pragma mark -- Internal API (testing etc.)
/** For testing purpose, manual key import */


+ 0
- 30
pEpObjCAdapter/PEPInternalSession.m View File

@ -595,36 +595,6 @@ void decryptMessageFree(message *src, message *dst, stringlist_t *extraKeys)
return YES;
}
- (NSNumber * _Nullable)queryKeySyncEnabledForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
pEp_identity *ident = [identity toStruct];
if (!identity.isOwn) {
[NSError setError:error fromPEPStatus:PEPStatusIllegalValue];
return nil;
}
PEPStatus status = (PEPStatus) [self runWithPasswords:^PEP_STATUS(PEP_SESSION session) {
return myself(session, ident);
}];
if ([NSError setError:error fromPEPStatus:status]) {
free_identity(ident);
return nil;
}
identity_flags_t flags = ident->flags;
free_identity(ident);
if (flags & PEP_idf_not_for_sync) {
return [NSNumber numberWithBool:NO];
} else {
return [NSNumber numberWithBool:YES];
}
}
- (NSArray<PEPIdentity *> * _Nullable)importKey:(NSString * _Nonnull)keydata
error:(NSError * _Nullable * _Nullable)error
{


+ 0
- 17
pEpObjCAdapter/PEPSession.m View File

@ -362,23 +362,6 @@ successCallback:(void (^)(PEPIdentity *identity))successCallback
});
}
- (void)queryKeySyncEnabledForIdentity:(PEPIdentity *)identity
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(BOOL enabled))successCallback
{
dispatch_async(queue, ^{
NSError *error = nil;
NSNumber *boolNum = [[PEPSessionProvider session]
queryKeySyncEnabledForIdentity:identity
error:&error];
if (boolNum != nil) {
successCallback(boolNum.boolValue);
} else {
errorCallback(error);
}
});
}
- (void)importKey:(NSString *)keydata
errorCallback:(void (^)(NSError *error))errorCallback
successCallback:(void (^)(NSArray<PEPIdentity *> *identities))successCallback


+ 0
- 172
pEpObjCTests/PEPInternalSessionTest.m View File

@ -1120,90 +1120,6 @@
[self shutdownSync];
}
/// ENGINE-684
- (void)testMyselfWithQueryKeySyncEnabledForIdentity
{
PEPInternalSession *session = [PEPSessionProvider session];
PEPIdentity *identMeEnabled = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i-enabled@pep-project.org"
userID:@"me-myself-and-i-enabled"
userName:@"pEp Me Enabled"
isOwn:YES];
PEPIdentity *identMeDisabled = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i-disabled@pep-project.org"
userID:@"me-myself-and-i-disabled"
userName:@"pEp Me Disabled"
isOwn:YES];
for (PEPIdentity *ident in @[identMeEnabled, identMeDisabled]) {
BOOL expectEnabled = ident == identMeEnabled ? YES : NO;
if (!expectEnabled) {
ident.flags |= PEPIdentityFlagsNotForSync;
}
NSError *error = nil;
XCTAssertTrue([session mySelf:ident error:&error]);
XCTAssertNil(error);
if (!expectEnabled) {
XCTAssertTrue([session disableSyncForIdentity:ident error:&error]);
XCTAssertNil(error);
}
NSNumber *enabledNum = [session queryKeySyncEnabledForIdentity:ident error:&error];
XCTAssertNotNil(enabledNum);
XCTAssertNil(error);
XCTAssertEqual([enabledNum boolValue], expectEnabled);
}
}
- (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
@ -1280,94 +1196,6 @@
error = nil;
XCTAssertFalse([session disableSyncForIdentity:notMe error:&error]);
XCTAssertNotNil(error);
error = nil;
XCTAssertNil([session queryKeySyncEnabledForIdentity:notMe error:&error]);
XCTAssertNotNil(error);
}
- (void)testEnableDisableSyncOnOwnIdentityWithQuery
{
PEPInternalSession *session = [PEPSessionProvider session];
PEPIdentity *identMe1 = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i@pep-project.org"
userID:@"me-myself-and-i"
userName:@"pEp Me"
isOwn:YES];
NSError *error = nil;
XCTAssertTrue([session mySelf:identMe1 error:&error]);
XCTAssertNil(error);
error = nil;
PEPIdentity *identMe2 = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i2@pep-project.org"
userID:@"me-myself-and-i2"
userName:@"pEp Me2"
isOwn:YES];
XCTAssertTrue([session mySelf:identMe2 error:&error]);
XCTAssertNil(error);
XCTAssertNotEqualObjects(identMe1.fingerPrint, identMe2.fingerPrint);
for (int i = 0; i < 10; ++i) {
error = nil;
BOOL enable = i % 2 == 0; // enable keysync on even numbers (roughly)
if (enable) {
XCTAssertTrue([session enableSyncForIdentity:identMe1 error:&error]);
XCTAssertTrue([session enableSyncForIdentity:identMe2 error:&error]);
} else {
XCTAssertTrue([session disableSyncForIdentity:identMe1 error:&error]);
XCTAssertTrue([session disableSyncForIdentity:identMe2 error:&error]);
}
XCTAssertNil(error);
NSNumber *keySyncState1 = [session queryKeySyncEnabledForIdentity:identMe1 error:&error];
NSNumber *keySyncState2 = [session queryKeySyncEnabledForIdentity:identMe2 error:&error];
XCTAssertNil(error);
XCTAssertNotNil(keySyncState1);
XCTAssertNotNil(keySyncState2);
if (enable) {
XCTAssertTrue([keySyncState1 boolValue]);
} else {
XCTAssertFalse([keySyncState1 boolValue]);
}
XCTAssertEqualObjects(keySyncState1, keySyncState2);
}
}
/**
ENGINE-604, just in case.
*/
- (void)testQueryKeySyncOnOwnIdentityInALoop
{
PEPInternalSession *session = [PEPSessionProvider session];
PEPIdentity *identMe = [[PEPIdentity alloc]
initWithAddress:@"me-myself-and-i@pep-project.org"
userID:@"me-myself-and-i"
userName:@"pEp Me"
isOwn:YES];
NSError *error = nil;
XCTAssertTrue([session mySelf:identMe error:&error]);
XCTAssertNil(error);
for (NSNumber *numBool in @[@YES, @NO]) {
error = nil;
if ([numBool boolValue]) {
XCTAssertTrue([session enableSyncForIdentity:identMe error:&error]);
} else {
XCTAssertTrue([session disableSyncForIdentity:identMe error:&error]);
}
XCTAssertNil(error);
for (int i = 0; i < 10; ++i) {
NSNumber *numQuery = [session queryKeySyncEnabledForIdentity:identMe error:&error];
XCTAssertNotNil(numQuery);
XCTAssertEqualObjects(numBool, numQuery);
XCTAssertNil(error);
}
}
}
#pragma mark - Basic Passphrases


+ 0
- 72
pEpObjCTests/PEPSessionTest.m View File

@ -274,13 +274,6 @@
XCTAssertTrue([self disableSyncForIdentity:identMe error:&error]);
}
XCTAssertNil(error);
for (int i = 0; i < 10; ++i) {
NSNumber *numQuery = [self queryKeySyncEnabledForIdentity:identMe error:&error];
XCTAssertNotNil(numQuery);
XCTAssertEqualObjects(numBool, numQuery);
XCTAssertNil(error);
}
}
}
@ -380,48 +373,6 @@
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
@ -845,29 +796,6 @@
return result;
}
- (NSNumber * _Nullable)queryKeySyncEnabledForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block NSNumber *result = nil;
__block NSError *theError = nil;
[asyncSession queryKeySyncEnabledForIdentity:identity
errorCallback:^(NSError * _Nonnull error) {
result = nil;
theError = error;
[exp fulfill];
} successCallback:^(BOOL enabled) {
result = [NSNumber numberWithBool:enabled];
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)disableSyncForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{


Loading…
Cancel
Save