Skip to content

Commit

Permalink
Merge pull request #422 from atsign-foundation/expire_otp_changes
Browse files Browse the repository at this point in the history
feat: Modify the OTP syntax for client to set the expire duration
  • Loading branch information
gkc authored Oct 17, 2023
2 parents efcba77 + cd07f87 commit 8aa8106
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 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 @@
## 3.0.57
- feat: Introduced TTL(Time to Live) for OTP verb to configure OTP expiry
## 3.0.56
- feat: Introduce "AtInvalidEnrollmentException" which is thrown when an enrollment is expired or invalid
- feat: Introduce error code 'AT0030' for Invalid Enrollment Status
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 @@ -129,7 +129,7 @@ class VerbSyntax {
static const enroll =
// The non-capturing group (?::)? matches ":" if the operation is request|approve|deny|revoke
r'^enroll:(?<operation>(?:list$|(request|approve|deny|revoke|update)))(?::)?(?<enrollParams>.+)?$';
static const otp = r'^otp:(?<operation>get|validate)(:(?<otp>\w+))?$';
static const otp = r'^otp:(?<operation>get)(:(?:ttl:(?<ttl>\d+)))?$';
static const keys = r'^keys:((?<operation>put|get|delete):?)'
r'(?:(?<visibility>public|private|self):?)?'
r'(?:namespace:(?<namespace>[a-zA-Z0-9_]+):?)?'
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: 3.0.56
version: 3.0.57
repository: https://github.com/atsign-foundation/at_libraries
homepage: https://atsign.dev

Expand Down
24 changes: 24 additions & 0 deletions packages/at_commons/test/otp_verb_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:at_commons/at_commons.dart';
import 'package:test/test.dart';

import 'syntax_test.dart';

void main() {
group('A group of tests related to OTP verb syntax', () {
test('A test to verify otp:get regex', () {
Map<dynamic, dynamic> verbParams =
getVerbParams(VerbSyntax.otp, "otp:get");
expect(verbParams[AtConstants.operation], "get");
expect(verbParams['ttl'], null);
expect(verbParams['otp'], null);
});

test('A test to verify otp:get regex with TTL', () {
Map<dynamic, dynamic> verbParams =
getVerbParams(VerbSyntax.otp, "otp:get:ttl:100");
expect(verbParams[AtConstants.operation], "get");
expect(verbParams['ttl'], '100');
expect(verbParams['otp'], null);
});
});
}
8 changes: 0 additions & 8 deletions packages/at_commons/test/syntax_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,6 @@ void main() {
VerbUtil.getVerbParam(VerbSyntax.otp, command.trim())!;
expect(enrollVerbParams['operation'], 'get');
});

test('A test to verify otp verb for validate operation', () {
String command = 'otp:validate:ABC123\n';
var enrollVerbParams =
VerbUtil.getVerbParam(VerbSyntax.otp, command.trim());
expect(enrollVerbParams!['operation'], 'validate');
expect(enrollVerbParams['otp'], 'ABC123');
});
});
}

Expand Down

0 comments on commit 8aa8106

Please sign in to comment.