diff --git a/packages/at_commons/lib/src/verb/syntax.dart b/packages/at_commons/lib/src/verb/syntax.dart index cc98b35c..89fdae55 100644 --- a/packages/at_commons/lib/src/verb/syntax.dart +++ b/packages/at_commons/lib/src/verb/syntax.dart @@ -128,7 +128,7 @@ class VerbSyntax { static const notifyRemove = r'notify:remove:(?[\w\d\-\_]+)'; static const enroll = // The non-capturing group (?::)? matches ":" if the operation is request|approve|deny|revoke - r'^enroll:(?(?:(request|approve|deny|revoke|list|fetch|delete)))(:(?force))?(?::)?((?.+)|(<=list:).?)?$'; + r'^enroll:(?(?:(request|approve|deny|revoke|list|fetch|unrevoke|delete)))(:(?force))?(?::)?((?.+)|(<=list:).?)?$'; static const otp = r'^otp:(?get|put)(:(?(?<=put:)\w{6,}))?(:(?:ttl:(?\d+)))?$'; static const keys = r'^keys:((?put|get|delete):?)' diff --git a/packages/at_commons/test/enroll_verb_builder_test.dart b/packages/at_commons/test/enroll_verb_builder_test.dart index 2132b899..51a9a216 100644 --- a/packages/at_commons/test/enroll_verb_builder_test.dart +++ b/packages/at_commons/test/enroll_verb_builder_test.dart @@ -98,5 +98,13 @@ void main() { expect(enrollVerbBuilder.buildCommand(), 'enroll:unrevoke:{"enrollmentId":"123"}\n'); }); + + test('A test to validate enroll delete command', () { + EnrollVerbBuilder enrollVerbBuilder = EnrollVerbBuilder() + ..operation = EnrollOperationEnum.delete + ..enrollmentId = '4785'; + expect(enrollVerbBuilder.buildCommand(), + 'enroll:delete:{"enrollmentId":"4785"}\n'); + }); }); } diff --git a/packages/at_commons/test/syntax_test.dart b/packages/at_commons/test/syntax_test.dart index 2bda5fa7..999c12e0 100644 --- a/packages/at_commons/test/syntax_test.dart +++ b/packages/at_commons/test/syntax_test.dart @@ -312,6 +312,15 @@ void main() { e is InvalidSyntaxException && e.message == 'command does not match the regex'))); }); + + test('A test to validate enroll delete command', () { + String command = 'enroll:delete:{"enrollmentId":"4567"}\n'; + var enrollVerbParams = + VerbUtil.getVerbParam(VerbSyntax.enroll, command.trim()); + expect(enrollVerbParams!['operation'], 'delete'); + var enrollmentInfo = jsonDecode(enrollVerbParams['enrollParams']!); + expect(enrollmentInfo['enrollmentId'], '4567'); + }); }); group('A group of tests related to otp verb', () {