Skip to content

Commit

Permalink
Merge pull request #314 from atsign-foundation/release_trunk
Browse files Browse the repository at this point in the history
release trunk branch
  • Loading branch information
sitaram-kalluri authored Sep 17, 2021
2 parents 567ef59 + 2a6a017 commit ee5e4d7
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 54 deletions.
5 changes: 2 additions & 3 deletions at_end2end_test/test/commons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Future<SecureSocket> socket_connection(host, port) async {
context.setTrustedCertificates('lib/secondary/base/certs/cacert.pem');
context.usePrivateKey('lib/secondary/base/certs/privkey.pem');
context.useCertificateChain('lib/secondary/base/certs/fullchain.pem');
return await SecureSocket.connect(host, port , context: context );
return await SecureSocket.connect(host, port, context: context);
}

void clear() {
Expand All @@ -26,8 +26,7 @@ void clear() {
}

///Secure Socket Connection
Future<SecureSocket> secure_socket_connection(
host, port) async {
Future<SecureSocket> secure_socket_connection(host, port) async {
var socket;
while (true) {
try {
Expand Down
128 changes: 83 additions & 45 deletions at_end2end_test/test/update_verb_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,41 @@ void main() {
await prepare(_socket_first_atsign, first_atsign);

//Socket connection for second atsign
_socket_second_atsign =
await secure_socket_connection(second_atsign_server, second_atsign_port);
_socket_second_atsign = await secure_socket_connection(
second_atsign_server, second_atsign_port);
socket_listener(_socket_second_atsign);
await prepare(_socket_second_atsign, second_atsign);
});

test('update-llookup verb with public key', () async {
/// UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:public:location$first_atsign Hyderabad');
await socket_writer(
_socket_first_atsign, 'update:public:location$first_atsign Hyderabad');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB
await socket_writer(_socket_first_atsign, 'llookup:public:location$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:public:location$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response, contains('data:Hyderabad'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update-llookup with private key', () async {
/// UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:$second_atsign:country$first_atsign India');
await socket_writer(_socket_first_atsign,
'update:$second_atsign:country$first_atsign India');
var response = await read();
print('update verb response $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB - with @sign returns value
await socket_writer(_socket_first_atsign, 'llookup:$second_atsign:country$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:$second_atsign:country$first_atsign');
response = await read();
print('llookup verb response with private key in llookup verb: $response');
expect(response, contains('data:India'));
Expand All @@ -76,27 +82,33 @@ void main() {

test('update verb with special characters', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:public:passcode$first_atsign @!ice^&##');
await socket_writer(
_socket_first_atsign, 'update:public:passcode$first_atsign @!ice^&##');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB
await socket_writer(_socket_first_atsign, 'llookup:public:passcode$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:public:passcode$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response,contains('data:@!ice^&##'));
expect(response, contains('data:@!ice^&##'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update verb with unicode characters', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:public:unicode$first_atsign U+0026');
await socket_writer(
_socket_first_atsign, 'update:public:unicode$first_atsign U+0026');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB
await socket_writer(_socket_first_atsign, 'llookup:public:unicode$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:public:unicode$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response, contains('data:U+0026'));
Expand All @@ -108,151 +120,177 @@ void main() {
'update:public:address$first_atsign "plot no-103,Essar enclave,Hyderabad-500083"');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB
await socket_writer(_socket_first_atsign, 'llookup:public:address$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:public:address$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response,contains(
'data:"plot no-103,Essar enclave,Hyderabad-500083"'));
expect(response,
contains('data:"plot no-103,Essar enclave,Hyderabad-500083"'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update verb without value should throw a error ', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:public:key-1$first_atsign');
await socket_writer(
_socket_first_atsign, 'update:public:key-1$first_atsign');
var response = await read();
print('update verb response : $response');
expect(response, contains('Invalid syntax'));
});

test('update verb by passing emoji as value ', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:public:emoji$first_atsign 🦄');
await socket_writer(
_socket_first_atsign, 'update:public:emoji$first_atsign 🦄');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB
await socket_writer(_socket_first_atsign, 'llookup:public:emoji$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:public:emoji$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response, contains('data:🦄'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update verb by passing japanese input as value ', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:public:japanese$first_atsign "パーニマぱーにま"');
await socket_writer(
_socket_first_atsign, 'update:public:japanese$first_atsign "パーニマぱーにま"');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB
await socket_writer(_socket_first_atsign, 'llookup:public:japanese$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:public:japanese$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response, contains('data:"パーニマぱーにま"'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update verb by sharing a cached key ', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:ttr:-1:$second_atsign:xbox1$first_atsign player123');
await socket_writer(_socket_first_atsign,
'update:ttr:-1:$second_atsign:xbox1$first_atsign player123');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

// ///LLOOKUP VERB in the same secondary
await socket_writer(_socket_first_atsign, 'llookup:$second_atsign:xbox1$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:$second_atsign:xbox1$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response, contains('data:player123'));

//LOOKUP VERB in the shared secondary
await socket_writer(_socket_second_atsign, 'llookup:cached:$second_atsign:xbox1$first_atsign');
await socket_writer(_socket_second_atsign,
'llookup:cached:$second_atsign:xbox1$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response, contains('data:player123'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update verb by passing 2 @ symbols ', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:public:country@$first_atsign USA');
await socket_writer(
_socket_first_atsign, 'update:public:country@$first_atsign USA');
var response = await read();
print('update verb response : $response');
assert(response.contains('Invalid syntax'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update-llookup for private key for an emoji atsign ', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:@🦄:emoji.name$first_atsign unicorn');
await socket_writer(
_socket_first_atsign, 'update:@🦄:emoji.name$first_atsign unicorn');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB
await socket_writer(_socket_first_atsign, 'llookup:@🦄:emoji.name$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:@🦄:emoji.name$first_atsign');
response = await read();
print('llookup verb response : $response');
expect(response, contains('data:unicorn'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update-llookup for ttl ', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:ttl:3000:$second_atsign:offer$first_atsign 3seconds');
await socket_writer(_socket_first_atsign,
'update:ttl:3000:$second_atsign:offer$first_atsign 3seconds');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP:META verb
await socket_writer(_socket_first_atsign, 'llookup:meta:$second_atsign:offer$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:meta:$second_atsign:offer$first_atsign');
response = await read();
print('llookup meta response : $response');
expect(response, contains('"ttl":3000'));

///LLOOKUP VERB - Before 3 seconds
await socket_writer(_socket_first_atsign, 'llookup:$second_atsign:offer$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:$second_atsign:offer$first_atsign');
response = await read();
print('llookup verb response before 3 seconds : $response');
expect(response, contains('data:3seconds'));

///LLOOKUP VERB - After 3 seconds
//Waiting till the ttl time is up
await Future.delayed(Duration(seconds: 2));
await socket_writer(_socket_first_atsign, 'llookup:$second_atsign:offer$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:$second_atsign:offer$first_atsign');
response = await read();
print('llookup verb response after 3 seconds : $response');
expect(response, contains('data:null'));
}, timeout: Timeout(Duration(seconds: 90)));

test('update-llookup for ttb ', () async {
///UPDATE VERB
await socket_writer(_socket_first_atsign, 'update:ttb:2000:$second_atsign:auth-code$first_atsign 3289');
await socket_writer(_socket_first_atsign,
'update:ttb:2000:$second_atsign:auth-code$first_atsign 3289');
var response = await read();
print('update verb response : $response');
assert((!response.contains('Invalid syntax')) && (!response.contains('null')));
assert(
(!response.contains('Invalid syntax')) && (!response.contains('null')));

///LLOOKUP VERB - Before 2 seconds
await socket_writer(_socket_first_atsign, 'llookup:$second_atsign:auth-code$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:$second_atsign:auth-code$first_atsign');
response = await read();
print('llookup verb response before 2 seconds : $response');
expect(response, contains('data:null'));

///LLOOKUP VERB - After 2 seconds
await socket_writer(_socket_first_atsign, 'llookup:$second_atsign:auth-code$first_atsign');
await socket_writer(
_socket_first_atsign, 'llookup:$second_atsign:auth-code$first_atsign');
response = await read();
print('llookup verb response after 2 seconds : $response');
expect(response, contains('data:3289'));

///LLookup:META FOR TTB
//waiting till ttb time is up
await Future.delayed(Duration(seconds: 2));
await socket_writer(_socket_first_atsign, 'llookup:meta:$second_atsign:auth-code$first_atsign');
await socket_writer(_socket_first_atsign,
'llookup:meta:$second_atsign:auth-code$first_atsign');
response = await read();
print('llookup meta verb response for ttb is : $response');
expect(response, contains('"ttb":2000'));
}, timeout: Timeout(Duration(seconds: 90)));


tearDown(() {
//Closing the client socket connection
clear();
Expand Down
9 changes: 5 additions & 4 deletions at_root/at_root_server/lib/src/server/at_root_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ class AtRootConfig {
static bool? _useSSL = true;
static String _certificateChainLocation = 'certs/fullchain.pem';
static String _privateKeyLocation = 'certs/privkey.pem';
static String? _root_server_version = (ConfigUtil.getPubspecConfig() != null &&
ConfigUtil.getPubspecConfig()!['version'] != null)
? ConfigUtil.getPubspecConfig()!['version']
: null;
static String? _root_server_version =
(ConfigUtil.getPubspecConfig() != null &&
ConfigUtil.getPubspecConfig()!['version'] != null)
? ConfigUtil.getPubspecConfig()!['version']
: null;

static final Map<String, String> _envVars = Platform.environment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class AtCertificateValidationJob {
// Run the cron job twice a day.
cron.schedule(Schedule(hours: [certsJobHour, certsJobHour + 12]), () {
if (file.existsSync()) {
logger.info('Restart file found. Initializing secondary server restart process');
logger.info(
'Restart file found. Initializing secondary server restart process');
mainIsolateSendPort.send(true);
}
});
Expand Down
2 changes: 1 addition & 1 deletion at_secondary/at_secondary_server/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
collection: ^1.15.0
basic_utils: ^3.0.2
at_persistence_secondary_server: ^3.0.0
at_lookup: ^3.0.0
at_lookup: ^3.0.2
at_server_spec: ^3.0.0

#dependency_overrides:
Expand Down

0 comments on commit ee5e4d7

Please sign in to comment.