-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'trunk' into apkam_onboarding_changes_with_enrollment_st…
…atus
- Loading branch information
Showing
4 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ import 'package:crypton/crypton.dart'; | |
import 'package:test/test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
|
||
import 'test_utils/test_utils.dart'; | ||
|
||
class MockSecondaryKeyStore extends Mock implements SecondaryKeyStore { | ||
static const String hiddenKey1 = 'public:__location.wavi@alice'; | ||
static const String hiddenKey2 = '_profilePic.wavi@alice'; | ||
|
@@ -163,6 +165,57 @@ void main() { | |
expect(executeResult!.startsWith('data:'), true); | ||
}); | ||
|
||
test('test update verb builder max key length check', () async { | ||
final atClientManager = AtClientManager(atSign); | ||
final preference = AtClientPreference() | ||
..syncRegex = '.wavi' | ||
..hiveStoragePath = 'test/hive'; | ||
AtClient atClient = await AtClientImpl.create(atSign, 'wavi', preference, | ||
atClientManager: atClientManager); | ||
final localSecondary = LocalSecondary(atClient); | ||
var key = TestUtils.createRandomString(250); | ||
final verbBuilder = UpdateVerbBuilder() | ||
..atKey = (AtKey() | ||
..key = key | ||
..sharedBy = atSign | ||
..metadata = (Metadata()..isPublic = true)) | ||
..value = '[email protected]'; | ||
expect( | ||
() async => | ||
await localSecondary.executeVerb(verbBuilder, sync: false), | ||
throwsA(predicate((dynamic e) => | ||
e is DataStoreException && | ||
e.message == | ||
'key length ${'public:'.length + key.length + atSign.length} is greater than max allowed 248 chars'))); | ||
}); | ||
|
||
test('test update verb builder max key length check for cached key', | ||
() async { | ||
final atClientManager = AtClientManager(atSign); | ||
final preference = AtClientPreference() | ||
..syncRegex = '.wavi' | ||
..hiveStoragePath = 'test/hive'; | ||
AtClient atClient = await AtClientImpl.create(atSign, 'wavi', preference, | ||
atClientManager: atClientManager); | ||
final localSecondary = LocalSecondary(atClient); | ||
var key = TestUtils.createRandomString(250); | ||
final verbBuilder = UpdateVerbBuilder() | ||
..atKey = (AtKey() | ||
..key = key | ||
..sharedBy = atSign | ||
..metadata = (Metadata() | ||
..isCached = true | ||
..isPublic = true)) | ||
..value = '[email protected]'; | ||
expect( | ||
() async => | ||
await localSecondary.executeVerb(verbBuilder, sync: false), | ||
throwsA(predicate((dynamic e) => | ||
e is DataStoreException && | ||
e.message == | ||
'key length ${'cached:'.length + 'public:'.length + key.length + atSign.length} is greater than max allowed 255 chars'))); | ||
}); | ||
|
||
test('test llookup verb builder', () async { | ||
final atClientManager = AtClientManager(atSign); | ||
final preference = AtClientPreference() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'dart:math'; | ||
|
||
class TestUtils { | ||
static String createRandomString(int length) { | ||
final String characters = | ||
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_'; | ||
return String.fromCharCodes(Iterable.generate(length, | ||
(index) => characters.codeUnitAt(Random().nextInt(characters.length)))); | ||
} | ||
} |