mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-07-30 02:08:42 -04:00
flutter unit/integration tests
This commit is contained in:
parent
d586748333
commit
6a8c0830d2
18 changed files with 1357 additions and 520 deletions
34
veilid-flutter/example/integration_test/test_crypto.dart
Normal file
34
veilid-flutter/example/integration_test/test_crypto.dart
Normal file
|
@ -0,0 +1,34 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
|
||||
Future<void> testBestCryptoSystem() async {
|
||||
final cs = await Veilid.instance.bestCryptoSystem();
|
||||
expect(await cs.defaultSaltLength(), equals(16));
|
||||
}
|
||||
|
||||
Future<void> testGetCryptoSystem() async {
|
||||
final cs = await Veilid.instance.getCryptoSystem(cryptoKindVLD0);
|
||||
expect(await cs.defaultSaltLength(), equals(16));
|
||||
}
|
||||
|
||||
Future<void> testGetCryptoSystemInvalid() async {
|
||||
await expectLater(
|
||||
() async => await Veilid.instance.getCryptoSystem(cryptoKindNONE),
|
||||
throwsA(isA<VeilidAPIException>()));
|
||||
}
|
||||
|
||||
Future<void> testHashAndVerifyPassword() async {
|
||||
final cs = await Veilid.instance.bestCryptoSystem();
|
||||
final nonce = await cs.randomNonce();
|
||||
final salt = nonce.decode();
|
||||
|
||||
// Password match
|
||||
final phash = await cs.hashPassword(utf8.encode("abc123"), salt);
|
||||
expect(await cs.verifyPassword(utf8.encode("abc123"), phash), isTrue);
|
||||
|
||||
// Password mismatch
|
||||
await cs.hashPassword(utf8.encode("abc1234"), salt);
|
||||
expect(await cs.verifyPassword(utf8.encode("abc1235"), phash), isFalse);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue