Skip to content

Commit

Permalink
fix: functional test failure fix
Browse files Browse the repository at this point in the history
  • Loading branch information
murali-shris committed Jun 19, 2024
1 parent 94fe347 commit fc78120
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 29 deletions.
12 changes: 3 additions & 9 deletions tests/at_functional_test/test/enroll_namespace_access_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,8 @@ void main() {
await firstAtSignConnection
.sendRequestToServer('update:$waviKey waviValue');

String encryptedSelfEncKey = EncryptionUtil.encryptValue(
at_demos.aesKeyMap[firstAtSign]!,
at_demos.apkamSymmetricKeyMap[firstAtSign]!);
String encryptedDefaultEncPrivateKey = EncryptionUtil.encryptValue(
at_demos.encryptionPrivateKeyMap[firstAtSign]!,
at_demos.apkamSymmetricKeyMap[firstAtSign]!);
var enrollRequest =
'enroll:request:{"appName":"wavi-${Uuid().v4().hashCode}","deviceName":"pixel","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptedPrivateKey":"$encryptedDefaultEncPrivateKey","encryptedDefaultSelfEncryptionKey":"$encryptedSelfEncKey","apkamPublicKey":"${pkamPublicKeyMap[firstAtSign]!}"}\n';
'enroll:request:{"appName":"wavi-${Uuid().v4().hashCode}","deviceName":"pixel","namespaces":{"wavi":"rw"},"apkamPublicKey":"${pkamPublicKeyMap[firstAtSign]!}"}\n';
String enrollResponse =
(await firstAtSignConnection.sendRequestToServer(enrollRequest))
.replaceAll('data:', '');
Expand All @@ -316,7 +310,7 @@ void main() {

//send second enroll request with otp
var secondEnrollRequest =
'enroll:request:{"appName":"buzz","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"buzz":"rw"},"otp":"$otpResponse","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!},"encryptedAPKAMSymmetricKey" : "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}\n';
'enroll:request:{"appName":"buzz","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"buzz":"rw"},"otp":"$otpResponse","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}","encryptedAPKAMSymmetricKey" : "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}\n';
var secondEnrollResponse =
(await secondConnection.sendRequestToServer(secondEnrollRequest))
.replaceAll('data:', '');
Expand All @@ -327,7 +321,7 @@ void main() {

// connect to the first client to approve the enroll request
var approveResponse = (await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"$secondEnrollmentId"}'))
'enroll:approve:{"enrollmentId":"$secondEnrollmentId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap["encryptedDefaultEncPrivateKey"]}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap["encryptedSelfEncKey"]}"}'))
.replaceAll('data:', '');
var approveJson = jsonDecode(approveResponse);
expect(approveJson['status'], 'approved');
Expand Down
31 changes: 16 additions & 15 deletions tests/at_functional_test/test/enroll_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void main() {
firstAtSign, firstAtSignHost, firstAtSignPort);
//send second enroll request with otp
String secondEnrollRequest =
'enroll:request:{"appName":"buzz","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"buzz":"rw"},"otp":"$otpResponse","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!},"encryptedAPKAMSymmetricKey": "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
'enroll:request:{"appName":"buzz","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"buzz":"rw"},"otp":"$otpResponse","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}","encryptedAPKAMSymmetricKey": "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
String secondEnrollResponse =
(await socketConnection2.sendRequestToServer(secondEnrollRequest))
.replaceFirst('data:', '');
Expand All @@ -383,7 +383,7 @@ void main() {

// connect to the first client to approve the enroll request
String approveResponse = (await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"$secondEnrollId"}'))
'enroll:approve:{"enrollmentId":"$secondEnrollId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap['encryptedDefaultEncPrivateKey']}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap['encryptedSelfEncKey']}"}'))
.replaceFirst('data:', '');
var approveJson = jsonDecode(approveResponse);
expect(approveJson['status'], 'approved');
Expand Down Expand Up @@ -517,7 +517,7 @@ void main() {
await OutboundConnectionFactory().initiateConnectionWithListener(
firstAtSign, firstAtSignHost, firstAtSignPort);
var enrollRequest =
'enroll:request:{"appName":"wavi","deviceName":"$deviceName","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!},"encryptedAPKAMSymmetricKey": "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
'enroll:request:{"appName":"wavi","deviceName":"$deviceName","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}","encryptedAPKAMSymmetricKey": "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
String enrollResponse =
(await socketConnection2.sendRequestToServer(enrollRequest))
.replaceFirst('data:', '');
Expand All @@ -527,7 +527,7 @@ void main() {
expect(enrollJsonMap['status'], 'pending');
// Approve enrollment
String approveEnrollment =
'enroll:approve:{"enrollmentId":"$enrollmentId"}';
'enroll:approve:{"enrollmentId":"$enrollmentId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap['encryptedDefaultEncPrivateKey']}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap['encryptedSelfEncKey']}"}';
String enrollmentResponse =
await firstAtSignConnection.sendRequestToServer(approveEnrollment);
enrollmentResponse = enrollmentResponse.replaceAll('data:', '');
Expand Down Expand Up @@ -724,7 +724,7 @@ void main() {
expect(jsonDecode(enrollmentResponse)['enrollmentId'], enrollmentId);
// Approve enrollment
enrollmentResponse = (await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"$enrollmentId"}'))
'enroll:approve:{"enrollmentId":"$enrollmentId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap['encryptedDefaultEncPrivateKey']}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap['encryptedSelfEncKey']}"}'))
.replaceAll('error:', '');
expect(
jsonDecode(enrollmentResponse)['errorDescription'],
Expand Down Expand Up @@ -756,7 +756,7 @@ void main() {
// Approve enrollment
await firstAtSignConnection.authenticateConnection();
enrollmentResponse = (await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"$enrollmentId"}'))
'enroll:approve:{"enrollmentId":"$enrollmentId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap['encryptedDefaultEncPrivateKey']}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap['encryptedSelfEncKey']}"}'))
.replaceAll('data:', '');
expect(jsonDecode(enrollmentResponse)['status'], 'approved');
expect(jsonDecode(enrollmentResponse)['enrollmentId'], enrollmentId);
Expand All @@ -768,7 +768,7 @@ void main() {
expect(jsonDecode(enrollmentResponse)['enrollmentId'], enrollmentId);
// Approve a revoked enrollment
enrollmentResponse = (await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"$enrollmentId"}'))
'enroll:approve:{"enrollmentId":"$enrollmentId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap['encryptedDefaultEncPrivateKey']}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap['encryptedSelfEncKey']}"}'))
.replaceAll('error:', '');
expect(
jsonDecode(enrollmentResponse)['errorDescription'],
Expand Down Expand Up @@ -810,7 +810,7 @@ void main() {
otp = await firstAtSignConnection.sendRequestToServer('otp:get');
otp = otp.replaceAll('data:', '').trim();
enrollRequest =
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}"}\n';
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}","encryptedAPKAMSymmetricKey" : "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}\n';
enrollmentResponse =
(await unAuthenticatedConnection.sendRequestToServer(enrollRequest))
.replaceAll('error:', '');
Expand Down Expand Up @@ -841,7 +841,7 @@ void main() {
otp = await firstAtSignConnection.sendRequestToServer('otp:get');
otp = otp.replaceAll('data:', '').trim();
enrollRequest =
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}"}';
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}","encryptedAPKAMSymmetricKey" : "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
enrollmentResponse =
(await unAuthenticatedConnection.sendRequestToServer(enrollRequest))
.replaceAll('error:', '');
Expand Down Expand Up @@ -878,7 +878,7 @@ void main() {
otp = await firstAtSignConnection.sendRequestToServer('otp:get');
otp = otp.replaceAll('data:', '').trim();
enrollRequest =
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}"}';
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}","encryptedAPKAMSymmetricKey" : "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
enrollmentResponse =
(await unAuthenticatedConnection.sendRequestToServer(enrollRequest))
.replaceAll('error:', '');
Expand All @@ -893,7 +893,7 @@ void main() {
otp = await firstAtSignConnection.sendRequestToServer('otp:get');
otp = otp.replaceAll('data:', '').trim();
enrollRequest =
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}"}';
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"otp":"$otp","apkamPublicKey":"${apkamPublicKeyMap[firstAtSign]!}","encryptedAPKAMSymmetricKey" : "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
enrollmentResponse = await secondUnAuthenticatedConnection2
.sendRequestToServer(enrollRequest);
enrollmentResponseMap =
Expand Down Expand Up @@ -943,7 +943,8 @@ void main() {
'A test to verify stats verb returns highest commitId among enrolled namespace',
() async {
String randomId = Uuid().v4();
String enrollRequest = 'enroll:approve:{"enrollmentId":"$enrollmentId"}';
String enrollRequest =
'enroll:approve:{"enrollmentId":"$enrollmentId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap["encryptedDefaultEncPrivateKey"]}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap["encryptedSelfEncKey"]}"}';
await firstAtSignConnection.initiateConnectionWithListener(
firstAtSign, firstAtSignHost, firstAtSignPort);
await firstAtSignConnection.authenticateConnection();
Expand Down Expand Up @@ -1027,9 +1028,9 @@ void main() {

// approve first and second enrollment request in enrollmentIds list
await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"${enrollmentIds[0]}"}');
'enroll:approve:{"enrollmentId":"${enrollmentIds[0]}","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap["encryptedDefaultEncPrivateKey"]}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap["encryptedSelfEncKey"]}"}');
await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"${enrollmentIds[1]}"}');
'enroll:approve:{"enrollmentId":"${enrollmentIds[1]}","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap["encryptedDefaultEncPrivateKey"]}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap["encryptedSelfEncKey"]}"}');

// again, fetch approved enrollment requests
Map<String, dynamic> enrollmentRequestsMap =
Expand All @@ -1052,7 +1053,7 @@ void main() {

// approve and then revoke third enrollment request in enrollmentIds list
await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"${enrollmentIds[2]}"}');
'enroll:approve:{"enrollmentId":"${enrollmentIds[2]}","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap["encryptedDefaultEncPrivateKey"]}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap["encryptedSelfEncKey"]}"}');
// authenticate using enrollmentIds[2]
OutboundConnectionFactory tempSocketConnection =
await OutboundConnectionFactory().initiateConnectionWithListener(
Expand Down
4 changes: 3 additions & 1 deletion tests/at_functional_test/test/info_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ void main() {
var enrollResponse =
await firstAtSignConnection.sendRequestToServer(enrollRequest);
enrollResponse = enrollResponse.replaceFirst('data:', '');
print(enrollResponse);
var enrollJsonMap = jsonDecode(enrollResponse);
expect(enrollJsonMap['enrollmentId'], isNotEmpty);
String enrollmentId = enrollJsonMap['enrollmentId'].toString().trim();
// Approve enrollment
enrollResponse = await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"$enrollmentId",,"encryptedDefaultEncryptionPrivateKey": "dummy_encrypted_default_encryption_private_key","encryptedDefaultSelfEncryptionKey":"dummy_encrypted_default_self_encryption_key"}');
'enroll:approve:{"enrollmentId":"$enrollmentId","encryptedDefaultEncryptionPrivateKey": "dummy_encrypted_default_encryption_private_key","encryptedDefaultSelfEncryptionKey":"dummy_encrypted_default_self_encryption_key"}');
enrollResponse = enrollResponse.replaceFirst('data:', '');
await firstAtSignConnection.close();

Expand All @@ -53,6 +54,7 @@ void main() {
await firstAtSignConnection.sendRequestToServer('info');
infoVerbResponse = infoVerbResponse.replaceAll('data:', '');
Map infoResponse = jsonDecode(infoVerbResponse);
print('infoResponse: $enrollResponse');
expect(infoResponse['apkam_metadata'], isNotEmpty);
var apkamMetadata = jsonDecode(infoResponse['apkam_metadata']);
// Assert the APKAM metadata
Expand Down
6 changes: 3 additions & 3 deletions tests/at_functional_test/test/keys_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void main() {
authType: AuthType.cram);

var enrollRequest =
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"encryptedDefaultEncryptedPrivateKey":"${apkamEncryptedKeysMap['encryptedDefaultEncPrivateKey']}","encryptedDefaultSelfEncryptionKey":"${apkamEncryptedKeysMap['encryptedSelfEncKey']}","apkamPublicKey":"${pkamPublicKeyMap[firstAtSign]!}"}';
'enroll:request:{"appName":"wavi","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"wavi":"rw"},"apkamPublicKey":"${pkamPublicKeyMap[firstAtSign]!}"}';
String enrollResponse =
await firstAtSignConnection.sendRequestToServer(enrollRequest);
enrollResponse = enrollResponse.replaceFirst('data:', '');
Expand All @@ -188,7 +188,7 @@ void main() {

//send second enroll request with otp
var secondEnrollRequest =
'enroll:request:{"appName":"buzz","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"buzz":"rw"},"otp":"$otpResponse","encryptedDefaultEncryptedPrivateKey":"${apkamEncryptedKeysMap['encryptedDefaultEncPrivateKey']}","encryptedDefaultSelfEncryptionKey":"${apkamEncryptedKeysMap['encryptedSelfEncKey']}","apkamPublicKey":"${pkamPublicKeyMap[firstAtSign]!},"encryptedAPKAMSymmetricKey": "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
'enroll:request:{"appName":"buzz","deviceName":"pixel-${Uuid().v4().hashCode}","namespaces":{"buzz":"rw"},"otp":"$otpResponse","apkamPublicKey":"${pkamPublicKeyMap[firstAtSign]!}","encryptedAPKAMSymmetricKey": "${apkamEncryptedKeysMap['encryptedAPKAMSymmetricKey']}"}';
String secondEnrollResponse =
await secondAtSignConnection.sendRequestToServer(secondEnrollRequest);
secondEnrollResponse = secondEnrollResponse.replaceFirst('data:', '');
Expand All @@ -199,7 +199,7 @@ void main() {

// connect to the first client to approve the enroll request
var approveResponse = await firstAtSignConnection.sendRequestToServer(
'enroll:approve:{"enrollmentId":"$secondEnrollId"}');
'enroll:approve:{"enrollmentId":"$secondEnrollId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap["encryptedDefaultEncPrivateKey"]}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap["encryptedSelfEncKey"]}"}');
approveResponse = approveResponse.replaceFirst('data:', '');
var approveJson = jsonDecode(approveResponse);
expect(approveJson['status'], 'approved');
Expand Down
2 changes: 1 addition & 1 deletion tests/at_functional_test/test/sync_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void main() {
String randomString = Uuid().v4();

await authenticatedSocket.sendRequestToServer(
'enroll:approve:{"enrollmentId":"$enrollmentId"}');
'enroll:approve:{"enrollmentId":"$enrollmentId","encryptedDefaultEncryptionPrivateKey":"${apkamEncryptedKeysMap["encryptedDefaultEncPrivateKey"]}","encryptedDefaultSelfEncryptionKey": "${apkamEncryptedKeysMap["encryptedSelfEncKey"]}"}');
await authenticatedSocket.sendRequestToServer(
'update:$secondAtSign:phone-$randomString.wavi$firstAtSign $randomString');
await authenticatedSocket.sendRequestToServer(
Expand Down

0 comments on commit fc78120

Please sign in to comment.