Skip to content

Commit

Permalink
docs: update docs + add test
Browse files Browse the repository at this point in the history
  • Loading branch information
srieteja committed Mar 21, 2024
1 parent a9389c2 commit feddc9e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/at_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## 4.0.4
- feat: Enhance enroll:list to enable filtering of enrollments based on their status
- feat: Enhance enroll:list to enable filtering based on enrollment status
## 4.0.3
- fix: "toJson()" invoked on "pubKeyHash" leads to NullPointerException.
## 4.0.2
Expand Down
2 changes: 1 addition & 1 deletion packages/at_commons/lib/src/verb/enroll_params.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:json_annotation/json_annotation.dart';

import '../../at_commons.dart';
import 'package:at_commons/at_commons.dart';
part 'enroll_params.g.dart';

@JsonSerializable()
Expand Down
1 change: 1 addition & 0 deletions packages/at_commons/lib/src/verb/enroll_params.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions packages/at_commons/lib/src/verb/enroll_verb_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {
String? encryptedDefaultSelfEncryptionKey;
String? encryptedAPKAMSymmetricKey;

/// Filters enrollment requests according to the provided [EnrollmentStatus] criteria.
/// Filters enrollment requests based on provided [EnrollmentStatus] criteria.
///
/// Accepts a list of enrollment statuses, defaulting to all available status values.
/// Accepts a list of enrollment statuses. Defaults to all EnrollmentStatuses
List<EnrollmentStatus> enrollmentStatusFilter = EnrollmentStatus.values;

@override
Expand Down Expand Up @@ -69,7 +69,9 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {
return sb.toString();
}

/// Checks if the key and its value should be added to the enroll verb command.
/// Compares current EnrollOperation with VerbBuilder params and removes any
/// that are NOT applicable
///
///
/// Returning "false" will leave the key and its value in the map, which gets added to the
/// enroll verb command. Returning true will remove the key and its value from the map to
Expand All @@ -78,8 +80,8 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {
if (value == null || value.toString().isEmpty) {
return true;
}
// When operation is not list, EnrollmentStatusFilter is not applicable. Hence remove from enrollParamsJson
// to prevent it from adding it enroll verb command.
// EnrollmentStatusFilter is only applicable to EnrollOperation.list
// Remove it from enrollParamsJson for any operation other than list
if (key == 'enrollmentStatusFilter' &&
operation != EnrollOperationEnum.list) {
return true;
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 @@ -64,5 +64,13 @@ void main() {
expect(command,
'enroll:list:{"enrollmentStatusFilter":["approved","pending"]}\n');
});

test('A test to validate enroll list command with default filter', () {
var enrollVerbBuilder = EnrollVerbBuilder()
..operation = EnrollOperationEnum.list;
var command = enrollVerbBuilder.buildCommand();
expect(command,
'enroll:list:{"enrollmentStatusFilter":["pending","approved","denied","revoked","expired"]}\n');
});
});
}

0 comments on commit feddc9e

Please sign in to comment.