Skip to content

Commit

Permalink
Apple: #635: Added test for temporary key expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
hvge committed Oct 8, 2024
1 parent 54e67bd commit 0cf4a7f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ public void onGetEciesEncryptorFailed(@NonNull Throwable t) {
assertNotNull(encryptor);
}

/*
@Test
public void testEciesTemporaryKeyExpiration() throws Exception {
// This test requires PAS configured for a very short temporary key lifespan.
Expand Down Expand Up @@ -587,5 +586,4 @@ public void onFetchEncryptionKeyFailed(@NonNull Throwable t) {
});
assertTrue(result);
}
*/
}
28 changes: 28 additions & 0 deletions proj-xcode/PowerAuth2IntegrationTests/PowerAuthSDKDefaultTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -1395,4 +1395,32 @@ - (void) testEncryptorCreation
XCTAssertNotNil(encryptor);
}


- (void) testTemporaryKeyExpiration
{
// This test requires PAS configured for a very short temporary key lifespan.
CHECK_TEST_CONFIG();

PowerAuthSdkActivation * activation = [_helper createActivation:YES];
if (!activation) {
return;
}

BOOL result = [[AsyncHelper synchronizeAsynchronousBlock:^(AsyncHelper *waiting) {
[_sdk fetchEncryptionKey:_helper.authPossessionWithKnowledge index:1000 callback:^(NSData * _Nullable encryptionKey, NSError * _Nullable error) {
[waiting reportCompletion:@(error == nil)];
}];
}] boolValue];
XCTAssertTrue(result);

[NSThread sleepForTimeInterval:15.0];

result = [[AsyncHelper synchronizeAsynchronousBlock:^(AsyncHelper *waiting) {
[_sdk fetchEncryptionKey:_helper.authPossessionWithKnowledge index:1000 callback:^(NSData * _Nullable encryptionKey, NSError * _Nullable error) {
[waiting reportCompletion:@(error == nil)];
}];
}] boolValue];
XCTAssertTrue(result);
}

@end

0 comments on commit 0cf4a7f

Please sign in to comment.