Browse Source

IOSAD-206 Add XCTestCase+PEPSession (project)

IOSAD-206
Dirk Zimmermann 1 year ago
parent
commit
48feeb1f30
3 changed files with 693 additions and 0 deletions
  1. +6
    -0
      pEpObjCAdapter.xcodeproj/project.pbxproj
  2. +108
    -0
      pEpObjCTests/TestUtils/XCTestCase+PEPSession.h
  3. +579
    -0
      pEpObjCTests/TestUtils/XCTestCase+PEPSession.m

+ 6
- 0
pEpObjCAdapter.xcodeproj/project.pbxproj View File

@ -191,6 +191,7 @@
4396CEB82187196600FDD398 /* PEPInternalSessionTestNotifyHandshakeDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4396CEB62187190F00FDD398 /* PEPInternalSessionTestNotifyHandshakeDelegate.m */; };
4396CECB2187220200FDD398 /* PEPInternalSessionTestSendMessageDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4396CEC8218721F900FDD398 /* PEPInternalSessionTestSendMessageDelegate.m */; };
43D2D5D72632A73D00088BDC /* PEPInternalSession+SetIdentity.m in Sources */ = {isa = PBXBuildFile; fileRef = 43D2D5D62632A73D00088BDC /* PEPInternalSession+SetIdentity.m */; };
43D2D5F12632B0FA00088BDC /* XCTestCase+PEPSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 43D2D5F02632B0FA00088BDC /* XCTestCase+PEPSession.m */; };
43E02A201C71F65B008F05E9 /* A3FC7F0A_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1C1C71F65B008F05E9 /* A3FC7F0A_sec.asc */; };
43E02A211C71F65B008F05E9 /* A3FC7F0A.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43E02A1D1C71F65B008F05E9 /* A3FC7F0A.asc */; };
4E58698325BF2FA900779EAD /* PEPMessage+SecureCoding.h in Headers */ = {isa = PBXBuildFile; fileRef = 4E58698125BF2FA900779EAD /* PEPMessage+SecureCoding.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -441,6 +442,8 @@
43AD0E2F22E99ECE00D46F56 /* PEPInternalConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPInternalConstants.m; sourceTree = "<group>"; };
43D2D5D42632A73D00088BDC /* PEPInternalSession+SetIdentity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "PEPInternalSession+SetIdentity.h"; sourceTree = "<group>"; };
43D2D5D62632A73D00088BDC /* PEPInternalSession+SetIdentity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "PEPInternalSession+SetIdentity.m"; sourceTree = "<group>"; };
43D2D5EE2632B0FA00088BDC /* XCTestCase+PEPSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCTestCase+PEPSession.h"; sourceTree = "<group>"; };
43D2D5F02632B0FA00088BDC /* XCTestCase+PEPSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCTestCase+PEPSession.m"; sourceTree = "<group>"; };
43DED784203C25E200D45CD6 /* NSError+PEP.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSError+PEP.h"; sourceTree = "<group>"; };
43DED785203C25E200D45CD6 /* NSError+PEP.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSError+PEP.m"; sourceTree = "<group>"; };
43E02A1C1C71F65B008F05E9 /* A3FC7F0A_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = A3FC7F0A_sec.asc; sourceTree = "<group>"; };
@ -640,6 +643,8 @@
15D3D762200F6C6A00A0DA20 /* TestUtils */ = {
isa = PBXGroup;
children = (
43D2D5EE2632B0FA00088BDC /* XCTestCase+PEPSession.h */,
43D2D5F02632B0FA00088BDC /* XCTestCase+PEPSession.m */,
15D3D77B2010DDC500A0DA20 /* PEPTestUtils.h */,
15D3D77C2010DDC500A0DA20 /* PEPTestUtils.m */,
4396CEB52187190F00FDD398 /* PEPInternalSessionTestNotifyHandshakeDelegate.h */,
@ -1368,6 +1373,7 @@
4331CE94229C2AAF00DDDC65 /* PEPSizeTest.m in Sources */,
4396CECB2187220200FDD398 /* PEPInternalSessionTestSendMessageDelegate.m in Sources */,
434707F924C30E9700E05485 /* PEPSessionTest.m in Sources */,
43D2D5F12632B0FA00088BDC /* XCTestCase+PEPSession.m in Sources */,
152A9C472010F50400F962ED /* PEPInternalSessionTest.m in Sources */,
43D2D5D72632A73D00088BDC /* PEPInternalSession+SetIdentity.m in Sources */,
434226811D4F60000083ED79 /* PepTests.m in Sources */,


+ 108
- 0
pEpObjCTests/TestUtils/XCTestCase+PEPSession.h View File

@ -0,0 +1,108 @@
//
// XCTestCase+PEPSession.h
// pEpObjCAdapterTests
//
// Created by Dirk Zimmermann on 09.04.21.
// Copyright © 2021 pp. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
#import "PEPObjCAdapterTypes_iOS.h"
NS_ASSUME_NONNULL_BEGIN
@interface XCTestCase (PEPSession)
#pragma mark - Normal session to async
- (PEPRating)ratingForIdentity:(PEPIdentity *)identity;
- (PEPIdentity * _Nullable)mySelf:(PEPIdentity *)identity
error:(NSError * _Nullable * _Nullable)error;
- (NSArray<NSString *> * _Nullable)trustwordsForFingerprint:(NSString *)fingerprint
languageID:(NSString *)languageID
shortened:(BOOL)shortened
error:(NSError * _Nullable * _Nullable)error;
- (PEPIdentity * _Nullable)updateIdentity:(PEPIdentity *)identity
error:(NSError * _Nullable * _Nullable)error;
- (NSNumber * _Nullable)outgoingRatingForMessage:(PEPMessage *)theMessage
error:(NSError * _Nullable * _Nullable)error;
- (PEPMessage * _Nullable)encryptMessage:(PEPMessage *)message
extraKeys:(PEPStringList * _Nullable)extraKeys
encFormat:(PEPEncFormat)encFormat
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error;
- (PEPMessage * _Nullable)encryptMessage:(PEPMessage *)message
extraKeys:(PEPStringList * _Nullable)extraKeys
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)trustPersonalKey:(PEPIdentity *)identity
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)keyResetTrust:(PEPIdentity *)identity
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)keyMistrusted:(PEPIdentity *)identity error:(NSError * _Nullable * _Nullable)error;
- (BOOL)enableSyncForIdentity:(PEPIdentity *)identity
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)disableSyncForIdentity:(PEPIdentity *)identity
error:(NSError * _Nullable * _Nullable)error;
- (NSString * _Nullable)getLogWithError:(NSError * _Nullable * _Nullable)error;
- (NSString * _Nullable)getTrustwordsIdentity1:(PEPIdentity *)identity1
identity2:(PEPIdentity *)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
error:(NSError * _Nullable * _Nullable)error;
- (NSNumber * _Nullable)isPEPUser:(PEPIdentity *)identity
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)trustOwnKeyIdentity:(PEPIdentity *)identity
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)keyReset:(PEPIdentity *)identity
fingerprint:(NSString * _Nullable)fingerprint
error:(NSError * _Nullable * _Nullable)error;
#pragma mark - Group API
- (PEPGroup * _Nullable)groupCreateGroupIdentity:(PEPIdentity const *)groupIdentity
managerIdentity:(PEPIdentity const *)managerIdentity
memberIdentities:(NSArray<PEPIdentity const *> *)memberIdentities
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)groupJoinGroupIdentity:(PEPIdentity const *)groupIdentity
memberIdentity:(PEPIdentity const *)memberIdentity
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)groupDissolveGroupIdentity:(PEPIdentity const *)groupIdentity
managerIdentity:(PEPIdentity const *)managerIdentity
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)groupInviteMemberGroupIdentity:(PEPIdentity const *)groupIdentity
memberIdentity:(PEPIdentity const *)memberIdentity
error:(NSError * _Nullable * _Nullable)error;
- (BOOL)groupRemoveMemberGroupIdentity:(PEPIdentity const *)groupIdentity
memberIdentity:(PEPIdentity const *)memberIdentity
error:(NSError * _Nullable * _Nullable)error;
- (NSNumber * _Nullable)groupRatingGroupIdentity:(PEPIdentity const *)groupIdentity
managerIdentity:(PEPIdentity const *)managerIdentity
error:(NSError * _Nullable * _Nullable)error;
@end
NS_ASSUME_NONNULL_END

+ 579
- 0
pEpObjCTests/TestUtils/XCTestCase+PEPSession.m View File

@ -0,0 +1,579 @@
//
// XCTestCase+PEPSession.m
// pEpObjCAdapterTests
//
// Created by Dirk Zimmermann on 09.04.21.
// Copyright © 2021 pp. All rights reserved.
//
#import "XCTestCase+PEPSession.h"
#import "PEPObjCAdapter_iOS.h"
#import "PEPTestUtils.h"
#import "NSNumber+PEPRating.h"
@implementation XCTestCase (PEPSession)
#pragma mark - Normal session to async
- (PEPRating)ratingForIdentity:(PEPIdentity *)identity
{
PEPSession *asyncSession = [PEPSession new];
__block PEPRating resultingRating = PEPRatingB0rken;
XCTestExpectation *expRated = [self expectationWithDescription:@"expRated"];
[asyncSession ratingForIdentity:identity
errorCallback:^(NSError * _Nonnull error) {
XCTFail();
[expRated fulfill];
} successCallback:^(PEPRating rating) {
resultingRating = rating;
[expRated fulfill];
}];
[self waitForExpectations:@[expRated] timeout:PEPTestInternalSyncTimeout];
return resultingRating;
}
- (PEPIdentity * _Nullable)mySelf:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *expMyself = [self expectationWithDescription:@"expMyself"];
__block PEPIdentity *identityMyselfed = nil;
__block NSError *errorMyself = nil;
[asyncSession mySelf:identity
errorCallback:^(NSError * _Nonnull theError) {
errorMyself = theError;
[expMyself fulfill];
} successCallback:^(PEPIdentity * _Nonnull identity) {
identityMyselfed = identity;
[expMyself fulfill];
}];
[self waitForExpectations:@[expMyself] timeout:PEPTestInternalSyncTimeout];
*error = errorMyself;
XCTAssertNotNil(identityMyselfed);
if (error) {
*error = errorMyself;
}
return identityMyselfed;
}
- (NSArray<NSString *> * _Nullable)trustwordsForFingerprint:(NSString * _Nonnull)fingerprint
languageID:(NSString * _Nonnull)languageID
shortened:(BOOL)shortened
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block NSArray<NSString *> *result = nil;
__block NSError *theError = nil;
[asyncSession trustwordsForFingerprint:fingerprint
languageID:languageID
shortened:shortened
errorCallback:^(NSError * _Nonnull error) {
theError = error;
[exp fulfill];
} successCallback:^(NSArray<NSString *> * _Nonnull trustwords) {
[exp fulfill];
result = trustwords;
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (PEPIdentity * _Nullable)updateIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *expUpdateIdent = [self expectationWithDescription:@"expUpdateIdent"];
__block PEPIdentity *identTestUpdated = nil;
__block NSError *theError = nil;
[asyncSession updateIdentity:identity
errorCallback:^(NSError * _Nonnull error) {
theError = error;
[expUpdateIdent fulfill];
} successCallback:^(PEPIdentity * _Nonnull identity) {
identTestUpdated = identity;
[expUpdateIdent fulfill];
}];
[self waitForExpectations:@[expUpdateIdent] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return identTestUpdated;
}
- (NSNumber * _Nullable)outgoingRatingForMessage:(PEPMessage * _Nonnull)theMessage
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block NSNumber *result = nil;
__block NSError *theError = nil;
[asyncSession outgoingRatingForMessage:theMessage
errorCallback:^(NSError * _Nonnull error) {
theError = error;
[exp fulfill];
} successCallback:^(PEPRating rating) {
result = [NSNumber numberWithPEPRating:rating];
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
extraKeys:(PEPStringList * _Nullable)extraKeys
encFormat:(PEPEncFormat)encFormat
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block PEPMessage *result = nil;
__block NSError *theError = nil;
[asyncSession encryptMessage:message
extraKeys:extraKeys
encFormat:encFormat
errorCallback:^(NSError * _Nonnull error) {
theError = error;
[exp fulfill];
} successCallback:^(PEPMessage * _Nonnull srcMessage, PEPMessage * _Nonnull destMessage) {
result = destMessage;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (PEPMessage * _Nullable)encryptMessage:(PEPMessage * _Nonnull)message
extraKeys:(PEPStringList * _Nullable)extraKeys
status:(PEPStatus * _Nullable)status
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block PEPMessage *result = nil;
__block NSError *theError = nil;
[asyncSession encryptMessage:message
extraKeys:extraKeys
errorCallback:^(NSError * _Nonnull error) {
theError = error;
[exp fulfill];
} successCallback:^(PEPMessage * _Nonnull srcMessage, PEPMessage * _Nonnull destMessage) {
result = destMessage;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)trustPersonalKey:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession trustPersonalKey:identity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)keyResetTrust:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession keyResetTrust:identity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)keyMistrusted:(PEPIdentity *)identity error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession keyMistrusted:identity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)enableSyncForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession enableSyncForIdentity:identity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)disableSyncForIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession disableSyncForIdentity:identity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (NSString * _Nullable)getLogWithError:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block NSString *result = nil;
__block NSError *theError = nil;
[asyncSession getLog:^(NSError * _Nonnull error) {
result = nil;
theError = error;
[exp fulfill];
} successCallback:^(NSString *theLog) {
result = theLog;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (NSString * _Nullable)getTrustwordsIdentity1:(PEPIdentity * _Nonnull)identity1
identity2:(PEPIdentity * _Nonnull)identity2
language:(NSString * _Nullable)language
full:(BOOL)full
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block NSString *result = nil;
__block NSError *theError = nil;
[asyncSession getTrustwordsIdentity1:identity1
identity2:identity2
language:language
full:full
errorCallback:^(NSError * _Nonnull error) {
result = nil;
theError = error;
[exp fulfill];
} successCallback:^(NSString * _Nonnull trustwords) {
result = trustwords;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (NSNumber * _Nullable)isPEPUser:(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 isPEPUser: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)trustOwnKeyIdentity:(PEPIdentity * _Nonnull)identity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession trustOwnKeyIdentity:identity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)keyReset:(PEPIdentity * _Nonnull)identity
fingerprint:(NSString * _Nullable)fingerprint
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession keyReset:identity
fingerprint:fingerprint
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
#pragma mark - Group API
- (PEPGroup * _Nullable)groupCreateGroupIdentity:(PEPIdentity const *)groupIdentity
managerIdentity:(PEPIdentity const *)managerIdentity
memberIdentities:(NSArray<PEPIdentity const *> *)memberIdentities
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block PEPGroup *result = nil;
__block NSError *theError = nil;
[asyncSession groupCreateGroupIdentity:groupIdentity
managerIdentity:managerIdentity
memberIdentities:memberIdentities
errorCallback:^(NSError *error) {
theError = error;
[exp fulfill];
}
successCallback:^(PEPGroup *group) {
result = group;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)groupJoinGroupIdentity:(PEPIdentity const *)groupIdentity
memberIdentity:(PEPIdentity const *)memberIdentity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession groupJoinGroupIdentity:groupIdentity
memberIdentity:memberIdentity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)groupDissolveGroupIdentity:(PEPIdentity const *)groupIdentity
managerIdentity:(PEPIdentity const *)managerIdentity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession groupDissolveGroupIdentity:groupIdentity
managerIdentity:managerIdentity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)groupInviteMemberGroupIdentity:(PEPIdentity const *)groupIdentity
memberIdentity:(PEPIdentity const *)memberIdentity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession groupInviteMemberGroupIdentity:groupIdentity
memberIdentity:memberIdentity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (BOOL)groupRemoveMemberGroupIdentity:(PEPIdentity const *)groupIdentity
memberIdentity:(PEPIdentity const *)memberIdentity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block BOOL result = NO;
__block NSError *theError = nil;
[asyncSession groupRemoveMemberGroupIdentity:groupIdentity
memberIdentity:memberIdentity
errorCallback:^(NSError * _Nonnull error) {
result = NO;
theError = error;
[exp fulfill];
} successCallback:^{
result = YES;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
- (NSNumber * _Nullable)groupRatingGroupIdentity:(PEPIdentity const *)groupIdentity
managerIdentity:(PEPIdentity const *)managerIdentity
error:(NSError * _Nullable * _Nullable)error
{
PEPSession *asyncSession = [PEPSession new];
XCTestExpectation *exp = [self expectationWithDescription:@"exp"];
__block NSNumber *result = nil;
__block NSError *theError = nil;
[asyncSession groupRatingGroupIdentity:groupIdentity
managerIdentity:managerIdentity
errorCallback:^(NSError * _Nonnull error) {
result = nil;
theError = error;
[exp fulfill];
} successCallback:^(NSNumber *numRating) {
result = numRating;
[exp fulfill];
}];
[self waitForExpectations:@[exp] timeout:PEPTestInternalSyncTimeout];
if (error) {
*error = theError;
}
return result;
}
@end

Loading…
Cancel
Save