diff --git a/pubspec.lock b/pubspec.lock index 1c7872644..cfc400ef9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -13,10 +13,10 @@ packages: dependency: transitive description: name: _flutterfire_internals - sha256: "5a0296da7ae717ffb7444dee8439ca25ac80e162a345b933aa57f0a4a48dca2c" + sha256: "71c01c1998c40b3af1944ad0a5f374b4e6fef7f3d2df487f3970dbeadaeb25a1" url: "https://pub.dev" source: hosted - version: "1.3.45" + version: "1.3.46" _macros: dependency: transitive description: dart @@ -218,10 +218,10 @@ packages: dependency: transitive description: name: camera_avfoundation - sha256: "0d04cec8715b59fb6dc60eefb47e69024f51233c570e475b886dc9290568bca7" + sha256: "2e4c568f70e406ccb87376bc06b53d2f5bebaab71e2fbcc1a950e31449381bcf" url: "https://pub.dev" source: hosted - version: "0.9.17+4" + version: "0.9.17+5" camera_platform_interface: dependency: transitive description: @@ -250,10 +250,10 @@ packages: dependency: transitive description: name: charcode - sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 + sha256: fb0f1107cac15a5ea6ef0a6ef71a807b9e4267c713bb93e00e92d737cc8dbd8a url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.4.0" checked_yaml: dependency: transitive description: @@ -330,10 +330,10 @@ packages: dependency: transitive description: name: coverage - sha256: "88b0fddbe4c92910fefc09cc0248f5e7f0cd23e450ded4c28f16ab8ee8f83268" + sha256: "4b03e11f6d5b8f6e5bb5e9f7889a56fe6c5cbe942da5378ea4d4d7f73ef9dfe5" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" cross_file: dependency: transitive description: @@ -418,10 +418,10 @@ packages: dependency: "direct main" description: name: device_info_plus - sha256: c4af09051b4f0508f6c1dc0a5c085bf014d5c9a4a0678ce1799c2b4d716387a0 + sha256: f545ffbadee826f26f2e1a0f0cbd667ae9a6011cc0f77c0f8f00a969655e6e95 url: "https://pub.dev" source: hosted - version: "11.1.0" + version: "11.1.1" device_info_plus_platform_interface: dependency: transitive description: @@ -490,10 +490,10 @@ packages: dependency: transitive description: name: file_selector_android - sha256: ec439df07c4999faad319ce8ad9e971795c2f1d7132ad5a793b9370a863c6128 + sha256: "934850f9702b0f9031bc331a306e7bebc62f894a6e5ca6c0681c7af17e7afb50" url: "https://pub.dev" source: hosted - version: "0.5.1+10" + version: "0.5.1+11" file_selector_ios: dependency: transitive description: @@ -506,10 +506,10 @@ packages: dependency: transitive description: name: file_selector_linux - sha256: "712ce7fab537ba532c8febdb1a8f167b32441e74acd68c3ccb2e36dcb52c4ab2" + sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33" url: "https://pub.dev" source: hosted - version: "0.9.3" + version: "0.9.3+2" file_selector_macos: dependency: transitive description: @@ -546,10 +546,10 @@ packages: dependency: "direct main" description: name: firebase_core - sha256: e59141ff83e70a9ba571a1f8733c5598cf57e6e68037ab185581d7fc0a436738 + sha256: "2438a75ad803e818ad3bd5df49137ee619c46b6fc7101f4dbc23da07305ce553" url: "https://pub.dev" source: hosted - version: "3.7.0" + version: "3.8.0" firebase_core_platform_interface: dependency: transitive description: @@ -570,26 +570,26 @@ packages: dependency: "direct main" description: name: firebase_messaging - sha256: a988c6ab37fa5a6abf2f8087a44b765e058848ace6f3253fb1602d1d44a63747 + sha256: "4d0968ecb860d7baa15a6e2af3469ec5b0d959e51c59ce84a52b0f7632a4aa5a" url: "https://pub.dev" source: hosted - version: "15.1.4" + version: "15.1.5" firebase_messaging_platform_interface: dependency: transitive description: name: firebase_messaging_platform_interface - sha256: "66aa477277baf2430904096234dd2095ad2e0248d0bfefc1b11695e68bf1790e" + sha256: a2cb3e7d71d40b6612e2d4e0daa0ae759f6a9d07f693f904d14d22aadf70be10 url: "https://pub.dev" source: hosted - version: "4.5.47" + version: "4.5.48" firebase_messaging_web: dependency: transitive description: name: firebase_messaging_web - sha256: "8b590d8c421dc4f63a28c6b9690a050424c28b99a54886ded4510c0806237130" + sha256: "1554e190f0cd9d6fe59f61ae0275ac12006fdb78b07669f1a260d1a9e6de3a1f" url: "https://pub.dev" source: hosted - version: "3.9.3" + version: "3.9.4" fixnum: dependency: "direct main" description: @@ -602,10 +602,10 @@ packages: dependency: "direct main" description: name: fluentui_system_icons - sha256: a9fd6c4dc23016d15a224151848f575f8466aba0665b41cce8a2d157e72c9f36 + sha256: d637972e7e0b34e7accf6a34bf757494a35559959b69ffd0f8926804421faa60 url: "https://pub.dev" source: hosted - version: "1.1.263" + version: "1.1.265" flutter: dependency: "direct main" description: flutter @@ -636,10 +636,10 @@ packages: dependency: "direct main" description: name: flutter_local_notifications - sha256: "725145682706fb0e5a30f93e5cb64f3df7ed7743de749bd555b22bf75ee718c0" + sha256: ef41ae901e7529e52934feba19ed82827b11baa67336829564aeab3129460610 url: "https://pub.dev" source: hosted - version: "18.0.0" + version: "18.0.1" flutter_local_notifications_linux: dependency: transitive description: @@ -745,10 +745,10 @@ packages: dependency: "direct main" description: name: flutter_svg - sha256: "1b7723a814d84fb65869ea7115cdb3ee7c3be5a27a755c1ec60e049f6b9fcbb2" + sha256: "936d9c1c010d3e234d1672574636f3352b4941ca3decaddd3cafaeb9ad49c471" url: "https://pub.dev" source: hosted - version: "2.0.11" + version: "2.0.15" flutter_test: dependency: "direct dev" description: flutter @@ -1013,10 +1013,10 @@ packages: dependency: "direct dev" description: name: json_serializable - sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b + sha256: c2fcb3920cf2b6ae6845954186420fca40bc0a8abcc84903b7801f17d7050d7c url: "https://pub.dev" source: hosted - version: "6.8.0" + version: "6.9.0" leak_tracker: dependency: transitive description: @@ -1093,10 +1093,10 @@ packages: dependency: "direct main" description: name: logger - sha256: "697d067c60c20999686a0add96cf6aba723b3aa1f83ecf806a8097231529ec32" + sha256: be4b23575aac7ebf01f225a241eb7f6b5641eeaf43c6a8613510fc2f8cf187d1 url: "https://pub.dev" source: hosted - version: "2.4.0" + version: "2.5.0" logging: dependency: transitive description: @@ -1205,10 +1205,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: df3eb3e0aed5c1107bb0fdb80a8e82e778114958b1c5ac5644fb1ac9cae8a998 + sha256: da8d9ac8c4b1df253d1a328b7bf01ae77ef132833479ab40763334db13b91cce url: "https://pub.dev" source: hosted - version: "8.1.0" + version: "8.1.1" package_info_plus_platform_interface: dependency: transitive description: @@ -1245,10 +1245,10 @@ packages: dependency: transitive description: name: path_provider_android - sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a + sha256: "8c4967f8b7cb46dc914e178daa29813d83ae502e0529d7b0478330616a691ef7" url: "https://pub.dev" source: hosted - version: "2.2.12" + version: "2.2.14" path_provider_foundation: dependency: transitive description: @@ -1309,10 +1309,10 @@ packages: dependency: transitive description: name: permission_handler_html - sha256: af26edbbb1f2674af65a8f4b56e1a6f526156bc273d0e65dd8075fab51c78851 + sha256: "38f000e83355abb3392140f6bc3030660cfaef189e1f87824facb76300b4ff24" url: "https://pub.dev" source: hosted - version: "0.1.3+2" + version: "0.1.3+5" permission_handler_platform_interface: dependency: transitive description: @@ -1413,10 +1413,10 @@ packages: dependency: transitive description: name: riverpod_analyzer_utils - sha256: dc53a659cb543b203cdc35cd4e942ed08ea893eb6ef12029301323bdf18c5d95 + sha256: c6b8222b2b483cb87ae77ad147d6408f400c64f060df7a225b127f4afef4f8c8 url: "https://pub.dev" source: hosted - version: "0.5.7" + version: "0.5.8" riverpod_annotation: dependency: "direct main" description: @@ -1429,18 +1429,18 @@ packages: dependency: "direct dev" description: name: riverpod_generator - sha256: "54458dac2fea976990dc9ed379060db6ae5c8790143f1963fedd0fb99980a326" + sha256: "63546d70952015f0981361636bf8f356d9cfd9d7f6f0815e3c07789a41233188" url: "https://pub.dev" source: hosted - version: "2.6.2" + version: "2.6.3" riverpod_lint: dependency: "direct dev" description: name: riverpod_lint - sha256: "326efc199b87f21053b9a2afbf2aea26c41b3bf6f8ba346ce69126ee17d16ebd" + sha256: "83e4caa337a9840469b7b9bd8c2351ce85abad80f570d84146911b32086fbd99" url: "https://pub.dev" source: hosted - version: "2.6.2" + version: "2.6.3" rxdart: dependency: transitive description: @@ -1533,10 +1533,10 @@ packages: dependency: transitive description: name: shelf_web_socket - sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611" + sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67 url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "2.0.1" simple_icons: dependency: "direct main" description: @@ -1730,10 +1730,10 @@ packages: dependency: transitive description: name: url_launcher_linux - sha256: e2b9622b4007f97f504cd64c0128309dfb978ae66adbe944125ed9e1750f06af + sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935" url: "https://pub.dev" source: hosted - version: "3.2.0" + version: "3.2.1" url_launcher_macos: dependency: transitive description: @@ -1778,10 +1778,10 @@ packages: dependency: transitive description: name: vector_graphics - sha256: "0b9149c6ddb013818075b072b9ddc1b89a5122fff1275d4648d297086b46c4f0" + sha256: "27d5fefe86fb9aace4a9f8375b56b3c292b64d8c04510df230f849850d912cb7" url: "https://pub.dev" source: hosted - version: "1.1.12" + version: "1.1.15" vector_graphics_codec: dependency: transitive description: @@ -1794,10 +1794,10 @@ packages: dependency: transitive description: name: vector_graphics_compiler - sha256: f3b9b6e4591c11394d4be4806c63e72d3a41778547b2c1e2a8a04fadcfd7d173 + sha256: "1b4b9e706a10294258727674a340ae0d6e64a7231980f9f9a3d12e4b42407aad" url: "https://pub.dev" source: hosted - version: "1.1.12" + version: "1.1.16" vector_math: dependency: transitive description: diff --git a/test/unit_test/model/extensions/enums/algorithms_extension_test.dart b/test/unit_test/model/extensions/enums/algorithms_extension_test.dart index 187987702..a315586c0 100644 --- a/test/unit_test/model/extensions/enums/algorithms_extension_test.dart +++ b/test/unit_test/model/extensions/enums/algorithms_extension_test.dart @@ -7,8 +7,146 @@ void main() { } void _testAlgorithmsExtension() { + final zeroTimestamp = DateTime.fromMillisecondsSinceEpoch(0); + + final oneYearFromEpoch = DateTime.fromMillisecondsSinceEpoch(31536000 * 1000); group('Algorithms Extension', () { - group('generateTOTPCodeString', () {}); + group('generateTOTPCodeString', () { + group('OTP default (lengh 6, interval 30, SHA1)', () { + test('OTP for zero seconds from epoch', () { + final otpValue = Algorithms.SHA1.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 30), + time: zeroTimestamp, + ); + expect(otpValue, equals('328482')); + }); + test('OTP for one year from epoch', () { + final otpValue = Algorithms.SHA1.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 30), + time: oneYearFromEpoch, + ); + expect(otpValue, equals('869960')); + }); + }); + group('different length 8 digits', () { + test('OTP for zero seconds from epoch', () { + final otpValue = Algorithms.SHA1.generateTOTPCodeString( + secret: 'secret', + length: 8, + interval: Duration(seconds: 30), + time: zeroTimestamp, + ); + expect(otpValue, equals('35328482')); + }); + test('OTP for one year from epoch', () { + final otpValue = Algorithms.SHA1.generateTOTPCodeString( + secret: 'secret', + length: 8, + interval: Duration(seconds: 30), + time: oneYearFromEpoch, + ); + expect(otpValue, equals('15869960')); + }); + }); + group('different algorithms SHA 256', () { + test('OTP for zero seconds from epoch', () { + final otpValue = Algorithms.SHA256.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 30), + time: zeroTimestamp, + ); + expect(otpValue, equals('356306')); + }); + test('OTP for one year from epoch', () { + final otpValue = Algorithms.SHA256.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 30), + time: oneYearFromEpoch, + ); + expect(otpValue, equals('213627')); + }); + }); + group('different algorithms SHA 512', () { + test('OTP for zero seconds from epoch', () { + final otpValue = Algorithms.SHA512.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 30), + time: zeroTimestamp, + ); + expect(otpValue, equals('674061')); + }); + test('OTP for one year from epoch', () { + final otpValue = Algorithms.SHA512.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 30), + time: oneYearFromEpoch, + ); + expect(otpValue, equals('495577')); + }); + }); + group('different interval 60 Seconds', () { + test('OTP for zero seconds from epoch', () { + final otpValue = Algorithms.SHA1.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 60), + time: zeroTimestamp, + ); + expect(otpValue, equals('328482')); + }); + test('OTP for one year from epoch', () { + final otpValue = Algorithms.SHA1.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 60), + time: oneYearFromEpoch, + ); + expect(otpValue, equals('383428')); + }); + test('compare half year 60 sec, 1 year 30 sec & hotp value', () { + final oneYear60SecCounter = 31536000 ~/ 60; + final halfYear30SecCounter = 15768000 ~/ 30; + expect(oneYear60SecCounter, equals(halfYear30SecCounter)); + final hotpValue = Algorithms.SHA1.generateHOTPCodeString(secret: 'secret', counter: oneYear60SecCounter, length: 6); + + final otpValueOneYear60Sec = Algorithms.SHA1.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 60), + time: DateTime.fromMillisecondsSinceEpoch(31536000 * 1000), + ); + final otpValueHalfYear30Sec = Algorithms.SHA1.generateTOTPCodeString( + secret: 'secret', + length: 6, + interval: Duration(seconds: 30), + time: DateTime.fromMillisecondsSinceEpoch(15768000 * 1000), + ); + expect(otpValueOneYear60Sec, equals(otpValueHalfYear30Sec)); + expect(otpValueOneYear60Sec, equals(hotpValue)); + }); + }); + group('is not google', () { + test('OTP for zero seconds from epoch', () { + final otpValue = + Algorithms.SHA1.generateTOTPCodeString(secret: 'secret', length: 6, interval: Duration(seconds: 30), time: zeroTimestamp, isGoogle: false); + expect(otpValue, equals('862089')); + }); + test('OTP for one year from epoch', () { + final otpValue = + Algorithms.SHA1.generateTOTPCodeString(secret: 'secret', length: 6, interval: Duration(seconds: 30), time: oneYearFromEpoch, isGoogle: false); + expect(otpValue, equals('265498')); + }); + }); + }); + group('generateHOTPCodeString', () { group('different couters 6 digits', () { test('OTP for counter == 0', () { diff --git a/test/unit_test/utils/customization/application_customization_test.dart b/test/unit_test/utils/customization/application_customization_test.dart index 560799bd7..684e0e798 100644 --- a/test/unit_test/utils/customization/application_customization_test.dart +++ b/test/unit_test/utils/customization/application_customization_test.dart @@ -71,19 +71,19 @@ void _testAppCustomizer() { expect(newCustomization.splashScreenImage.imageData, equals(defaultIconUint8List)); }); group('serialization', () { - test('toJson', () { + test('toJson (new)', () { // Act final json = customization.toJson(); // Assert expect(json['appName'], equals('test')); expect(json['websiteLink'], equals('https://test')); - expect(json['appIcon'], equals({'fileType': 'png', 'imageData': base64Encode(defaultIconUint8List)})); - expect(json['appImage'], equals({'fileType': 'png', 'imageData': base64Encode(defaultImageUint8List)})); + expect(json['appbarIcon'], equals({'fileType': 'png', 'imageData': base64Encode(defaultIconUint8List), 'fileName': 'appbarIcon'})); + expect(json['splashScreenImage'], equals({'fileType': 'png', 'imageData': base64Encode(defaultImageUint8List), 'fileName': 'splashScreenImage'})); expect(json['lightTheme'], equals(ApplicationCustomization.defaultCustomization.lightTheme.toJson())); expect(json['darkTheme'], equals(ApplicationCustomization.defaultCustomization.darkTheme.toJson())); expect(json['disabledFeatures'], equals({AppFeature.patchNotes.name})); }); - test('fromJson', () { + test('fromJson (old)', () { // Act final newCustomization = ApplicationCustomization.fromJson({ 'appName': 'test2', @@ -104,6 +104,31 @@ void _testAppCustomizer() { expect(newCustomization.disabledFeatures, isA()); expect(newCustomization.disabledFeatures, isEmpty); }); + test('fromJson (new)', () { + // Act + final newCustomization = ApplicationCustomization.fromJson({ + 'appName': 'test2', + 'websiteLink': 'https://test2', + 'appbarIcon': {'fileType': 'png', 'imageData': base64Encode(defaultIconUint8List), 'fileName': 'appbarIcon'}, + 'splashScreenImage': {'fileType': 'png', 'imageData': base64Encode(defaultImageUint8List), 'fileName': 'splashScreenImage'}, + 'lightTheme': ApplicationCustomization.defaultCustomization.lightTheme.toJson(), + 'darkTheme': ApplicationCustomization.defaultCustomization.darkTheme.toJson(), + 'disabledFeatures': [], + }); + // Assert + expect(newCustomization.appName, equals('test2')); + expect(newCustomization.websiteLink, equals('https://test2')); + expect(newCustomization.appbarIcon.fileType, equals(ImageFileType.png)); + expect(newCustomization.appbarIcon.imageData, equals(defaultIconUint8List)); + expect(newCustomization.appbarIcon.fileName, equals('appbarIcon')); + expect(newCustomization.splashScreenImage.fileType, equals(ImageFileType.png)); + expect(newCustomization.splashScreenImage.imageData, equals(defaultImageUint8List)); + expect(newCustomization.splashScreenImage.fileName, equals('splashScreenImage')); + expect(newCustomization.lightTheme, equals(ApplicationCustomization.defaultCustomization.lightTheme)); + expect(newCustomization.darkTheme, equals(ApplicationCustomization.defaultCustomization.darkTheme)); + expect(newCustomization.disabledFeatures, isA()); + expect(newCustomization.disabledFeatures, isEmpty); + }); }); }); }