From 0cf4a7f3d03e06f27a2a5f478f656b417e028570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraj=20=C4=8Eurech?= Date: Tue, 8 Oct 2024 17:17:09 +0200 Subject: [PATCH] Apple: #635: Added test for temporary key expiration --- .../tests/StandardActivationTest.java | 2 -- .../PowerAuthSDKDefaultTests.m | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/tests/StandardActivationTest.java b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/tests/StandardActivationTest.java index 232b3c18..38fe9897 100644 --- a/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/tests/StandardActivationTest.java +++ b/proj-android/PowerAuthLibrary/src/androidTest/java/io/getlime/security/powerauth/integration/tests/StandardActivationTest.java @@ -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. @@ -587,5 +586,4 @@ public void onFetchEncryptionKeyFailed(@NonNull Throwable t) { }); assertTrue(result); } - */ } diff --git a/proj-xcode/PowerAuth2IntegrationTests/PowerAuthSDKDefaultTests.m b/proj-xcode/PowerAuth2IntegrationTests/PowerAuthSDKDefaultTests.m index 18c100a7..aa4b0bbd 100644 --- a/proj-xcode/PowerAuth2IntegrationTests/PowerAuthSDKDefaultTests.m +++ b/proj-xcode/PowerAuth2IntegrationTests/PowerAuthSDKDefaultTests.m @@ -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