Skip to content

Commit

Permalink
docs: update exception messages and tests to match the change
Browse files Browse the repository at this point in the history
  • Loading branch information
srieteja committed Oct 2, 2023
1 parent 7c6d614 commit 78bb276
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class EnrollVerbHandler extends AbstractVerbHandler {
} on KeyNotFoundException {
// KeyNotFound exception indicates an enrollment is expired or invalid
throw AtInvalidEnrollmentException(
'enrollment_id: ${enrollParams.enrollmentId} is expired or invalid');
'Enrollment_id: ${enrollParams.enrollmentId} is expired or invalid');
}
EnrollStatus enrollStatus =
getEnrollStatusFromString(enrollDataStoreValue.approval!.state);
Expand Down Expand Up @@ -406,21 +406,21 @@ class EnrollVerbHandler extends AbstractVerbHandler {
response.isError = true;
response.errorCode = 'AT0030';
response.errorMessage =
'EnrollmentStatus: ${enrollStatus.name}. Only approved enrollments can be updated';
'Enrollment_id: $enrollId is ${enrollStatus.name}. Only approved enrollments can be updated';
}
if (operation == 'approve' &&
EnrollStatus.pending != enrollStatus &&
!isEnrollmentUpdate) {
response.isError = true;
response.errorCode = 'AT0030';
response.errorMessage =
'Cannot approve a ${enrollStatus.name} enrollment. Only pending enrollments can be approved';
'Enrollment_id: $enrollId is ${enrollStatus.name}. Only pending enrollments can be approved';
}
if (operation == 'revoke' && EnrollStatus.approved != enrollStatus) {
response.isError = true;
response.errorCode = 'AT0030';
response.errorMessage =
'Cannot revoke a ${enrollStatus.name} enrollment. Only approved enrollments can be revoked';
'Enrollment_id: $enrollId is ${enrollStatus.name}. Only approved enrollments can be revoked';
}
if (enrollStatus == EnrollStatus.expired) {
throw AtInvalidEnrollmentException(
Expand Down Expand Up @@ -485,13 +485,13 @@ class EnrollVerbHandler extends AbstractVerbHandler {
enrollmentValue = await getEnrollDataStoreValue(existingEnrollKey);
} on KeyNotFoundException {
throw AtInvalidEnrollmentException(
'cannot update enrollment_id: $enrollId. Enrollment is expired');
'Cannot update enrollment_id: $enrollId. Enrollment is expired');
}
if (EnrollStatus.approved.name != enrollmentValue.approval!.state) {
response.isError = true;
response.errorCode = 'AT0030';
response.errorMessage =
'EnrollmentStatus: ${enrollmentValue.approval!.state}. Only approved enrollments can be updated';
'Enrollment_id: $enrollId is ${enrollmentValue.approval?.state}. Only approved enrollments can be updated';
return false;
}
return true;
Expand Down Expand Up @@ -573,7 +573,7 @@ class EnrollVerbHandler extends AbstractVerbHandler {
logger.info(
'Invalid \'enroll:update\' params: enrollId: ${enrollParams.enrollmentId} enrollNamespace: ${enrollParams.namespaces}');
throw IllegalArgumentException(
'Invalid parameters received for Enrollment Update. Update requires an existing approved enrollment_id');
'Invalid parameters received for Enrollment Update. Update requires an existing approved enrollment');
}
EnrollDataStoreValue? existingEnrollment;
try {
Expand Down
16 changes: 8 additions & 8 deletions packages/at_secondary_server/test/enroll_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void main() {
expect(response.isError, true);
expect(response.errorCode, 'AT0030');
expect(response.errorMessage,
'EnrollmentStatus: expired. Only approved enrollments can be updated');
'Enrollment_id: $enrollId is expired. Only approved enrollments can be updated');
});

test('verify enroll:update behaviour on revoked enrollment', () async {
Expand Down Expand Up @@ -353,7 +353,7 @@ void main() {
expect(response.isError, true);
expect(response.errorCode, 'AT0030');
expect(response.errorMessage,
'EnrollmentStatus: revoked. Only approved enrollments can be updated');
'Enrollment_id: $enrollId is revoked. Only approved enrollments can be updated');
});

test('verify enroll:update behaviour on denied enrollment', () async {
Expand All @@ -380,7 +380,7 @@ void main() {
expect(response.isError, true);
expect(response.errorCode, 'AT0030');
expect(response.errorMessage,
'EnrollmentStatus: denied. Only approved enrollments can be updated');
'Enrollment_id: $enrollId is denied. Only approved enrollments can be updated');
});

test('verify enroll:update behaviour when enrollment request expires',
Expand All @@ -405,7 +405,7 @@ void main() {
expect(response.isError, true);
expect(response.errorCode, 'AT0030');
expect(response.errorMessage,
'Cannot approve a approved enrollment. Only pending enrollments can be approved');
'Enrollment_id: $enrollId is approved. Only pending enrollments can be approved');
// reset enrollments expiry duration
enrollVerbHandler.enrollmentExpiryInMills =
Duration(hours: AtSecondaryConfig.enrollmentExpiryInHours)
Expand Down Expand Up @@ -915,7 +915,7 @@ void main() {
expect(response.isError, true);
expect(response.errorCode, 'AT0030');
expect(response.errorMessage,
'Cannot approve a denied enrollment. Only pending enrollments can be approved');
'Enrollment_id: $enrollmentId is denied. Only pending enrollments can be approved');
});

test('A test to verify revoked enrollment cannot be approved', () async {
Expand Down Expand Up @@ -945,7 +945,7 @@ void main() {
expect(response.errorCode, 'AT0030');
// Approved a revoked enrollment throws AtEnrollmentException
expect(response.errorMessage,
'Cannot approve a revoked enrollment. Only pending enrollments can be approved');
'Enrollment_id: $enrollmentId is revoked. Only pending enrollments can be approved');
});

test('A test to verify pending enrollment cannot be revoked', () async {
Expand All @@ -961,7 +961,7 @@ void main() {
expect(response.isError, true);
expect(response.errorCode, 'AT0030');
expect(response.errorMessage,
'Cannot revoke a pending enrollment. Only approved enrollments can be revoked');
'Enrollment_id: $enrollmentId is pending. Only approved enrollments can be revoked');
});
});

Expand Down Expand Up @@ -1089,7 +1089,7 @@ void main() {
expect(response.isError, true);
expect(response.errorCode, 'AT0030');
expect(response.errorMessage,
'EnrollmentStatus: ${enrollDataStoreValue.approval!.state}. Only approved enrollments can be updated');
'Enrollment_id: $enrollId is revoked. Only approved enrollments can be updated');
});

test(
Expand Down

0 comments on commit 78bb276

Please sign in to comment.