Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add optional param encryptValue to notify method #1391

Merged
merged 14 commits into from
Sep 13, 2024
Merged
43 changes: 43 additions & 0 deletions tests/at_end2end_test/test/notify_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,48 @@ void main() async {
expect(notificationListJson[0]['from'], currentAtSign);
expect(notificationListJson[0]['to'], sharedWithAtSign);
expect(notificationListJson[0]['value'], isNotEmpty);
expect(notificationListJson[0]['value'] != value,
true); //encrypted value should be different from actual value
});
test('Notify a key with value by setting encryptValue to false', () async {
var uuid = Uuid();
// Generate uuid
var randomValue = uuid.v4();
var phoneKey = AtKey()
..key = 'phone$randomValue'
..sharedWith = sharedWithAtSign
..metadata = (Metadata()..ttr = 60000)
..namespace = namespace;

// Appending a random number as a last number to generate a new phone number
// for each run.
var value = '+1 100 200 30';
// Setting currentAtSign atClient instance to context.
currentAtClientManager = await AtClientManager.getInstance()
.setCurrentAtSign(currentAtSign, namespace,
TestPreferences.getInstance().getPreference(currentAtSign));
final notificationResult = await currentAtClientManager
.atClient.notificationService
.notify(NotificationParams.forUpdate(phoneKey, value: value),
encryptValue: false);
expect(notificationResult, isNotNull);
expect(notificationResult.notificationStatusEnum,
NotificationStatusEnum.delivered);

// Setting sharedWithAtSign atClient instance to context.
await AtClientManager.getInstance().setCurrentAtSign(
sharedWithAtSign,
namespace,
TestPreferences.getInstance().getPreference(sharedWithAtSign));
var notificationListResult = await AtClientManager.getInstance()
.atClient
.notifyList(regex: 'phone$randomValue');
expect(notificationListResult, isNotEmpty);
notificationListResult = notificationListResult.replaceFirst('data:', '');
final notificationListJson = jsonDecode(notificationListResult);
print(notificationListJson);
expect(notificationListJson[0]['from'], currentAtSign);
expect(notificationListJson[0]['to'], sharedWithAtSign);
expect(notificationListJson[0]['value'], value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add an expect for isEncrypted please?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am getting isEncrypted=true for this test.
[{id: 79a2d96e-ff34-442c-aac0-97a556fcbcfc, from: @ce2e1, to: @ce2e2, key: @ce2e2:phone2a9c23ff-cb4c-4d41-a50d-276d87d24820.e2e_test@ce2e1, value: +1 100 200 30, operation: update, epochMillis: 1726120153595, messageType: MessageType.key, isEncrypted: true, metadata: {encKeyName: null, encAlgo: null, ivNonce: null, skeEncKeyName: null, skeEncAlgo: null, availableAt: null, expiresAt: 2024-09-13 05:49:13.595Z***]
Is this because we don't have the changes on the server yet?

});
}
Loading