Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce localkey #233

Merged
merged 5 commits into from
Oct 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions at_commons/test/at_key_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -575,5 +575,27 @@ void main() {
expect(localKey.isLocal, true);
expect(localKey.toString(), 'local:phone@alice');
});

test('validate a local key with namespace', () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test description says 'with namespace' but there is no namespace used in this test. And shouldn't the validation then fail because namespace should be mandatory? Same applies to the next test below

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gkc, i have copied the test from above and changed the key types. missed correcting the test subject line. Since enforceNamespace defaults to false, the tests did not fail. Added a new test with enforceNamespace set to true which asserts on a failure

var localKey = (LocalKeyBuilder()
..key('phone')
..sharedBy('@alice'))
.build();
var validationResult = AtKeyValidators.get().validate(
localKey.toString(), ValidationContext()..atSign = '@alice');
expect(validationResult.isValid, true);
});

test('validate a local key with namespace when sharedBy is not populated',
() {
var localKey = (LocalKeyBuilder()
..key('phone')
..sharedBy(''))
.build();
var validationResult = AtKeyValidators.get().validate(
localKey.toString(), ValidationContext()..atSign = '@alice');
expect(validationResult.isValid, false);
expect(validationResult.failureReason, 'local:phone is not a valid key');
});
});
}