Skip to content

Commit

Permalink
test: add some more functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
srieteja committed Oct 2, 2023
1 parent 78bb276 commit 61d50e2
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tests/at_functional_test/test/enroll_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void main() {
var enrollResponse = await read();
enrollResponse = enrollResponse.replaceFirst('error:', '');
expect(enrollResponse,
'AT0011-Exception: Invalid otp. Cannot process enroll request\n');
'AT0026:Invalid otp. Cannot process enroll request\n');
});

test('enroll request on unauthenticated connection invalid otp', () async {
Expand Down Expand Up @@ -684,6 +684,7 @@ void main() {

test('test enroll:update on an unauthenticated connection', () async {
await _connect();
// socket connection has not been authenticated
await socket_writer(
socketConnection1!, 'enroll:update:{"enrollmentId":"dummy1"}');
var response = await read();
Expand All @@ -695,6 +696,7 @@ void main() {
test('verify enroll:update behaviour with an invalid syntax', () async {
await _connect();
await prepare(socketConnection1!, firstAtsign);
// send enroll:update request without namespace
await socket_writer(
socketConnection1!, 'enroll:update:{"enrollmentId":"dummy1"}');
var response = await read();
Expand All @@ -710,6 +712,7 @@ void main() {
await _connect();
await prepare(socketConnection1!, firstAtsign,
isApkam: true, enrollmentId: enrollId);
// try to update with an invalid enrollmentId
await socket_writer(socketConnection1!,
'enroll:update:{"enrollmentId":"invalid_enrollment_id","namespaces":{"buzz":"rw"}}');
var response = await read();
Expand All @@ -732,8 +735,26 @@ void main() {
expect(jsonDecode(response)['status'], 'pending');
});

test('verify enroll:update behaviour with revoked enrollmentId', () async {
String firstEnrollId = await getApprovedEnrollment();
String secondEnrollId = await getApprovedEnrollment();

await _connect();
await prepare(socketConnection1!, firstAtsign,
isApkam: true, enrollmentId: secondEnrollId);
// revoke the first enrollment
await socket_writer(socketConnection1!, 'enroll:revoke:{"enrollmentId":"$firstEnrollId"}');
assert((await read()).contains('revoked'));
// try to update the first enrollment which is revoked
await socket_writer(socketConnection1!,
'enroll:update:{"enrollmentId":"$firstEnrollId","namespaces":{"buzz":"rw"}}');
var response = await read();
response = response.replaceFirst('error:', '');
expect(response, 'AT0030:EnrollmentStatus: revoked. Only approved enrollments can be updated\n');
});

test(
'verify that enroll:update request approval actually updates the actual enrollment',
'verify that enroll:update request approval updates the namespaces of existing enrollments',
() async {
String enrollId = await getApprovedEnrollment();
await socketConnection1?.close();
Expand Down

0 comments on commit 61d50e2

Please sign in to comment.