From fbb6244d14a3e6aa43104a455de0d90ede7bfdf7 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Fri, 15 Nov 2024 07:38:40 +0530 Subject: [PATCH 01/13] fix: Uptake public key hash changes --- .../src/notification/resource_manager.dart | 4 ++++ .../handler/abstract_update_verb_handler.dart | 6 ++++++ .../verb/handler/monitor_verb_handler.dart | 5 ++++- .../src/verb/handler/notify_verb_handler.dart | 7 +++++++ .../sync_progressive_verb_handler.dart | 21 +++++++++++++++---- .../test/sync_verb_test.dart | 11 ++++++++-- 6 files changed, 47 insertions(+), 7 deletions(-) diff --git a/packages/at_secondary_server/lib/src/notification/resource_manager.dart b/packages/at_secondary_server/lib/src/notification/resource_manager.dart index 43e018780..0487a13a5 100644 --- a/packages/at_secondary_server/lib/src/notification/resource_manager.dart +++ b/packages/at_secondary_server/lib/src/notification/resource_manager.dart @@ -227,6 +227,10 @@ class ResourceManager { commandBody = '${AtConstants.encryptingKeyName}:${atNotification.atMetadata!.encKeyName}:$commandBody'; } + if (atNotification.atMetadata!.pubKeyHash != null) { + commandBody = + '${AtConstants.sharedWithPublicKeyHash}:${atNotification.atMetadata!.pubKeyHash?.hash}:${AtConstants.sharedWithPublicKeyHashingAlgo}:${atNotification.atMetadata!.pubKeyHash?.hashingAlgo}:$commandBody'; + } if (atNotification.atMetadata!.pubKeyCS != null) { commandBody = '${AtConstants.sharedWithPublicKeyCheckSum}:${atNotification.atMetadata!.pubKeyCS}:$commandBody'; diff --git a/packages/at_secondary_server/lib/src/verb/handler/abstract_update_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/abstract_update_verb_handler.dart index d3aade830..3026e84b2 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/abstract_update_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/abstract_update_verb_handler.dart @@ -191,6 +191,12 @@ abstract class AbstractUpdateVerbHandler extends ChangeVerbHandler { verbParams[AtConstants.sharedKeyEncryptedEncryptingKeyName]; metadata.skeEncAlgo = verbParams[AtConstants.sharedKeyEncryptedEncryptingAlgo]; + if (verbParams[AtConstants.sharedWithPublicKeyHash] != null && + verbParams[AtConstants.sharedWithPublicKeyHashingAlgo] != null) { + metadata.pubKeyHash = PublicKeyHash( + verbParams[AtConstants.sharedWithPublicKeyHash]!, + verbParams[AtConstants.sharedWithPublicKeyHashingAlgo]!); + } updateParams.metadata = metadata; return updateParams; diff --git a/packages/at_secondary_server/lib/src/verb/handler/monitor_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/monitor_verb_handler.dart index 5d77a768f..3f79b7b82 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/monitor_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/monitor_verb_handler.dart @@ -138,6 +138,8 @@ class MonitorVerbHandler extends AbstractVerbHandler { "skeEncKeyName": atNotification.atMetadata?.skeEncKeyName, "skeEncAlgo": atNotification.atMetadata?.skeEncAlgo, "sharedKeyEnc": atNotification.atMetadata?.sharedKeyEnc, + "pubKeyHash": + jsonEncode(atNotification.atMetadata?.pubKeyHash?.toJson()) }; await _checkAndSend(notification); @@ -222,7 +224,8 @@ class Notification { "availableAt": atNotification.atMetadata?.availableAt.toString(), "expiresAt": (atNotification.atMetadata?.expiresAt ?? atNotification.expiresAt) - .toString() + .toString(), + 'pubKeyHash': jsonEncode(atNotification.atMetadata?.pubKeyHash?.toJson()) }; } diff --git a/packages/at_secondary_server/lib/src/verb/handler/notify_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/notify_verb_handler.dart index 2f7e10075..15fc6d1ca 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/notify_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/notify_verb_handler.dart @@ -358,6 +358,13 @@ class NotifyVerbHandler extends AbstractVerbHandler { if (verbParams[AtConstants.sharedWithPublicKeyCheckSum] != null) { atMetadata.pubKeyCS = verbParams[AtConstants.sharedWithPublicKeyCheckSum]; } + if (verbParams[AtConstants.sharedWithPublicKeyHash].isNotNullOrEmpty && + verbParams[AtConstants.sharedWithPublicKeyHashingAlgo] + .isNotNullOrEmpty) { + atMetadata.pubKeyHash = PublicKeyHash( + verbParams[AtConstants.sharedWithPublicKeyHash]!, + verbParams[AtConstants.sharedWithPublicKeyHashingAlgo]!); + } if (verbParams[AtConstants.encryptingKeyName] != null) { atMetadata.encKeyName = verbParams[AtConstants.encryptingKeyName]; } diff --git a/packages/at_secondary_server/lib/src/verb/handler/sync_progressive_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/sync_progressive_verb_handler.dart index 01149568a..34892761c 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/sync_progressive_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/sync_progressive_verb_handler.dart @@ -150,11 +150,24 @@ class SyncProgressiveVerbHandler extends AbstractVerbHandler { if (metaData == null) { return metaDataMap; } - metaData.toJson().forEach((key, value) { - if (value != null) { - metaDataMap[key] = value.toString(); + Iterator itr = metaData.toJson().entries.iterator; + while (itr.moveNext()) { + // The value of [AtConstants.sharedWithPublicKeyHash] stores a Map containing + // the hash value and the hashing algorithm used for hashing the data. + // For example, {"hash":"dummy_value", "hashingAlgo":"sha512"}. + // Using toString() will not allow convert this into a Map, which is necessary + // for constructing the PublicKeyHash type on the client side. + // Therefore, a JSON-encoded string is used here, and on the client side, + // "jsonDecode" will be used to retrieve the Map and build the PublicKeyHash instance. + if (itr.current.key == AtConstants.sharedWithPublicKeyHash && + itr.current.value != null) { + metaDataMap[itr.current.key] = jsonEncode(itr.current.value); + continue; + } + if (itr.current.value != null) { + metaDataMap[itr.current.key] = itr.current.value.toString(); } - }); + } return metaDataMap; } diff --git a/packages/at_secondary_server/test/sync_verb_test.dart b/packages/at_secondary_server/test/sync_verb_test.dart index bbae7fc34..0b1e9fc9f 100644 --- a/packages/at_secondary_server/test/sync_verb_test.dart +++ b/packages/at_secondary_server/test/sync_verb_test.dart @@ -2,6 +2,7 @@ import 'dart:collection'; import 'dart:convert'; import 'dart:io'; +import 'package:at_chops/at_chops.dart'; import 'package:at_commons/at_commons.dart'; import 'package:at_persistence_secondary_server/at_persistence_secondary_server.dart'; import 'package:at_secondary/src/connection/inbound/inbound_connection_impl.dart'; @@ -10,8 +11,8 @@ import 'package:at_secondary/src/utils/handler_util.dart'; import 'package:at_secondary/src/utils/secondary_util.dart'; import 'package:at_secondary/src/verb/handler/sync_progressive_verb_handler.dart'; import 'package:at_server_spec/at_verb_spec.dart'; -import 'package:test/test.dart'; import 'package:mocktail/mocktail.dart'; +import 'package:test/test.dart'; import 'test_utils.dart'; @@ -115,7 +116,10 @@ void main() { ..ttb = 1000 ..ttr = 100 ..isBinary = false - ..encoding = 'base64')); + ..encoding = 'base64' + ..pubKeyHash = + PublicKeyHash('dummy_hash', HashingAlgoType.sha512.name) + ..pubKeyCS = 'dummy_pub_key_cs')); verbHandler = SyncProgressiveVerbHandler(keyStoreManager.getKeyStore()); var response = Response(); @@ -136,6 +140,9 @@ void main() { expect(syncResponseMap['metadata']['ttr'], '100'); expect(syncResponseMap['metadata']['isBinary'], 'false'); expect(syncResponseMap['metadata']['encoding'], 'base64'); + expect(syncResponseMap['metadata']['pubKeyCS'], 'dummy_pub_key_cs'); + expect(syncResponseMap['metadata']['pubKeyHash'], + '{"hash":"dummy_hash","hashingAlgo":"sha512"}'); }); when(() => mockKeyStore.isKeyExists(any())).thenReturn(true); From db951945bc82a51826ce919adef69cdcd4c49e1f Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Tue, 26 Nov 2024 15:12:15 +0530 Subject: [PATCH 02/13] fix: Add dependency_overrides in the pubspec.yaml --- packages/at_secondary_server/pubspec.yaml | 17 ++++++++++++----- tests/at_end2end_test/pubspec.yaml | 8 ++++++++ tests/at_functional_test/pubspec.yaml | 11 +++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/packages/at_secondary_server/pubspec.yaml b/packages/at_secondary_server/pubspec.yaml index 9df107fb2..a98ec49ed 100644 --- a/packages/at_secondary_server/pubspec.yaml +++ b/packages/at_secondary_server/pubspec.yaml @@ -9,7 +9,7 @@ environment: sdk: '>=3.0.0 <4.0.0' dependencies: - args: 2.5.0 + args: 2.6.0 uuid: 3.0.7 convert: 3.1.1 cron: 0.5.1 @@ -19,9 +19,9 @@ dependencies: basic_utils: 5.7.0 ecdsa: 0.1.0 encrypt: 5.0.3 - at_commons: 5.0.1 + at_commons: 5.0.2 at_utils: 3.0.19 - at_chops: 2.0.1 + at_chops: 2.2.0 at_lookup: 3.0.49 at_server_spec: 5.0.2 at_persistence_spec: 2.0.14 @@ -29,14 +29,21 @@ dependencies: intl: ^0.19.0 json_annotation: ^4.8.0 version: 3.0.2 - meta: 1.15.0 + meta: 1.16.0 mutex: 3.1.0 yaml: 3.1.2 logging: 1.2.0 +dependency_overrides: + at_persistence_secondary_server: + git: + url: https://github.com/atsign-foundation/at_server.git + path: packages/at_persistence_secondary_server + ref: 2121-uptake-public-key-hash-at-persistence_secondary-server + dev_dependencies: build_runner: ^2.3.3 - test: ^1.24.4 + test: ^1.25.8 coverage: ^1.6.1 lints: ^5.0.0 mocktail: ^1.0.3 diff --git a/tests/at_end2end_test/pubspec.yaml b/tests/at_end2end_test/pubspec.yaml index d8b2fb94d..3cc07a4e2 100644 --- a/tests/at_end2end_test/pubspec.yaml +++ b/tests/at_end2end_test/pubspec.yaml @@ -11,6 +11,14 @@ dependencies: at_demo_data: ^1.0.3 at_lookup: ^3.0.48 + +dependency_overrides: + at_persistence_secondary_server: + git: + url: https://github.com/atsign-foundation/at_server.git + path: packages/at_persistence_secondary_server + ref: 2121-uptake-public-key-hash-at-persistence_secondary-server + dev_dependencies: lints: ^1.0.1 test: ^1.14.4 diff --git a/tests/at_functional_test/pubspec.yaml b/tests/at_functional_test/pubspec.yaml index 3bb74939e..c09b93f62 100644 --- a/tests/at_functional_test/pubspec.yaml +++ b/tests/at_functional_test/pubspec.yaml @@ -9,12 +9,19 @@ environment: dependencies: hex: ^0.2.0 at_demo_data: ^1.1.0 - at_chops: ^2.0.0 + at_chops: ^2.2.0 at_lookup: ^3.0.48 - at_commons: ^4.1.2 + at_commons: ^5.0.2 uuid: ^3.0.7 elliptic: ^0.3.8 +dependency_overrides: + at_persistence_secondary_server: + git: + url: https://github.com/atsign-foundation/at_server.git + path: packages/at_persistence_secondary_server + ref: 2121-uptake-public-key-hash-at-persistence_secondary-server + dev_dependencies: lints: ^4.0.0 test: ^1.25.8 From 8182577b6d4ba0be75dca69f5210bc194f186890 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Wed, 27 Nov 2024 11:31:57 +0530 Subject: [PATCH 03/13] fix: Add functional test to verify publicKeyHash is set in metadata by sync verb --- .../test/sync_verb_test.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/at_functional_test/test/sync_verb_test.dart b/tests/at_functional_test/test/sync_verb_test.dart index 98a1ed35f..062889bac 100644 --- a/tests/at_functional_test/test/sync_verb_test.dart +++ b/tests/at_functional_test/test/sync_verb_test.dart @@ -70,6 +70,26 @@ void main() { assert((response.contains('Invalid syntax'))); }); + test('A test to verify publicKeyHash in set in sync response', () async { + String namespace = '.func.test'; + String randomId = Uuid().v4(); + + var response = await firstAtSignConnection.sendRequestToServer( + 'update:pubKeyHash:dummy_hash:hashingAlgo:sha512:$secondAtSign:twitter-$randomId$namespace$firstAtSign bob_tweet'); + assert( + (!response.contains('Invalid syntax')) && (!response.contains('null'))); + String commitId = response.replaceAll('data:', ''); + int syncId = int.parse(commitId); + // sync with regex + response = await firstAtSignConnection + .sendRequestToServer('sync:from:${syncId - 1}:limit:5:$namespace'); + response = response.replaceAll('data:', ''); + var responseMap = jsonDecode(response); + var publicKeyHashMap = jsonDecode(responseMap[0]['metadata']['pubKeyHash']); + expect(publicKeyHashMap['hash'], 'dummy_hash'); + expect(publicKeyHashMap['hashingAlgo'], 'sha512'); + }); + group('A group of tests to verify sync entries', () { late OutboundConnectionFactory authenticatedSocket = OutboundConnectionFactory(); From 65940f551364d4339d4b71104bbc075a752e4c49 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Wed, 27 Nov 2024 15:14:12 +0530 Subject: [PATCH 04/13] fix: Add E2E test to verify publicKeyHash --- tests/at_end2end_test/pubspec.yaml | 5 +-- .../test/lookup_verb_test.dart | 32 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/at_end2end_test/pubspec.yaml b/tests/at_end2end_test/pubspec.yaml index 3cc07a4e2..d0b68e4ab 100644 --- a/tests/at_end2end_test/pubspec.yaml +++ b/tests/at_end2end_test/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: encrypt: 5.0.3 at_demo_data: ^1.0.3 at_lookup: ^3.0.48 + uuid: ^3.0.7 dependency_overrides: @@ -20,6 +21,6 @@ dependency_overrides: ref: 2121-uptake-public-key-hash-at-persistence_secondary-server dev_dependencies: - lints: ^1.0.1 - test: ^1.14.4 + lints: ^5.0.0 + test: ^1.25.8 version: ^3.0.2 diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index 831f03498..15eb954ac 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -1,6 +1,9 @@ +import 'dart:convert'; import 'dart:math'; import 'package:test/test.dart'; +import 'package:uuid/uuid.dart'; +import 'package:version/version.dart'; import 'e2e_test_utils.dart' as e2e; @@ -46,4 +49,33 @@ void main() { print('lookup verb response : $response'); expect(response, contains('data:$value')); }, timeout: Timeout(Duration(minutes: 3))); + + test('A test to verify lookup metadata contains public key hash value', + () async { + Version atSign1ServerVersion = Version.parse(await sh1.getVersion()); + if (atSign1ServerVersion < Version(3, 0, 52)) { + print( + 'Found server version: $atSign1ServerVersion. This test is only applicable for server version greater than 3.0.52. Skipping the test'); + return; + } + var lastValue = Random().nextInt(5); + var randomHashValue = Uuid().v4().hashCode; + var value = 'Q7878R$lastValue'; + await sh1.writeCommand( + 'update:pubKeyHash:hashedValue-$randomHashValue:hashingAlgo:sha512:$atSign_2:special-code$atSign_1 $value'); + String response = await sh1.read(); + assert( + (!response.contains('Invalid syntax')) && (!response.contains('null'))); + + ///lookup verb alice atsign + await sh2.writeCommand('lookup:all:special-code$atSign_1'); + response = await sh2.read(timeoutMillis: 4000); + response = response.replaceAll('data:', ''); + var decodedResponse = jsonDecode(response); + expect(decodedResponse['key'], '@bob🛠:special-code@alice🛠'); + expect(decodedResponse['metaData']['pubKeyHash']['hash'], + 'hashedValue-$randomHashValue'); + expect(decodedResponse['metaData']['pubKeyHash']['hashingAlgo'], 'sha512'); + expect(decodedResponse['data'], value); + }); } From 2d4223cf10e502d40caeb34f9f16b0fb2449b898 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Wed, 27 Nov 2024 15:20:57 +0530 Subject: [PATCH 05/13] fix: Remove hard coded atSign from E2E test to verify publicKeyHash --- tests/at_end2end_test/test/lookup_verb_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index 15eb954ac..7df6c9685 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -72,7 +72,7 @@ void main() { response = await sh2.read(timeoutMillis: 4000); response = response.replaceAll('data:', ''); var decodedResponse = jsonDecode(response); - expect(decodedResponse['key'], '@bob🛠:special-code@alice🛠'); + expect(decodedResponse['key'], '$atSign_2:special-code$atSign_1'); expect(decodedResponse['metaData']['pubKeyHash']['hash'], 'hashedValue-$randomHashValue'); expect(decodedResponse['metaData']['pubKeyHash']['hashingAlgo'], 'sha512'); From 25b567f22d6d7aba2172d6078c5c6e08068d4c75 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Wed, 27 Nov 2024 15:36:48 +0530 Subject: [PATCH 06/13] fix: Add version check for second atSign --- tests/at_end2end_test/test/lookup_verb_test.dart | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index 7df6c9685..97a18b5de 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -55,7 +55,13 @@ void main() { Version atSign1ServerVersion = Version.parse(await sh1.getVersion()); if (atSign1ServerVersion < Version(3, 0, 52)) { print( - 'Found server version: $atSign1ServerVersion. This test is only applicable for server version greater than 3.0.52. Skipping the test'); + 'Found $atSign_1 with server version: $atSign1ServerVersion. This test is only applicable for server version greater than 3.0.52. Skipping the test'); + return; + } + Version atSign2ServerVersion = Version.parse(await sh2.getVersion()); + if (atSign2ServerVersion < Version(3, 0, 52)) { + print( + 'Found $atSign_2 with server version: $atSign2ServerVersion. This test is only applicable for server version greater than 3.0.52. Skipping the test'); return; } var lastValue = Random().nextInt(5); From a8656d95a06bdab55cbd1e5f631097021bf49865 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Wed, 27 Nov 2024 16:04:19 +0530 Subject: [PATCH 07/13] fix: Skip publicKeyHash E2E test --- tests/at_end2end_test/test/lookup_verb_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index 97a18b5de..a7c6d3af9 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -83,5 +83,5 @@ void main() { 'hashedValue-$randomHashValue'); expect(decodedResponse['metaData']['pubKeyHash']['hashingAlgo'], 'sha512'); expect(decodedResponse['data'], value); - }); + }, skip: 'Skip untill the changes are merged to trunk'); } From 0eb9ca3b71848258a0b7c82e5c99cebdf2904ebe Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Wed, 27 Nov 2024 16:44:39 +0530 Subject: [PATCH 08/13] fix: Add randomId to have unique keys on each run --- tests/at_end2end_test/test/lookup_verb_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index a7c6d3af9..1c8087ea6 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -37,14 +37,16 @@ void main() { ///Update verb on bob atsign var lastValue = Random().nextInt(5); var value = 'Q7878R$lastValue'; - await sh1.writeCommand('update:$atSign_2:special-code$atSign_1 $value'); + var randomId = Uuid().v4(); + await sh1.writeCommand( + 'update:$atSign_2:special-code-$randomId$atSign_1 $value'); String response = await sh1.read(); print('update verb response : $response'); assert( (!response.contains('Invalid syntax')) && (!response.contains('null'))); ///lookup verb alice atsign - await sh2.writeCommand('lookup:special-code$atSign_1'); + await sh2.writeCommand('lookup:special-code-$randomId$atSign_1'); response = await sh2.read(timeoutMillis: 4000); print('lookup verb response : $response'); expect(response, contains('data:$value')); From 24194dcd1df871cb6c00d1840f8f13392880735f Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Wed, 27 Nov 2024 16:52:36 +0530 Subject: [PATCH 09/13] fix: Remove the skip tag --- tests/at_end2end_test/test/lookup_verb_test.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index 1c8087ea6..27df0a078 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -70,20 +70,21 @@ void main() { var randomHashValue = Uuid().v4().hashCode; var value = 'Q7878R$lastValue'; await sh1.writeCommand( - 'update:pubKeyHash:hashedValue-$randomHashValue:hashingAlgo:sha512:$atSign_2:special-code$atSign_1 $value'); + 'update:pubKeyHash:hashedValue-$randomHashValue:hashingAlgo:sha512:$atSign_2:special-code-$randomHashValue$atSign_1 $value'); String response = await sh1.read(); assert( (!response.contains('Invalid syntax')) && (!response.contains('null'))); ///lookup verb alice atsign - await sh2.writeCommand('lookup:all:special-code$atSign_1'); + await sh2.writeCommand('lookup:all:special-code-$randomHashValue$atSign_1'); response = await sh2.read(timeoutMillis: 4000); response = response.replaceAll('data:', ''); var decodedResponse = jsonDecode(response); - expect(decodedResponse['key'], '$atSign_2:special-code$atSign_1'); + expect(decodedResponse['key'], + '$atSign_2:special-code-$randomHashValue$atSign_1'); expect(decodedResponse['metaData']['pubKeyHash']['hash'], 'hashedValue-$randomHashValue'); expect(decodedResponse['metaData']['pubKeyHash']['hashingAlgo'], 'sha512'); expect(decodedResponse['data'], value); - }, skip: 'Skip untill the changes are merged to trunk'); + }); } From 4fb2928c5ec5f0a3c3eb7c8c4ddee9966f373636 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Thu, 5 Dec 2024 20:45:38 +0530 Subject: [PATCH 10/13] fix: Update the server version to fix th E2E test --- tests/at_end2end_test/test/lookup_verb_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index 27df0a078..dc9be531e 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -55,13 +55,13 @@ void main() { test('A test to verify lookup metadata contains public key hash value', () async { Version atSign1ServerVersion = Version.parse(await sh1.getVersion()); - if (atSign1ServerVersion < Version(3, 0, 52)) { + if (atSign1ServerVersion < Version(3, 1, 0)) { print( 'Found $atSign_1 with server version: $atSign1ServerVersion. This test is only applicable for server version greater than 3.0.52. Skipping the test'); return; } Version atSign2ServerVersion = Version.parse(await sh2.getVersion()); - if (atSign2ServerVersion < Version(3, 0, 52)) { + if (atSign2ServerVersion < Version(3, 1, 0)) { print( 'Found $atSign_2 with server version: $atSign2ServerVersion. This test is only applicable for server version greater than 3.0.52. Skipping the test'); return; From 79d45da6b0c997e1d8ea8ccae6f1cd3ebacc7d5f Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Mon, 9 Dec 2024 16:47:53 +0530 Subject: [PATCH 11/13] fix: Update the server version in the E2E test log. --- tests/at_end2end_test/test/lookup_verb_test.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index dc9be531e..67237dbc1 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -57,13 +57,13 @@ void main() { Version atSign1ServerVersion = Version.parse(await sh1.getVersion()); if (atSign1ServerVersion < Version(3, 1, 0)) { print( - 'Found $atSign_1 with server version: $atSign1ServerVersion. This test is only applicable for server version greater than 3.0.52. Skipping the test'); + 'Found $atSign_1 with server version: $atSign1ServerVersion. This test is only applicable for server version greater than 3.1.0. Skipping the test'); return; } Version atSign2ServerVersion = Version.parse(await sh2.getVersion()); if (atSign2ServerVersion < Version(3, 1, 0)) { print( - 'Found $atSign_2 with server version: $atSign2ServerVersion. This test is only applicable for server version greater than 3.0.52. Skipping the test'); + 'Found $atSign_2 with server version: $atSign2ServerVersion. This test is only applicable for server version greater than 3.1.0. Skipping the test'); return; } var lastValue = Random().nextInt(5); From c3c23214ddf87de96a3397963bf64eb3a74ffa86 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Mon, 9 Dec 2024 22:42:30 +0530 Subject: [PATCH 12/13] fix: Update the version to 3.1.1 --- packages/at_secondary_server/CHANGELOG.md | 2 ++ packages/at_secondary_server/pubspec.yaml | 2 +- tests/at_end2end_test/test/lookup_verb_test.dart | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/at_secondary_server/CHANGELOG.md b/packages/at_secondary_server/CHANGELOG.md index 58e639b7c..2b155b113 100644 --- a/packages/at_secondary_server/CHANGELOG.md +++ b/packages/at_secondary_server/CHANGELOG.md @@ -1,3 +1,5 @@ +# 3.1.1 +- fix: Store "publicKeyHash" value in the keystore # 3.1.0 - feat: sync skip deletes until changes - fix: Enable persistence of the Initialization Vector for "defaultEncryptionPrivateKey" and "selfEncryptionKey" in diff --git a/packages/at_secondary_server/pubspec.yaml b/packages/at_secondary_server/pubspec.yaml index fc4553d6b..1aa03443d 100644 --- a/packages/at_secondary_server/pubspec.yaml +++ b/packages/at_secondary_server/pubspec.yaml @@ -1,6 +1,6 @@ name: at_secondary description: Implementation of secondary server. -version: 3.1.0 +version: 3.1.1 repository: https://github.com/atsign-foundation/at_server homepage: https://www.example.com publish_to: none diff --git a/tests/at_end2end_test/test/lookup_verb_test.dart b/tests/at_end2end_test/test/lookup_verb_test.dart index 67237dbc1..14dc155d1 100644 --- a/tests/at_end2end_test/test/lookup_verb_test.dart +++ b/tests/at_end2end_test/test/lookup_verb_test.dart @@ -55,15 +55,15 @@ void main() { test('A test to verify lookup metadata contains public key hash value', () async { Version atSign1ServerVersion = Version.parse(await sh1.getVersion()); - if (atSign1ServerVersion < Version(3, 1, 0)) { + if (atSign1ServerVersion < Version(3, 1, 1)) { print( - 'Found $atSign_1 with server version: $atSign1ServerVersion. This test is only applicable for server version greater than 3.1.0. Skipping the test'); + 'Found $atSign_1 with server version: $atSign1ServerVersion. This test is only applicable for server version least 3.1.1. Skipping the test'); return; } Version atSign2ServerVersion = Version.parse(await sh2.getVersion()); - if (atSign2ServerVersion < Version(3, 1, 0)) { + if (atSign2ServerVersion < Version(3, 1, 1)) { print( - 'Found $atSign_2 with server version: $atSign2ServerVersion. This test is only applicable for server version greater than 3.1.0. Skipping the test'); + 'Found $atSign_2 with server version: $atSign2ServerVersion. This test is only applicable for server version least 3.1.1. Skipping the test'); return; } var lastValue = Random().nextInt(5); From 7ce9aea8d43679ad759be8499a90a62c697f3304 Mon Sep 17 00:00:00 2001 From: Sitaram Kalluri Date: Tue, 10 Dec 2024 07:41:54 +0530 Subject: [PATCH 13/13] fix: Replace not null check with isNotNullOrEmpty --- .../lib/src/verb/handler/abstract_update_verb_handler.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/at_secondary_server/lib/src/verb/handler/abstract_update_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/abstract_update_verb_handler.dart index 3026e84b2..1e53d6aeb 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/abstract_update_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/abstract_update_verb_handler.dart @@ -191,8 +191,9 @@ abstract class AbstractUpdateVerbHandler extends ChangeVerbHandler { verbParams[AtConstants.sharedKeyEncryptedEncryptingKeyName]; metadata.skeEncAlgo = verbParams[AtConstants.sharedKeyEncryptedEncryptingAlgo]; - if (verbParams[AtConstants.sharedWithPublicKeyHash] != null && - verbParams[AtConstants.sharedWithPublicKeyHashingAlgo] != null) { + if (verbParams[AtConstants.sharedWithPublicKeyHash].isNotNullOrEmpty && + verbParams[AtConstants.sharedWithPublicKeyHashingAlgo] + .isNotNullOrEmpty) { metadata.pubKeyHash = PublicKeyHash( verbParams[AtConstants.sharedWithPublicKeyHash]!, verbParams[AtConstants.sharedWithPublicKeyHashingAlgo]!);