Skip to content

Commit

Permalink
Merge pull request #1523 from atsign-foundation/update_at_secondary_s…
Browse files Browse the repository at this point in the history
…erver

chore: update dependencies in at_secondary_server
  • Loading branch information
sitaram-kalluri authored Aug 23, 2023
2 parents d950575 + e25c120 commit c9c5b11
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 34 deletions.
5 changes: 5 additions & 0 deletions packages/at_secondary_server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.0.35
- chore: Upgraded at_persistence_secondary_server to 3.0.57 for memory optimization in commit log
- feat: APKAM keys verb implementation
- feat: Implementation changes for APKAM latest specification
- Allow lookup verb for only authorized namespaces when authenticated via APKAM
## 3.0.34
- chore: Upgraded at_persistence_spec to 2.0.14
- chore: Upgraded at_persistence_secondary_server to 3.0.56
Expand Down
8 changes: 4 additions & 4 deletions packages/at_secondary_server/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_secondary
description: Implementation of secondary server.
version: 3.0.34
version: 3.0.35
repository: https://github.com/atsign-foundation/at_server
homepage: https://www.example.com
publish_to: none
Expand All @@ -20,11 +20,11 @@ dependencies:
ecdsa: 0.0.4
at_commons: 3.0.53
at_utils: 3.0.15
at_chops: 1.0.3
at_lookup: 3.0.38
at_chops: 1.0.4
at_lookup: 3.0.39
at_server_spec: 3.0.13
at_persistence_spec: 2.0.14
at_persistence_secondary_server: 3.0.56
at_persistence_secondary_server: 3.0.57
expire_cache: ^2.0.1
intl: ^0.18.1
json_annotation: ^4.8.0
Expand Down
83 changes: 53 additions & 30 deletions tests/at_functional_test/test/info_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'dart:convert';
import 'dart:io';

import 'package:at_commons/at_commons.dart';
import 'package:at_functional_test/conf/config_util.dart';
import 'package:test/test.dart';
import 'package:version/version.dart';
Expand All @@ -16,11 +17,13 @@ void main() {
var firstAtsign =
ConfigUtil.getYaml()!['first_atsign_server']['first_atsign_name'];
Socket? socketFirstAtsign;
String firstAtsignServer = '';
int firstAtsignPort = 0;

setUp(() async {
var firstAtsignServer =
firstAtsignServer =
ConfigUtil.getYaml()!['first_atsign_server']['first_atsign_url'];
var firstAtsignPort =
firstAtsignPort =
ConfigUtil.getYaml()!['first_atsign_server']['first_atsign_port'];

socketFirstAtsign =
Expand All @@ -36,36 +39,56 @@ void main() {
expect(infoResponse['version'], isNotEmpty);
});

// commenting the test as the server doesn't have enroll verb changes yet
test('info verb with enroll verb changes', () async {
await socket_writer(socketFirstAtsign!, 'info:brief');
var infoResponse = await read();
infoResponse = infoResponse.replaceFirst('data:', '');
var serverVersion = jsonDecode(infoResponse)['version'];
if (Version.parse(serverVersion) > Version(3, 0, 34)) {
await socket_writer(socketFirstAtsign!, 'from:$firstAtsign');
var fromResponse = await read();
fromResponse = fromResponse.replaceAll('data:', '');
var pkamDigest = generatePKAMDigest(firstAtsign, fromResponse);
await socket_writer(socketFirstAtsign!, 'pkam:$pkamDigest');
var pkamResult = await read();
expect(pkamResult, 'data:success\n');
await socket_writer(socketFirstAtsign!, 'from:$firstAtsign');
var fromResponse = await read();
fromResponse = fromResponse.replaceAll('data:', '');
var pkamDigest = generatePKAMDigest(firstAtsign, fromResponse);
await socket_writer(socketFirstAtsign!, 'pkam:$pkamDigest');
var pkamResult = await read();
expect(pkamResult, 'data:success\n');

// create a key with the _manage namespace
var enrollRequest =
'enroll:request:appName:wavi:deviceName:pixel:namespaces:[wavi,rw]:apkamPublicKey:${pkamPublicKeyMap[firstAtsign]!}\n';
await socket_writer(socketFirstAtsign!, enrollRequest);
var enrollResponse = await read();
enrollResponse = enrollResponse.replaceFirst('data:', '');
var enrollJsonMap = jsonDecode(enrollResponse);
expect(enrollJsonMap['enrollmentId'], isNotEmpty);
// create a key with the _manage namespace
var enrollRequest =
'enroll:request:{"appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw"},"apkamPublicKey":"${pkamPublicKeyMap[firstAtsign]!}"}\n';
await socket_writer(socketFirstAtsign!, enrollRequest);
var enrollResponse = await read();
enrollResponse = enrollResponse.replaceFirst('data:', '');
var enrollJsonMap = jsonDecode(enrollResponse);
expect(enrollJsonMap['enrollmentId'], isNotEmpty);
String enrollmentId = enrollJsonMap['enrollmentId'].toString().trim();
// Approve enrollment
await socket_writer(
socketFirstAtsign!, 'enroll:approve:{"enrollmentId":"$enrollmentId"}');
enrollResponse = await read();
enrollResponse = enrollResponse.replaceFirst('data:', '');
await socketFirstAtsign?.close();

// check the info verb.. It should return the result
await socket_writer(socketFirstAtsign!, 'info');
var infoVerbResponse = await read();
infoVerbResponse = infoVerbResponse.replaceAll('data:', '');
var infoResponse = jsonDecode(infoVerbResponse);
expect(infoResponse['apkam_metadata'], isNotEmpty);
}
socketFirstAtsign =
await secure_socket_connection(firstAtsignServer, firstAtsignPort);
socket_listener(socketFirstAtsign!);
await socket_writer(socketFirstAtsign!, 'from:$firstAtsign');
fromResponse = await read();
fromResponse = fromResponse.replaceAll('data:', '');
pkamDigest = generatePKAMDigest(firstAtsign, fromResponse);
// Authenticate the connection via enrollmentId to fetch the APKAM metadata
await socket_writer(
socketFirstAtsign!, 'pkam:enrollmentId:$enrollmentId:$pkamDigest');
pkamResult = await read();
expect(pkamResult, 'data:success\n');

// check the info verb.. It should return the result
await socket_writer(socketFirstAtsign!, 'info');
var infoVerbResponse = await read();
infoVerbResponse = infoVerbResponse.replaceAll('data:', '');
var infoResponse = jsonDecode(infoVerbResponse);
expect(infoResponse['apkam_metadata'], isNotEmpty);
var apkamMetadata = jsonDecode(infoResponse['apkam_metadata']);
// Assert the APKAM metadata
expect(apkamMetadata['appName'], 'wavi');
expect(apkamMetadata['deviceName'], 'pixel');
expect(apkamMetadata['namespaces'], {"wavi": "rw"});
expect(apkamMetadata['sessionId'], isNotNull);
expect(apkamMetadata['apkamPublicKey'], isNotNull);
});
}

0 comments on commit c9c5b11

Please sign in to comment.