Skip to content

Commit

Permalink
fix: added test to verify isEncrypted from remote
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-shris committed Sep 24, 2024
1 parent b2de9dc commit c6e9552
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/at_functional_test/test/atclient_put_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:typed_data';

import 'package:at_client/at_client.dart';
import 'package:at_functional_test/src/config_util.dart';
import 'package:at_functional_test/src/sync_service.dart';
import 'package:test/test.dart';
import 'test_utils.dart';

Expand All @@ -19,15 +20,26 @@ void main() {
atClientManager.atClient.syncService.sync();
});

test('put method - create a key sharing to other atSign', () async {
test(
'put method - create a key sharing to other atSign and verify metadata isEncrypted from server',
() async {
var phoneKey = AtKey()
..key = 'phone'
..sharedWith = '@bob🛠';
..sharedWith = '@bob🛠'
..sharedBy = atSign;
var value = '+1 100 200 300';
var putResult = await atClientManager.atClient.put(phoneKey, value);
expect(putResult, true);
var getResult = await atClientManager.atClient.get(phoneKey);
expect(getResult.value, value);
expect(getResult.metadata?.isEncrypted, true);
await FunctionalTestSyncService.getInstance().syncData(
AtClientManager.getInstance().atClient.syncService,
syncOptions: SyncOptions()..key = phoneKey.toString());
// fetch the key from remote and verify isEncrypted
var getResultRemote = await atClientManager.atClient.get(phoneKey,
getRequestOptions: GetRequestOptions()..useRemoteAtServer = true);
expect(getResultRemote.metadata?.isEncrypted, true);
});

test(
Expand All @@ -50,6 +62,14 @@ void main() {
expect(getKeyStoreResult.data, value);
var getResult = await atClientManager.atClient.get(phoneKey);
expect(getResult.value, value);
expect(getResult.metadata?.isEncrypted, false);
await FunctionalTestSyncService.getInstance().syncData(
AtClientManager.getInstance().atClient.syncService,
syncOptions: SyncOptions()..key = phoneKey.toString());
// fetch the key from remote and verify isEncrypted
var getResultRemote = await atClientManager.atClient.get(phoneKey,
getRequestOptions: GetRequestOptions()..useRemoteAtServer = true);
expect(getResultRemote.metadata?.isEncrypted, false);
});

test('put method - create a public key', () async {
Expand Down

0 comments on commit c6e9552

Please sign in to comment.