import 'dart:typed_data';

import 'package:flutter_test/flutter_test.dart';
import 'package:kusoft/kusoft.dart';

void main() {
  const libraryPath = String.fromEnvironment('KUSOFT_LIBRARY_PATH');

  setUpAll(() async {
    await initKusoft(libraryPath: libraryPath);
  });

  test('native auth fingerprint is deterministic and 96 bytes', () {
    final first = authMode(
      42,
      'synthetic-device',
      signature: Uint8List.fromList([1, 2, 3]),
      dex: Uint8List.fromList([4, 5, 6]),
      so: Uint8List.fromList([7, 8, 9]),
    );
    final second = authMode(
      42,
      'synthetic-device',
      signature: Uint8List.fromList([1, 2, 3]),
      dex: Uint8List.fromList([4, 5, 6]),
      so: Uint8List.fromList([7, 8, 9]),
    );
    expect(first, hasLength(96));
    expect(second, orderedEquals(first));
  });

  test('custom certificate authority remains opt in', () {
    setTrustMincifryCa(enabled: false);
    expect(trustMincifryCa(), isFalse);
    setTrustMincifryCa(enabled: true);
    expect(trustMincifryCa(), isTrue);
    setTrustMincifryCa(enabled: false);
  });
}
