From 78bb276cbc778e50a2aece12815383eaa0f22fc1 Mon Sep 17 00:00:00 2001 From: Srie Teja Date: Tue, 3 Oct 2023 04:47:31 +0530 Subject: [PATCH] docs: update exception messages and tests to match the change --- .../src/verb/handler/enroll_verb_handler.dart | 14 +++++++------- .../test/enroll_verb_test.dart | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/at_secondary_server/lib/src/verb/handler/enroll_verb_handler.dart b/packages/at_secondary_server/lib/src/verb/handler/enroll_verb_handler.dart index 7e311b01a..9021a0161 100644 --- a/packages/at_secondary_server/lib/src/verb/handler/enroll_verb_handler.dart +++ b/packages/at_secondary_server/lib/src/verb/handler/enroll_verb_handler.dart @@ -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); @@ -406,7 +406,7 @@ 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 && @@ -414,13 +414,13 @@ class EnrollVerbHandler extends AbstractVerbHandler { 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( @@ -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; @@ -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 { diff --git a/packages/at_secondary_server/test/enroll_verb_test.dart b/packages/at_secondary_server/test/enroll_verb_test.dart index 6fc4a8bad..4e79986a6 100644 --- a/packages/at_secondary_server/test/enroll_verb_test.dart +++ b/packages/at_secondary_server/test/enroll_verb_test.dart @@ -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 { @@ -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 { @@ -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', @@ -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) @@ -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 { @@ -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 { @@ -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'); }); }); @@ -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(