IOSAD-25 test PEP_TRUSTWORDS_DUPLICATE_FPR with trustwords
authorDirk Zimmermann <dirk@pep-project.org>
Thu, 31 Aug 2017 15:29:46 +0200
changeset 213959a115bc0f7
parent 212 616a7f62fa60
child 214 ab77645073b3
child 220 3d7525bb2df1
IOSAD-25 test PEP_TRUSTWORDS_DUPLICATE_FPR with trustwords
pEpObjCAdapter/PEPSession.h
pEpObjCAdapter/PEPSession.m
pEpObjCTests/iOSTests.m
     1.1 --- a/pEpObjCAdapter/PEPSession.h	Thu Aug 31 14:27:08 2017 +0200
     1.2 +++ b/pEpObjCAdapter/PEPSession.h	Thu Aug 31 15:29:46 2017 +0200
     1.3 @@ -140,7 +140,8 @@
     1.4                                     receiverDict:(nonnull PEPDict *)receiverDict
     1.5                                        keysArray:(PEPStringList * _Nullable)keysArray
     1.6                                         language:(nullable NSString *)language
     1.7 -                                           full:(BOOL)full;
     1.8 +                                           full:(BOOL)full
     1.9 +                                resultingStatus:(PEP_STATUS * _Nullable)resultingStatus;
    1.10  
    1.11  /**
    1.12   @returns The list of supported languages for trustwords.
     2.1 --- a/pEpObjCAdapter/PEPSession.m	Thu Aug 31 14:27:08 2017 +0200
     2.2 +++ b/pEpObjCAdapter/PEPSession.m	Thu Aug 31 15:29:46 2017 +0200
     2.3 @@ -394,6 +394,7 @@
     2.4                                        keysArray:(PEPStringList * _Nullable)keysArray
     2.5                                         language:(nullable NSString *)language
     2.6                                             full:(BOOL)full
     2.7 +                                resultingStatus:(PEP_STATUS * _Nullable)resultingStatus
     2.8  {
     2.9      NSString *result = nil;
    2.10      char *trustwords = nil;
    2.11 @@ -412,6 +413,10 @@
    2.12                                                   precomposedStringWithCanonicalMapping] UTF8String],
    2.13                                                 &trustwords, full);
    2.14  
    2.15 +    if (resultingStatus) {
    2.16 +        *resultingStatus = status;
    2.17 +    }
    2.18 +
    2.19      if (status == PEP_STATUS_OK) {
    2.20          result = [NSString stringWithCString:trustwords
    2.21                                      encoding:NSUTF8StringEncoding];
     3.1 --- a/pEpObjCTests/iOSTests.m	Thu Aug 31 14:27:08 2017 +0200
     3.2 +++ b/pEpObjCTests/iOSTests.m	Thu Aug 31 15:29:46 2017 +0200
     3.3 @@ -1471,6 +1471,31 @@
     3.4      [self pEpCleanUp];
     3.5  }
     3.6  
     3.7 +- (void)testMessageTrustwordsWithMySelf
     3.8 +{
     3.9 +    [self pEpSetUp];
    3.10 +
    3.11 +    PEPStringList *keys = nil;
    3.12 +    PEPDict *decryptedDict = [self internalEncryptToMySelfKeys:&keys];
    3.13 +    XCTAssertNotNil(keys);
    3.14 +    XCTAssert(keys.count > 0);
    3.15 +
    3.16 +    PEPDict *receiver = decryptedDict[kPepTo][0];
    3.17 +    XCTAssertNotNil(receiver);
    3.18 +    PEP_STATUS trustwordsStatus;
    3.19 +    NSString *trustwords = [session getTrustwordsMessageDict:decryptedDict
    3.20 +                                                receiverDict:receiver
    3.21 +                                                   keysArray:keys language:@"en"
    3.22 +                                                        full:YES
    3.23 +                                             resultingStatus: &trustwordsStatus];
    3.24 +
    3.25 +    // No trustwords with yourself
    3.26 +    XCTAssertEqual(trustwordsStatus, PEP_TRUSTWORDS_DUPLICATE_FPR);
    3.27 +    XCTAssertNil(trustwords);
    3.28 +
    3.29 +    [self pEpCleanUp];
    3.30 +}
    3.31 +
    3.32  - (void)testGetTrustwords
    3.33  {
    3.34      [self pEpSetUp];