Skip to content

Commit

Permalink
Merge pull request #223 from atsign-foundation/atkey_types
Browse files Browse the repository at this point in the history
fix: added error code for invalid atkey exception
  • Loading branch information
murali-shris authored Aug 12, 2022
2 parents 3e336cf + 7c9c96b commit e1e9189
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions at_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 3.0.24
* fix: add error code for InvalidAtKeyException
## 3.0.23
* fix: bug fixes to AtKey.fromString static method and various toString instance methods
* feat: When validating AtKeys, allow _namespace_ to be optional, for legacy app code which depends on keys without namespaces
Expand Down
2 changes: 2 additions & 0 deletions at_commons/lib/src/exception/error_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Map error_codes = {
'BlockedConnectionException': 'AT0013',
'AtClientException': 'AT0014',
'KeyNotFoundException': 'AT0015',
'InvalidAtKeyException': 'AT0016',
'SecondaryConnectException': 'AT0021',
'IllegalArgumentException': 'AT0022',
'AtTimeoutException': 'AT0023'
Expand All @@ -39,6 +40,7 @@ const Map error_description = {
'AT0013': 'Connection Exception',
'AT0014': 'Unknown AtClient exception',
'AT0015': 'key not found',
'AT0016': 'Invalid key',
'AT0021': 'Unable to connect to secondary',
'AT0022': 'Illegal arguments',
'AT0023': 'Timeout waiting for response'
Expand Down
2 changes: 1 addition & 1 deletion at_commons/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_commons
description: A library of Dart and Flutter utility classes that are used across other components of the @‎platform.
version: 3.0.23
version: 3.0.24
repository: https://github.com/atsign-foundation/at_tools
homepage: https://atsign.dev

Expand Down
30 changes: 30 additions & 0 deletions at_commons/test/at_key_type_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ void main() {
expect(keyType, equals(KeyType.reservedKey));
});

test('Test reserved key type for self encryption key', () {
var keyType = AtKey.getKeyType('privatekey:self_encryption_key');
expect(keyType, equals(KeyType.reservedKey));
});

test('Test reserved key type for signing private key', () {
var keyType = AtKey.getKeyType('@alice:signing_privatekey@alice');
expect(keyType, equals(KeyType.reservedKey));
});

test('Test reserved key type for public session key', () {
var keyType = AtKey.getKeyType(
'public:_a29464d0-1f2d-4216-b903-031963bc4ab3@alice');
Expand All @@ -90,5 +100,25 @@ void main() {
var keyType = AtKey.getKeyType('public:signing_publickey@colin');
expect(keyType, equals(KeyType.reservedKey));
});

test('Test reserved key type for commit log compaction key', () {
var keyType = AtKey.getKeyType('privatekey:commitLogCompactionStats');
expect(keyType, equals(KeyType.reservedKey));
});

test('Test reserved key type for access log compaction key', () {
var keyType = AtKey.getKeyType('privatekey:accessLogCompactionStats');
expect(keyType, equals(KeyType.reservedKey));
});

test('Test reserved key type for cram secret deleted', () {
var keyType = AtKey.getKeyType('privatekey:at_secret_deleted');
expect(keyType, equals(KeyType.reservedKey));
});

test('Test reserved key type for cram secret', () {
var keyType = AtKey.getKeyType('privatekey:at_secret');
expect(keyType, equals(KeyType.reservedKey));
});
});
}

0 comments on commit e1e9189

Please sign in to comment.