code_test.dart 802 B

12345678910111213141516171819202122
  1. import 'package:ente_auth/models/code.dart';
  2. import 'package:flutter_test/flutter_test.dart';
  3. void main() {
  4. test("parseCodeFromRawData", () {
  5. final code1 = Code.fromRawData(
  6. "otpauth://totp/example%20finance%3Aee%40ff.gg?secret=ASKZNWOU6SVYAMVS",
  7. );
  8. expect(code1.issuer, "example finance", reason: "issuerMismatch");
  9. expect(code1.account, "ee@ff.gg", reason: "accountMismatch");
  10. expect(code1.secret, "ASKZNWOU6SVYAMVS");
  11. });
  12. test("parseDocumentedFormat", () {
  13. final code = Code.fromRawData(
  14. "otpauth://totp/testdata@ente.io?secret=ASKZNWOU6SVYAMVS&issuer=GitHub",
  15. );
  16. expect(code.issuer, "GitHub", reason: "issuerMismatch");
  17. expect(code.account, "testdata@ente.io", reason: "accountMismatch");
  18. expect(code.secret, "ASKZNWOU6SVYAMVS");
  19. });
  20. }