diff --git a/packages/at_secondary_server/CHANGELOG.md b/packages/at_secondary_server/CHANGELOG.md index 3eafd44bf..ff53a0fa9 100644 --- a/packages/at_secondary_server/CHANGELOG.md +++ b/packages/at_secondary_server/CHANGELOG.md @@ -1,3 +1,5 @@ +## 3.0.36 +- fix: Implement notify ephemeral changes - Send notification with value without caching the key on receiver's secondary server ## 3.0.35 - chore: Upgraded at_persistence_secondary_server to 3.0.57 for memory optimization in commit log - feat: APKAM keys verb implementation 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 245a7ab2d..277852da3 100644 --- a/packages/at_secondary_server/lib/src/notification/resource_manager.dart +++ b/packages/at_secondary_server/lib/src/notification/resource_manager.dart @@ -35,6 +35,7 @@ class ResourceManager { NotifyConnectionsPool.getInstance(); int get outboundConnectionLimit => _notifyConnectionsPool.size; + set outboundConnectionLimit(int ocl) => _notifyConnectionsPool.size = ocl; void start() { @@ -201,6 +202,9 @@ class ResourceManager { // looked at this code. String commandBody; commandBody = '${atNotification.notification}'; + if (atNotification.atValue != null) { + commandBody = '$commandBody:${atNotification.atValue}'; + } var atMetaData = atNotification.atMetadata; if (atMetaData != null) { if (atNotification.atMetadata!.skeEncAlgo != null) { @@ -237,7 +241,7 @@ class ResourceManager { } if (atMetaData.ttr != null) { commandBody = - 'ttr:${atMetaData.ttr}:ccd:${atMetaData.isCascade}:$commandBody:${atNotification.atValue}'; + 'ttr:${atMetaData.ttr}:ccd:${atMetaData.isCascade}:$commandBody'; } if (atMetaData.ttb != null) { commandBody = 'ttb:${atMetaData.ttb}:$commandBody'; diff --git a/packages/at_secondary_server/pubspec.yaml b/packages/at_secondary_server/pubspec.yaml index 5569e42c6..964bda93b 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.0.35 +version: 3.0.36 repository: https://github.com/atsign-foundation/at_server homepage: https://www.example.com publish_to: none diff --git a/tests/at_end2end_test/test/notify_verb_test.dart b/tests/at_end2end_test/test/notify_verb_test.dart index 383d94cc7..067261095 100644 --- a/tests/at_end2end_test/test/notify_verb_test.dart +++ b/tests/at_end2end_test/test/notify_verb_test.dart @@ -122,7 +122,7 @@ void main() { response = await sh1.read(); print('notify list verb response : $response'); expect(response, - contains('"key":"$atSign_1:contact-no$atSign_2","value":null')); + contains('"key":"$atSign_1:contact-no$atSign_2","value":"$value')); }); test('notify verb without messageType', () async { @@ -200,7 +200,7 @@ void main() { expect( response, contains( - '"key":"$atSign_2:email$atSign_1","value":"null","operation":"delete"')); + '"key":"$atSign_2:email$atSign_1","value":null,"operation":"delete"')); }); test('notify verb without giving message type value', () async { @@ -700,6 +700,241 @@ void main() { expect(decodedResponse['metaData']['skeEncAlgo'], null); } }); + + group('A group of tests related to notify ephemeral', () { + test( + 'notify verb without ttr for messageType-key and operation type - update and with value', + () async { + // The notify ephemeral changes are not into Canary and production. + // So, no point in running against and Canary and Prod servers.` + if (atSign1ServerVersion < Version(3, 0, 36)) { + return; + } + /// NOTIFY VERB + var value = 'testingvalue'; + await sh2.writeCommand( + 'notify:update:messageType:key:$atSign_1:testkey$atSign_2:$value'); + String response = await sh2.read(); + print('notify verb response : $response'); + assert((!response.contains('Invalid syntax')) && + (!response.contains('null'))); + String notificationId = response.replaceAll('data:', ''); + + // notify status + response = await getNotifyStatus(sh2, notificationId, + returnWhenStatusIn: ['delivered'], timeOutMillis: 15000); + print('notify status response : $response'); + assert(response.contains('data:delivered')); + + ///notify:list verb + await sh1.writeCommand('notify:list'); + response = await sh1.read(); + print('notify list verb response : $response'); + expect( + response, + contains( + '"key":"$atSign_1:testkey$atSign_2","value":"$value","operation":"update"')); + }); + + test('notify verb without ttr and without value for operation type update', + () async { + // The notify ephemeral changes are not into Canary and production. + // So, no point in running against and Canary and Prod servers.` + if (atSign1ServerVersion < Version(3, 0, 36)) { + return; + } + + /// NOTIFY VERB + await sh2.writeCommand('notify:update:$atSign_1:nottrkey$atSign_2'); + String response = await sh2.read(); + print('notify verb response : $response'); + assert((!response.contains('Invalid syntax')) && + (!response.contains('null'))); + String notificationId = response.replaceAll('data:', ''); + + // notify status + response = await getNotifyStatus(sh2, notificationId, + returnWhenStatusIn: ['delivered'], timeOutMillis: 15000); + print('notify status response : $response'); + assert(response.contains('data:delivered')); + + ///notify:list verb + await sh1.writeCommand('notify:list'); + response = await sh1.read(); + print('notify list verb response : $response'); + expect( + response, + contains( + '"key":"$atSign_1:nottrkey$atSign_2","value":null,"operation":"update"')); + }); + + test( + 'notify verb without ttr for messageType-text and operation type - update', + () async { + // The notify ephemeral changes are not into Canary and production. + // So, no point in running against and Canary and Prod servers.` + if (atSign1ServerVersion < Version(3, 0, 36)) { + return; + } + + /// NOTIFY VERB + await sh2.writeCommand( + 'notify:update:messageType:text:$atSign_1:hello_world$atSign_2'); + String response = await sh2.read(); + print('notify verb response : $response'); + assert((!response.contains('Invalid syntax')) && + (!response.contains('null'))); + String notificationId = response.replaceAll('data:', ''); + + // notify status + response = await getNotifyStatus(sh2, notificationId, + returnWhenStatusIn: ['delivered'], timeOutMillis: 15000); + print('notify status response : $response'); + assert(response.contains('data:delivered')); + + ///notify:list verb + await sh1.writeCommand('notify:list'); + response = await sh1.read(); + print('notify list verb response : $response'); + expect( + response, + contains( + '"key":"$atSign_1:hello_world","value":null,"operation":"update"')); + }); + + test( + 'notify verb without ttr for messageType-text and operation type - delete', + () async { + // The notify ephemeral changes are not into Canary and production. + // So, no point in running against and Canary and Prod servers.` + if (atSign1ServerVersion < Version(3, 0, 36)) { + return; + } + + /// NOTIFY VERB + await sh2.writeCommand( + 'notify:delete:messageType:text:$atSign_1:hello_world$atSign_2'); + String response = await sh2.read(); + print('notify verb response : $response'); + assert((!response.contains('Invalid syntax')) && + (!response.contains('null'))); + String notificationId = response.replaceAll('data:', ''); + + // notify status + response = await getNotifyStatus(sh2, notificationId, + returnWhenStatusIn: ['delivered'], timeOutMillis: 15000); + print('notify status response : $response'); + assert(response.contains('data:delivered')); + + ///notify:list verb + await sh1.writeCommand('notify:list'); + response = await sh1.read(); + print('notify list verb response : $response'); + expect( + response, + contains( + '"key":"$atSign_1:hello_world","value":null,"operation":"delete"')); + }); + + test( + 'notify verb without ttr and without value for operation type update (self notification)', + () async { + // The notify ephemeral changes are not into Canary and production. + // So, no point in running against and Canary and Prod servers.` + if (atSign1ServerVersion < Version(3, 0, 36)) { + return; + } + + /// NOTIFY VERB + await sh2.writeCommand('notify:update:$atSign_2:nottrkey$atSign_2'); + String response = await sh2.read(); + print('notify verb response : $response'); + assert((!response.contains('Invalid syntax')) && + (!response.contains('null'))); + String notificationId = response.replaceAll('data:', ''); + + // notify status + response = await getNotifyStatus(sh2, notificationId, + returnWhenStatusIn: ['delivered'], timeOutMillis: 15000); + print('notify status response : $response'); + assert(response.contains('data:delivered')); + + ///notify:list verb + await sh2.writeCommand('notify:list'); + response = await sh2.read(); + print('notify list verb response : $response'); + expect( + response, + contains( + '"key":"$atSign_2:nottrkey$atSign_2","value":null,"operation":"update"')); + }); + + test( + 'notify verb without ttr and with value for operation type update (self notification)', + () async { + // The notify ephemeral changes are not into Canary and production. + // So, no point in running against and Canary and Prod servers.` + if (atSign1ServerVersion < Version(3, 0, 36)) { + return; + } + + /// NOTIFY VERB + var value = 'no-ttr'; + await sh2 + .writeCommand('notify:update:$atSign_2:nottrkey$atSign_2:$value'); + String response = await sh2.read(); + print('notify verb response : $response'); + assert((!response.contains('Invalid syntax')) && + (!response.contains('null'))); + String notificationId = response.replaceAll('data:', ''); + + // notify status + response = await getNotifyStatus(sh2, notificationId, + returnWhenStatusIn: ['delivered'], timeOutMillis: 15000); + print('notify status response : $response'); + assert(response.contains('data:delivered')); + + ///notify:list verb + await sh2.writeCommand('notify:list'); + response = await sh2.read(); + print('notify list verb response : $response'); + expect( + response, + contains( + '"key":"$atSign_2:nottrkey$atSign_2","value":"$value","operation":"update"')); + }); + + test('notify verb without ttr for operation type delete', () async { + // The notify ephemeral changes are not into Canary and production. + // So, no point in running against and Canary and Prod servers.` + if (atSign1ServerVersion < Version(3, 0, 36)) { + return; + } + + /// NOTIFY VERB + await sh2.writeCommand('notify:delete:$atSign_1:twitter-id$atSign_2'); + String response = await sh2.read(); + print('notify verb response : $response'); + assert((!response.contains('Invalid syntax')) && + (!response.contains('null'))); + String notificationId = response.replaceAll('data:', ''); + + // notify status + response = await getNotifyStatus(sh2, notificationId, + returnWhenStatusIn: ['delivered'], timeOutMillis: 15000); + print('notify status response : $response'); + assert(response.contains('data:delivered')); + + ///notify:list verb + await sh1.writeCommand('notify:list'); + response = await sh1.read(); + print('notify list verb response : $response'); + expect( + response, + contains( + '"key":"$atSign_1:twitter-id$atSign_2","value":null,"operation":"delete"')); + }); + }); } // get notify status