From bc3ed752e99f771623aab6998f93607b204f2763 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Thu, 12 Dec 2024 16:49:25 +0530 Subject: [PATCH] fix: Modify existing functional tests to assert on publicKeyHash --- packages/at_client/lib/src/response/at_notification.dart | 4 ++-- packages/at_client/pubspec.yaml | 2 +- packages/at_client/test/encryption_decryption_test.dart | 2 +- tests/at_functional_test/test/atclient_sharedkey_test.dart | 6 +++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/at_client/lib/src/response/at_notification.dart b/packages/at_client/lib/src/response/at_notification.dart index 0e1948088..9e14df2d2 100644 --- a/packages/at_client/lib/src/response/at_notification.dart +++ b/packages/at_client/lib/src/response/at_notification.dart @@ -38,8 +38,8 @@ class AtNotification { metadata.sharedKeyEnc = json['metadata'][AtConstants.sharedKeyEncrypted]; // AtContants.sharedWithPublicKeyHash will be sent by the server starting v3.0.52 // Notifications received from Secondary server before 3.0.52 does not contain - // AtConstants.sharedWithPublicKeyHash. Therefore, check for null. - if (json['metadata'][AtConstants.sharedWithPublicKeyHash] != null) { + // AtConstants.sharedWithPublicKeyHash. Therefore, check for null String. + if (json['metadata'][AtConstants.sharedWithPublicKeyHash] != "null") { var publicKeyHash = jsonDecode(json['metadata'][AtConstants.sharedWithPublicKeyHash]); metadata.pubKeyHash = diff --git a/packages/at_client/pubspec.yaml b/packages/at_client/pubspec.yaml index 0dc42d46f..99ceb8ec2 100644 --- a/packages/at_client/pubspec.yaml +++ b/packages/at_client/pubspec.yaml @@ -35,7 +35,7 @@ dependencies: at_utils: ^3.0.19 at_chops: ^2.2.0 at_lookup: ^3.0.49 - at_auth: ^2.0.8 + at_auth: ^2.0.10 at_persistence_spec: ^2.0.14 at_persistence_secondary_server: ^3.1.0 meta: ^1.8.0 diff --git a/packages/at_client/test/encryption_decryption_test.dart b/packages/at_client/test/encryption_decryption_test.dart index f91e12f79..58f6a4494 100644 --- a/packages/at_client/test/encryption_decryption_test.dart +++ b/packages/at_client/test/encryption_decryption_test.dart @@ -45,7 +45,7 @@ void main() { atEncryptionKeyPair.atPublicKey.publicKey); }); - tearDown(() { + tearDownAll(() { Directory('test/unit_test_storage').deleteSync(recursive: true); }); diff --git a/tests/at_functional_test/test/atclient_sharedkey_test.dart b/tests/at_functional_test/test/atclient_sharedkey_test.dart index e33f645d1..e8411d96a 100644 --- a/tests/at_functional_test/test/atclient_sharedkey_test.dart +++ b/tests/at_functional_test/test/atclient_sharedkey_test.dart @@ -30,6 +30,8 @@ void main() { var metadata = await atClient.getMeta(phoneKey); expect(metadata!.sharedKeyEnc, isNotEmpty); expect(metadata.pubKeyCS, isNotEmpty); + expect(metadata.pubKeyHash?.hash, isNotEmpty); + expect(metadata.pubKeyHash?.hashingAlgo, isNotEmpty); }); test('sharedKey and checksum metadata sync to local storage', () async { @@ -43,7 +45,7 @@ void main() { AtKeyEncryptionManager(atClient).get(phoneKey, currentAtSign); var encryptedValue = await encryptionService.encrypt(phoneKey, value); var result = await atClient.getRemoteSecondary()!.executeCommand( - 'update:sharedKeyEnc:${phoneKey.metadata.sharedKeyEnc}:pubKeyCS:${phoneKey.metadata.pubKeyCS}:${phoneKey.sharedWith}:${phoneKey.key}.$namespace$currentAtSign $encryptedValue\n', + 'update:sharedKeyEnc:${phoneKey.metadata.sharedKeyEnc}:pubKeyCS:${phoneKey.metadata.pubKeyCS}:pubKeyHash:${phoneKey.metadata.pubKeyHash?.hash}:hashingAlgo:${phoneKey.metadata.pubKeyHash?.hashingAlgo}:${phoneKey.sharedWith}:${phoneKey.key}.$namespace$currentAtSign $encryptedValue\n', auth: true); expect(result != null, true); await FunctionalTestSyncService.getInstance() @@ -51,5 +53,7 @@ void main() { var metadata = await atClient.getMeta(phoneKey); expect(metadata?.sharedKeyEnc, isNotEmpty); expect(metadata?.pubKeyCS, isNotEmpty); + expect(metadata?.pubKeyHash?.hash, isNotEmpty); + expect(metadata?.pubKeyHash?.hashingAlgo, isNotEmpty); }); }