Skip to content

Commit

Permalink
feat: add delete option to enroll verb (#654)
Browse files Browse the repository at this point in the history
* feat: introduce 'delete' into EnrollOperationEnum

* feat: introduce 'delete' into enroll verb regex

* fix: remove update from EnrollOperationEnum and enroll verb regex
  • Loading branch information
srieteja authored Sep 12, 2024
1 parent 29ebc11 commit a70a6f7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/at_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 4.1.1
- feat: Add "delete" operation to the enroll verb to allow deletion of denied enrollments
## 4.1.0
- feat: Add "unrevoke" operation to the enroll verb to restore revoked APKAM keys
- fix: Add isEncrypted flag to notify command for both true and false
Expand Down
4 changes: 2 additions & 2 deletions packages/at_commons/lib/src/verb/operation_enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ enum EnrollOperationEnum {
deny,
revoke,
list,
update,
fetch,
unrevoke
unrevoke,
delete
}

String getEnrollOperation(EnrollOperationEnum? enrollOperationEnum) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/at_commons/lib/src/verb/syntax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class VerbSyntax {
static const notifyRemove = r'notify:remove:(?<id>[\w\d\-\_]+)';
static const enroll =
// The non-capturing group (?::)? matches ":" if the operation is request|approve|deny|revoke
r'^enroll:(?<operation>(?:(request|approve|deny|revoke|update|list|fetch|unrevoke)))(:(?<force>force))?(?::)?((?<enrollParams>.+)|(<=list:)<enrollParams>.?)?$';
r'^enroll:(?<operation>(?:(request|approve|deny|revoke|list|fetch|unrevoke|delete)))(:(?<force>force))?(?::)?((?<enrollParams>.+)|(<=list:)<enrollParams>.?)?$';
static const otp =
r'^otp:(?<operation>get|put)(:(?<otp>(?<=put:)\w{6,}))?(:(?:ttl:(?<ttl>\d+)))?$';
static const keys = r'^keys:((?<operation>put|get|delete):?)'
Expand Down
2 changes: 1 addition & 1 deletion packages/at_commons/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_commons
description: A library of Dart and Flutter utility classes that are used across other components of the atPlatform.
version: 4.1.0
version: 4.1.1
repository: https://github.com/atsign-foundation/at_libraries
homepage: https://atsign.dev

Expand Down
8 changes: 8 additions & 0 deletions packages/at_commons/test/enroll_verb_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
}
9 changes: 9 additions & 0 deletions packages/at_commons/test/syntax_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand Down

0 comments on commit a70a6f7

Please sign in to comment.