Skip to content

Commit

Permalink
fix: Modify existing functional tests to assert on publicKeyHash
Browse files Browse the repository at this point in the history
  • Loading branch information
sitaram-kalluri committed Dec 12, 2024
1 parent 181c955 commit bc3ed75
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/at_client/lib/src/response/at_notification.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion packages/at_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/at_client/test/encryption_decryption_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void main() {
atEncryptionKeyPair.atPublicKey.publicKey);
});

tearDown(() {
tearDownAll(() {
Directory('test/unit_test_storage').deleteSync(recursive: true);
});

Expand Down
6 changes: 5 additions & 1 deletion tests/at_functional_test/test/atclient_sharedkey_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -43,13 +45,15 @@ 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()
.syncData(atClientManager.atClient.syncService);
var metadata = await atClient.getMeta(phoneKey);
expect(metadata?.sharedKeyEnc, isNotEmpty);
expect(metadata?.pubKeyCS, isNotEmpty);
expect(metadata?.pubKeyHash?.hash, isNotEmpty);
expect(metadata?.pubKeyHash?.hashingAlgo, isNotEmpty);
});
}

0 comments on commit bc3ed75

Please sign in to comment.