IOSAD-172 Test timeout IOSAD-172
authorDirk Zimmermann <dz@pep.security>
Fri, 26 Jun 2020 16:54:34 +0200
branchIOSAD-172
changeset 14711b27ba747985
parent 1470 f6c4020bf409
child 1472 5127b205711e
IOSAD-172 Test timeout
pEpObjCTests/PEPPassphraseCacheTest.m
     1.1 --- a/pEpObjCTests/PEPPassphraseCacheTest.m	Fri Jun 26 16:54:34 2020 +0200
     1.2 +++ b/pEpObjCTests/PEPPassphraseCacheTest.m	Fri Jun 26 16:54:34 2020 +0200
     1.3 @@ -9,6 +9,7 @@
     1.4  #import <XCTest/XCTest.h>
     1.5  
     1.6  #import "PEPPassphraseCache.h"
     1.7 +#import "PEPPassphraseCacheInternal.h"
     1.8  
     1.9  @interface PEPPassphraseCacheTest : XCTestCase
    1.10  
    1.11 @@ -86,4 +87,19 @@
    1.12      XCTAssertEqualObjects(self.cache.passphrases, expected);
    1.13  }
    1.14  
    1.15 +- (void)testTimeout
    1.16 +{
    1.17 +    NSTimeInterval timeout = 0.5;
    1.18 +    PEPPassphraseCache *ownCache = [[PEPPassphraseCache alloc] initWithTimeout:timeout];
    1.19 +
    1.20 +    NSString *ownPassphrase = @"blah";
    1.21 +    [ownCache addPassphrase:ownPassphrase];
    1.22 +
    1.23 +    NSArray *expectedBefore = @[@"", ownPassphrase];
    1.24 +    XCTAssertEqualObjects(ownCache.passphrases, expectedBefore);
    1.25 +
    1.26 +    [NSThread sleepForTimeInterval:timeout];
    1.27 +    XCTAssertEqualObjects(ownCache.passphrases, @[@""]);
    1.28 +}
    1.29 +
    1.30  @end