diff --git a/integration_test/views_test.dart b/integration_test/views_test.dart index 444a23e86..4aa7623c3 100644 --- a/integration_test/views_test.dart +++ b/integration_test/views_test.dart @@ -32,7 +32,7 @@ void main() { late final MockTokenFolderRepository mockTokenFolderRepository; late final MockRsaUtils mockRsaUtils; late final MockFirebaseUtils mockFirebaseUtils; - late final MockPrivacyIdeaIOClient mockIOClient; + late final MockPrivacyideaIOClient mockIOClient; late final MockIntroductionRepository mockIntroductionRepository; setUp(() { mockSettingsRepository = MockSettingsRepository(); @@ -63,7 +63,7 @@ void main() { mockFirebaseUtils = MockFirebaseUtils(); when(mockFirebaseUtils.getFBToken()).thenAnswer((_) => Future.value('fbToken')); when(mockRsaUtils.deserializeRSAPublicKeyPKCS1('publicKey')).thenAnswer((_) => RSAPublicKey(BigInt.one, BigInt.one)); - mockIOClient = MockPrivacyIdeaIOClient(); + mockIOClient = MockPrivacyideaIOClient(); when(mockIOClient.doPost( url: anyNamed('url'), body: anyNamed('body'), diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 8b396c1cf..2636604a2 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -10,11 +10,11 @@ 0DCCE7B526CE7AA30029E1D5 /* BuildFile in Resources */ = {isa = PBXBuildFile; }; 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 403BEAD9CEEEF24864419C1C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F729E806F51B040D7B8D1DB /* Pods_Runner.framework */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + B4FBF5C1CAF1E8F7A8E0ADF9 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E8D7023819A25E6583C458F /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -45,20 +45,21 @@ 0D32FBC626A84C0B0033DD09 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/LaunchScreen.strings; sourceTree = ""; }; 0D32FBC726A84E6D0033DD09 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Main.strings; sourceTree = ""; }; 0D32FBC826A84E6D0033DD09 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/LaunchScreen.strings; sourceTree = ""; }; + 12CD62B16AD15C0B40F90E53 /* Pods-Runner.debug-netknights.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug-netknights.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug-netknights.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 1E8D7023819A25E6583C458F /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 29E3D04F2458553B00DFB52B /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; + 31A644BB097DC1A31854E0BC /* Pods-Runner.release-netknights_debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release-netknights_debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release-netknights_debug.xcconfig"; sourceTree = ""; }; 369B8C852B459656000E0321 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; 369B8C872B459656000E0321 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; 36AD5FD02B83589200FB5A82 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 36AD5FD12B8358A400FB5A82 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 4759EE86FDC0E25A4E555CD4 /* Pods-Runner.debug-netknights.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug-netknights.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug-netknights.xcconfig"; sourceTree = ""; }; - 5A6CA23A95D8450431CE0A44 /* Pods-Runner.debug-netknights_debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug-netknights_debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug-netknights_debug.xcconfig"; sourceTree = ""; }; + 4752BB89F680890715134DC4 /* Pods-Runner.release-netknights.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release-netknights.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release-netknights.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 7F729E806F51B040D7B8D1DB /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* (debug) privacyIDEA Authenticator.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "(debug) privacyIDEA Authenticator.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -66,8 +67,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 9F753B1B2B403956AFEA0395 /* Pods-Runner.release-netknights.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release-netknights.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release-netknights.xcconfig"; sourceTree = ""; }; - C58C0B6BA34E653880EA190D /* Pods-Runner.release-netknights_debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release-netknights_debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release-netknights_debug.xcconfig"; sourceTree = ""; }; + DD06BE5D70E55B7EDE1DFEAC /* Pods-Runner.debug-netknights_debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug-netknights_debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug-netknights_debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -75,7 +75,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 403BEAD9CEEEF24864419C1C /* Pods_Runner.framework in Frameworks */, + B4FBF5C1CAF1E8F7A8E0ADF9 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -87,7 +87,7 @@ children = ( 369B8C852B459656000E0321 /* WidgetKit.framework */, 369B8C872B459656000E0321 /* SwiftUI.framework */, - 7F729E806F51B040D7B8D1DB /* Pods_Runner.framework */, + 1E8D7023819A25E6583C458F /* Pods_Runner.framework */, ); name = Frameworks; sourceTree = ""; @@ -95,10 +95,10 @@ 319E74BAB265CB63977BE434 /* Pods */ = { isa = PBXGroup; children = ( - 4759EE86FDC0E25A4E555CD4 /* Pods-Runner.debug-netknights.xcconfig */, - 5A6CA23A95D8450431CE0A44 /* Pods-Runner.debug-netknights_debug.xcconfig */, - 9F753B1B2B403956AFEA0395 /* Pods-Runner.release-netknights.xcconfig */, - C58C0B6BA34E653880EA190D /* Pods-Runner.release-netknights_debug.xcconfig */, + 12CD62B16AD15C0B40F90E53 /* Pods-Runner.debug-netknights.xcconfig */, + DD06BE5D70E55B7EDE1DFEAC /* Pods-Runner.debug-netknights_debug.xcconfig */, + 4752BB89F680890715134DC4 /* Pods-Runner.release-netknights.xcconfig */, + 31A644BB097DC1A31854E0BC /* Pods-Runner.release-netknights_debug.xcconfig */, ); path = Pods; sourceTree = ""; @@ -190,7 +190,7 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 58E13FE4D4B7DE5ACBB1D1B6 /* [CP] Check Pods Manifest.lock */, + 120572E137DCFB813B41E0A0 /* [CP] Check Pods Manifest.lock */, 369B8C942B459657000E0321 /* Embed Foundation Extensions */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, @@ -199,8 +199,8 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 36AD5FCC2B83563A00FB5A82 /* Copy GoogleService-Info.plist */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - CC125C65952EA1D8611AEC7C /* [CP] Embed Pods Frameworks */, - 9DA0E565AC864FB8D64ED279 /* [CP] Copy Pods Resources */, + 333966190DE2F6AF583A6346 /* [CP] Embed Pods Frameworks */, + AC275A3BB6E698A0E7479708 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -264,41 +264,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 36AD5FCC2B83563A00FB5A82 /* Copy GoogleService-Info.plist */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "Copy GoogleService-Info.plist"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "environment=\"default\"\n\n# Regex to extract the scheme name from the Build Configuration\n# We have named our Build Configurations as Debug-dev, Debug-prod etc.\n# Here, dev and prod are the scheme names. This kind of naming is required by Flutter for flavors to work.\n# We are using the $CONFIGURATION variable available in the XCode build environment to extract \n# the environment (or flavor)\n# For eg.\n# If CONFIGURATION=\"Debug-prod\", then environment will get set to \"prod\".\nif [[ $CONFIGURATION =~ -([^-]*)$ ]]; then\nenvironment=${BASH_REMATCH[1]}\nfi\n\necho $environment\n\n# Name and path of the resource we're copying\nGOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist\nGOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}\n\n# Make sure GoogleService-Info.plist exists\necho \"Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_FILE}\"\nif [ ! -f $GOOGLESERVICE_INFO_FILE ]\nthen\necho \"No GoogleService-Info.plist found. Please ensure it's in the proper directory.\"\nexit 1\nfi\n\n# Get a reference to the destination location for the GoogleService-Info.plist\n# This is the default location where Firebase init code expects to find GoogleServices-Info.plist file\nPLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\necho \"Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}\"\n\n# Copy over the prod GoogleService-Info.plist for Release builds\ncp \"${GOOGLESERVICE_INFO_FILE}\" \"${PLIST_DESTINATION}\"\n\n"; - }; - 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", - ); - name = "Thin Binary"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; - }; - 58E13FE4D4B7DE5ACBB1D1B6 /* [CP] Check Pods Manifest.lock */ = { + 120572E137DCFB813B41E0A0 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -320,42 +286,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 9740EEB61CF901F6004384FC /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; - }; - 9DA0E565AC864FB8D64ED279 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/firebase_messaging/firebase_messaging_Privacy.bundle", - "${PODS_CONFIGURATION_BUILD_DIR}/permission_handler_apple/permission_handler_apple_privacy.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/firebase_messaging_Privacy.bundle", - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/permission_handler_apple_privacy.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; - CC125C65952EA1D8611AEC7C /* [CP] Embed Pods Frameworks */ = { + 333966190DE2F6AF583A6346 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -431,6 +362,75 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 36AD5FCC2B83563A00FB5A82 /* Copy GoogleService-Info.plist */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy GoogleService-Info.plist"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "environment=\"default\"\n\n# Regex to extract the scheme name from the Build Configuration\n# We have named our Build Configurations as Debug-dev, Debug-prod etc.\n# Here, dev and prod are the scheme names. This kind of naming is required by Flutter for flavors to work.\n# We are using the $CONFIGURATION variable available in the XCode build environment to extract \n# the environment (or flavor)\n# For eg.\n# If CONFIGURATION=\"Debug-prod\", then environment will get set to \"prod\".\nif [[ $CONFIGURATION =~ -([^-]*)$ ]]; then\nenvironment=${BASH_REMATCH[1]}\nfi\n\necho $environment\n\n# Name and path of the resource we're copying\nGOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist\nGOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/config/${environment}/${GOOGLESERVICE_INFO_PLIST}\n\n# Make sure GoogleService-Info.plist exists\necho \"Looking for ${GOOGLESERVICE_INFO_PLIST} in ${GOOGLESERVICE_INFO_FILE}\"\nif [ ! -f $GOOGLESERVICE_INFO_FILE ]\nthen\necho \"No GoogleService-Info.plist found. Please ensure it's in the proper directory.\"\nexit 1\nfi\n\n# Get a reference to the destination location for the GoogleService-Info.plist\n# This is the default location where Firebase init code expects to find GoogleServices-Info.plist file\nPLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\necho \"Will copy ${GOOGLESERVICE_INFO_PLIST} to final destination: ${PLIST_DESTINATION}\"\n\n# Copy over the prod GoogleService-Info.plist for Release builds\ncp \"${GOOGLESERVICE_INFO_FILE}\" \"${PLIST_DESTINATION}\"\n\n"; + }; + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; + }; + AC275A3BB6E698A0E7479708 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh", + "${PODS_CONFIGURATION_BUILD_DIR}/firebase_messaging/firebase_messaging_Privacy.bundle", + "${PODS_CONFIGURATION_BUILD_DIR}/permission_handler_apple/permission_handler_apple_privacy.bundle", + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/firebase_messaging_Privacy.bundle", + "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/permission_handler_apple_privacy.bundle", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -529,7 +529,7 @@ }; 36AD5FC72B83483100FB5A82 /* Debug-netknights */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 4759EE86FDC0E25A4E555CD4 /* Pods-Runner.debug-netknights.xcconfig */; + baseConfigurationReference = 12CD62B16AD15C0B40F90E53 /* Pods-Runner.debug-netknights.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-netknights"; CLANG_ENABLE_MODULES = YES; @@ -624,7 +624,7 @@ }; 36AD5FC92B834F2A00FB5A82 /* Debug-netknights_debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 5A6CA23A95D8450431CE0A44 /* Pods-Runner.debug-netknights_debug.xcconfig */; + baseConfigurationReference = DD06BE5D70E55B7EDE1DFEAC /* Pods-Runner.debug-netknights_debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-netknights_debug"; CLANG_ENABLE_MODULES = YES; @@ -715,7 +715,7 @@ }; 36AD5FCB2B834F4600FB5A82 /* Release-netknights_debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = C58C0B6BA34E653880EA190D /* Pods-Runner.release-netknights_debug.xcconfig */; + baseConfigurationReference = 31A644BB097DC1A31854E0BC /* Pods-Runner.release-netknights_debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-netknights_debug"; CLANG_ENABLE_MODULES = YES; @@ -805,7 +805,7 @@ }; 97C147071CF9000F007C117D /* Release-netknights */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9F753B1B2B403956AFEA0395 /* Pods-Runner.release-netknights.xcconfig */; + baseConfigurationReference = 4752BB89F680890715134DC4 /* Pods-Runner.release-netknights.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "AppIcon-netknights"; CLANG_ENABLE_MODULES = YES; diff --git a/lib/state_notifiers/push_request_notifier.dart b/lib/state_notifiers/push_request_notifier.dart index 1af024357..ea1d921ac 100644 --- a/lib/state_notifiers/push_request_notifier.dart +++ b/lib/state_notifiers/push_request_notifier.dart @@ -33,7 +33,7 @@ import '../repo/secure_push_request_repository.dart'; import '../utils/custom_int_buffer.dart'; import '../utils/globals.dart'; import '../utils/logger.dart'; -import '../utils/network_utils.dart'; +import '../utils/privacyidea_io_client.dart'; import '../utils/push_provider.dart'; import '../utils/riverpod_providers.dart'; import '../utils/rsa_utils.dart'; @@ -48,19 +48,19 @@ class PushRequestNotifier extends StateNotifier { PushProvider _pushProvider; PushProvider get pushProvider => _pushProvider; - final PrivacyIdeaIOClient _ioClient; + final PrivacyideaIOClient _ioClient; final RsaUtils _rsaUtils; final Map _expirationTimers = {}; PushRequestNotifier({ PushRequestState? initState, - PrivacyIdeaIOClient? ioClient, + PrivacyideaIOClient? ioClient, required PushProvider pushProvider, required this.ref, RsaUtils? rsaUtils, PushRequestRepository? pushRepo, - }) : _ioClient = ioClient ?? const PrivacyIdeaIOClient(), + }) : _ioClient = ioClient ?? const PrivacyideaIOClient(), _pushProvider = pushProvider, _rsaUtils = rsaUtils ?? const RsaUtils(), _pushRepo = pushRepo ?? const SecurePushRequestRepository(), diff --git a/lib/state_notifiers/token_notifier.dart b/lib/state_notifiers/token_notifier.dart index fc396564e..008c9a250 100644 --- a/lib/state_notifiers/token_notifier.dart +++ b/lib/state_notifiers/token_notifier.dart @@ -32,7 +32,7 @@ import '../utils/globals.dart'; import '../utils/identifiers.dart'; import '../utils/lock_auth.dart'; import '../utils/logger.dart'; -import '../utils/network_utils.dart'; +import '../utils/privacyidea_io_client.dart'; import '../utils/riverpod_providers.dart'; import '../utils/rsa_utils.dart'; import '../utils/utils.dart'; @@ -47,7 +47,7 @@ class TokenNotifier extends StateNotifier { final _updatingTokensMutex = Mutex(); final TokenRepository _repo; final RsaUtils _rsaUtils; - final PrivacyIdeaIOClient _ioClient; + final PrivacyideaIOClient _ioClient; final FirebaseUtils _firebaseUtils; TokenNotifier({ @@ -55,11 +55,11 @@ class TokenNotifier extends StateNotifier { TokenState? initialState, TokenRepository? repository, RsaUtils? rsaUtils, - PrivacyIdeaIOClient? ioClient, + PrivacyideaIOClient? ioClient, FirebaseUtils? firebaseUtils, }) : _rsaUtils = rsaUtils ?? const RsaUtils(), _repo = repository ?? const SecureTokenRepository(), - _ioClient = ioClient ?? const PrivacyIdeaIOClient(), + _ioClient = ioClient ?? const PrivacyideaIOClient(), _firebaseUtils = firebaseUtils ?? FirebaseUtils(), super( initialState ?? TokenState(tokens: const [], lastlyUpdatedTokens: const []), @@ -282,23 +282,9 @@ class TokenNotifier extends StateNotifier { /// There is no need to use mutexes because the updating functions are always using the latest version of the updating tokens. */ - /// Adds a new token and returns true if successful, false if not. - Future addNewToken(Token token) async { - final success = await _addOrReplaceToken(token); - await _handlePushTokensIfExist(); - return success; - } - /// Adds or replaces a token and returns true if successful, false if not. Future addOrReplaceToken(Token token) => _addOrReplaceToken(token); - /// Adds new tokens and returns the tokens that could not be added. - Future> addTokens(List tokens) async { - final failedTokens = await _addOrReplaceTokens(tokens); - await _handlePushTokensIfExist(); - return failedTokens; - } - /// Adds or replaces a list of tokens and returns the tokens that could not be added or replaced. Future> addOrReplaceTokens(List tokens) => _addOrReplaceTokens(tokens); @@ -758,7 +744,7 @@ class TokenNotifier extends StateNotifier { Future _handlePushTokensIfExist() async { Logger.info('Handling push tokens if they exist.', name: 'token_notifier.dart#_handlePushTokensIfExist'); final pushTokens = state.pushTokens; - if (pushTokens.isNotEmpty || state.hasOTPTokens == false) { + if (pushTokens.isEmpty || state.pushTokens.isEmpty) { if (ref.read(settingsProvider).hidePushTokens == true) { ref.read(settingsProvider.notifier).setHidePushTokens(false); } diff --git a/lib/utils/network_utils.dart b/lib/utils/privacyidea_io_client.dart similarity index 81% rename from lib/utils/network_utils.dart rename to lib/utils/privacyidea_io_client.dart index a544ba6a9..63ad96cd0 100644 --- a/lib/utils/network_utils.dart +++ b/lib/utils/privacyidea_io_client.dart @@ -32,8 +32,8 @@ import '../utils/logger.dart'; import '../utils/riverpod_providers.dart'; import '../utils/view_utils.dart'; -class PrivacyIdeaIOClient { - const PrivacyIdeaIOClient(); +class PrivacyideaIOClient { + const PrivacyideaIOClient(); /// Dummy network request can be used to trigger the network access permission /// on iOS devices. Doing this at an appropriate place in the code can prevent @@ -113,11 +113,19 @@ class PrivacyIdeaIOClient { Response response; try { response = await ioClient.post(url, body: body).timeout(const Duration(seconds: 15)); - } on HandshakeException catch (e, s) { - response = Response('${e.runtimeType} : $s', 525); - } catch (e, s) { - if (e is! TimeoutException && e is! SocketException && e is! ClientException) rethrow; - response = Response('${e.runtimeType} : $s', 404); + } on HandshakeException catch (e, _) { + Logger.info('Handshake failed. sslVerify: $sslVerify', name: 'utils.dart#doPost'); + showMessage(message: 'Handshake failed, please check the server certificate and try again.'); + response = Response('${e.runtimeType}', 525); + } on TimeoutException catch (e, _) { + Logger.info('TimeoutException', name: 'utils.dart#doPost'); + response = Response('${e.runtimeType}', 408); + } on SocketException catch (e, _) { + Logger.info('SocketException', name: 'utils.dart#doPost'); + response = Response('${e.runtimeType}', 404); + } catch (e, _) { + Logger.info('Unknown exception', name: 'utils.dart#doPost'); + response = Response('${e.runtimeType}', 404); } if (response.statusCode != 200) { @@ -165,13 +173,19 @@ class PrivacyIdeaIOClient { Uri uri = Uri.parse(buffer.toString()); try { response = await ioClient.get(uri).timeout(const Duration(seconds: 15)); - } on HandshakeException catch (e, s) { - Logger.warning('Handshake failed. sslVerify: $sslVerify', name: 'utils.dart#doGet', error: e, stackTrace: s); + } on HandshakeException catch (e, _) { + Logger.info('Handshake failed. sslVerify: $sslVerify', name: 'utils.dart#doGet'); showMessage(message: 'Handshake failed, please check the server certificate and try again.'); - rethrow; - } catch (e, s) { - if (e is! TimeoutException && e is! SocketException) rethrow; - response = Response('${e.runtimeType} : $s', 404); + response = Response('${e.runtimeType}', 525); + } on TimeoutException catch (e, _) { + Logger.info('TimeoutException', name: 'utils.dart#doGet'); + response = Response('${e.runtimeType}', 408); + } on SocketException catch (e, _) { + Logger.info('SocketException', name: 'utils.dart#doGet'); + response = Response('${e.runtimeType}', 404); + } catch (e, _) { + Logger.info('Unknown exception', name: 'utils.dart#doGet'); + response = Response('${e.runtimeType}', 404); } if (response.statusCode != 200) { diff --git a/lib/utils/push_provider.dart b/lib/utils/push_provider.dart index 6154de860..3ecc8cf5c 100644 --- a/lib/utils/push_provider.dart +++ b/lib/utils/push_provider.dart @@ -37,7 +37,7 @@ import '../repo/secure_token_repository.dart'; import 'firebase_utils.dart'; import 'globals.dart'; import 'logger.dart'; -import 'network_utils.dart'; +import 'privacyidea_io_client.dart'; import 'riverpod_providers.dart'; import 'rsa_utils.dart'; import 'utils.dart'; @@ -58,19 +58,19 @@ class PushProvider { FirebaseUtils _firebaseUtils; FirebaseUtils get firebaseUtils => _firebaseUtils; bool _firebaseInitialized = false; - PrivacyIdeaIOClient _ioClient; - PrivacyIdeaIOClient get ioClient => _ioClient; + PrivacyideaIOClient _ioClient; + PrivacyideaIOClient get ioClient => _ioClient; RsaUtils _rsaUtils; RsaUtils get rsaUtils => _rsaUtils; LegacyUtils _legacyUtils; PushProvider._({ FirebaseUtils? firebaseUtils, - PrivacyIdeaIOClient? ioClient, + PrivacyideaIOClient? ioClient, RsaUtils? rsaUtils, LegacyUtils? legacyUtils, }) : _firebaseUtils = firebaseUtils ?? FirebaseUtils(), - _ioClient = ioClient ?? const PrivacyIdeaIOClient(), + _ioClient = ioClient ?? const PrivacyideaIOClient(), _rsaUtils = rsaUtils ?? const RsaUtils(), _legacyUtils = legacyUtils ?? const LegacyUtils() { _initFirebase(); @@ -103,7 +103,7 @@ class PushProvider { factory PushProvider({ bool? pollingEnabled, - PrivacyIdeaIOClient? ioClient, + PrivacyideaIOClient? ioClient, RsaUtils? rsaUtils, FirebaseUtils? firebaseUtils, }) { @@ -355,7 +355,7 @@ class PushProvider { try { response = instance != null ? await instance!._ioClient.doGet(url: token.url!, parameters: parameters, sslVerify: token.sslVerify) - : await const PrivacyIdeaIOClient().doGet(url: token.url!, parameters: parameters, sslVerify: token.sslVerify); + : await const PrivacyideaIOClient().doGet(url: token.url!, parameters: parameters, sslVerify: token.sslVerify); } catch (e) { if (isManually) { globalRef?.read(statusMessageProvider.notifier).state = ( @@ -428,9 +428,9 @@ class PlaceholderPushProvider implements PushProvider { @override FirebaseUtils get firebaseUtils => _firebaseUtils; @override - PrivacyIdeaIOClient _ioClient = const PrivacyIdeaIOClient(); + PrivacyideaIOClient _ioClient = const PrivacyideaIOClient(); @override - PrivacyIdeaIOClient get ioClient => _ioClient; + PrivacyideaIOClient get ioClient => _ioClient; @override LegacyUtils _legacyUtils = const LegacyUtils(); @override diff --git a/lib/widgets/deactivateable_refresh_indicator.dart b/lib/widgets/deactivateable_refresh_indicator.dart index 8dbe598f4..7313a4fb0 100644 --- a/lib/widgets/deactivateable_refresh_indicator.dart +++ b/lib/widgets/deactivateable_refresh_indicator.dart @@ -16,7 +16,9 @@ class DeactivateableRefreshIndicator extends StatelessWidget { Widget build(BuildContext context) { return allowToRefresh ? RefreshIndicator( - onRefresh: onRefresh, + onRefresh: () async { + onRefresh(); + }, backgroundColor: Theme.of(context).scaffoldBackgroundColor, triggerMode: RefreshIndicatorTriggerMode.anywhere, child: child, diff --git a/pubspec.yaml b/pubspec.yaml index 6ab698610..54a683f18 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,8 @@ publish_to: none # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 4.4.0+404007 # TODO Set the right version number +version: 4.4.0+404008 # TODO Set the right version number + # version: major.minor.build + 2x major|2x minor|3x build # version: version number + build number (optional) # android: build-name + versionCode diff --git a/test/tests_app_wrapper.dart b/test/tests_app_wrapper.dart index 3bbc2ce15..2d9bc4c32 100644 --- a/test/tests_app_wrapper.dart +++ b/test/tests_app_wrapper.dart @@ -8,14 +8,14 @@ import 'package:privacyidea_authenticator/interfaces/repo/settings_repository.da import 'package:privacyidea_authenticator/interfaces/repo/token_folder_repository.dart'; import 'package:privacyidea_authenticator/interfaces/repo/token_repository.dart'; import 'package:privacyidea_authenticator/utils/firebase_utils.dart'; -import 'package:privacyidea_authenticator/utils/network_utils.dart'; +import 'package:privacyidea_authenticator/utils/privacyidea_io_client.dart'; import 'package:privacyidea_authenticator/utils/rsa_utils.dart'; @GenerateNiceMocks([ MockSpec(), MockSpec(), MockSpec(), - MockSpec(), + MockSpec(), MockSpec(), MockSpec(), MockSpec(), diff --git a/test/tests_app_wrapper.mocks.dart b/test/tests_app_wrapper.mocks.dart index 3d940a926..040771d76 100644 --- a/test/tests_app_wrapper.mocks.dart +++ b/test/tests_app_wrapper.mocks.dart @@ -27,7 +27,8 @@ import 'package:privacyidea_authenticator/model/token_folder.dart' as _i11; import 'package:privacyidea_authenticator/model/tokens/push_token.dart' as _i16; import 'package:privacyidea_authenticator/model/tokens/token.dart' as _i8; import 'package:privacyidea_authenticator/utils/firebase_utils.dart' as _i17; -import 'package:privacyidea_authenticator/utils/network_utils.dart' as _i12; +import 'package:privacyidea_authenticator/utils/privacyidea_io_client.dart' + as _i12; import 'package:privacyidea_authenticator/utils/rsa_utils.dart' as _i13; // ignore_for_file: type=lint @@ -244,11 +245,11 @@ class MockTokenFolderRepository extends _i1.Mock ) as _i7.Future>); } -/// A class which mocks [PrivacyIdeaIOClient]. +/// A class which mocks [PrivacyideaIOClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrivacyIdeaIOClient extends _i1.Mock - implements _i12.PrivacyIdeaIOClient { +class MockPrivacyideaIOClient extends _i1.Mock + implements _i12.PrivacyideaIOClient { @override _i7.Future triggerNetworkAccessPermission({ required Uri? url, diff --git a/test/unit_test/state_notifiers/push_request_notifier_test.dart b/test/unit_test/state_notifiers/push_request_notifier_test.dart index 272d424f8..e4739fa7e 100644 --- a/test/unit_test/state_notifiers/push_request_notifier_test.dart +++ b/test/unit_test/state_notifiers/push_request_notifier_test.dart @@ -8,14 +8,14 @@ import 'package:privacyidea_authenticator/model/states/push_request_state.dart'; import 'package:privacyidea_authenticator/model/tokens/push_token.dart'; import 'package:privacyidea_authenticator/state_notifiers/push_request_notifier.dart'; import 'package:privacyidea_authenticator/utils/custom_int_buffer.dart'; -import 'package:privacyidea_authenticator/utils/network_utils.dart'; +import 'package:privacyidea_authenticator/utils/privacyidea_io_client.dart'; import 'package:privacyidea_authenticator/utils/push_provider.dart'; import 'package:privacyidea_authenticator/utils/rsa_utils.dart'; import 'package:mockito/annotations.dart'; import 'push_request_notifier_test.mocks.dart'; -@GenerateMocks([RsaUtils, PrivacyIdeaIOClient, PushProvider, PushRequestRepository]) +@GenerateMocks([RsaUtils, PrivacyideaIOClient, PushProvider, PushRequestRepository]) void main() { _testPushRequestNotifier(); } @@ -24,7 +24,7 @@ void _testPushRequestNotifier() { group('PushRequestNotifier', () { test('accept', () async { final container = ProviderContainer(); - final mockIoClient = MockPrivacyIdeaIOClient(); + final mockIoClient = MockPrivacyideaIOClient(); final mockPushProvider = MockPushProvider(); final mockRsaUtils = MockRsaUtils(); final mockPushRepo = MockPushRequestRepository(); @@ -82,7 +82,7 @@ void _testPushRequestNotifier() { }); test('decline', () async { final container = ProviderContainer(); - final mockIoClient = MockPrivacyIdeaIOClient(); + final mockIoClient = MockPrivacyideaIOClient(); final mockPushProvider = MockPushProvider(); final mockRsaUtils = MockRsaUtils(); final mockPushRepo = MockPushRequestRepository(); @@ -139,7 +139,7 @@ void _testPushRequestNotifier() { test('add', () async { final container = ProviderContainer(); - final mockIoClient = MockPrivacyIdeaIOClient(); + final mockIoClient = MockPrivacyideaIOClient(); final mockPushProvider = MockPushProvider(); final mockRsaUtils = MockRsaUtils(); final mockPushRepo = MockPushRequestRepository(); @@ -175,7 +175,7 @@ void _testPushRequestNotifier() { }); test('remove', () async { final container = ProviderContainer(); - final mockIoClient = MockPrivacyIdeaIOClient(); + final mockIoClient = MockPrivacyideaIOClient(); final mockPushProvider = MockPushProvider(); final mockRsaUtils = MockRsaUtils(); final mockPushRepo = MockPushRequestRepository(); diff --git a/test/unit_test/state_notifiers/push_request_notifier_test.mocks.dart b/test/unit_test/state_notifiers/push_request_notifier_test.mocks.dart index f5830f31c..545b8e59d 100644 --- a/test/unit_test/state_notifiers/push_request_notifier_test.mocks.dart +++ b/test/unit_test/state_notifiers/push_request_notifier_test.mocks.dart @@ -17,7 +17,8 @@ import 'package:privacyidea_authenticator/model/states/push_request_state.dart' as _i7; import 'package:privacyidea_authenticator/model/tokens/push_token.dart' as _i11; import 'package:privacyidea_authenticator/utils/firebase_utils.dart' as _i4; -import 'package:privacyidea_authenticator/utils/network_utils.dart' as _i5; +import 'package:privacyidea_authenticator/utils/privacyidea_io_client.dart' + as _i5; import 'package:privacyidea_authenticator/utils/push_provider.dart' as _i12; import 'package:privacyidea_authenticator/utils/rsa_utils.dart' as _i6; @@ -86,9 +87,9 @@ class _FakeFirebaseUtils_4 extends _i1.SmartFake implements _i4.FirebaseUtils { ); } -class _FakePrivacyIdeaIOClient_5 extends _i1.SmartFake - implements _i5.PrivacyIdeaIOClient { - _FakePrivacyIdeaIOClient_5( +class _FakePrivacyideaIOClient_5 extends _i1.SmartFake + implements _i5.PrivacyideaIOClient { + _FakePrivacyideaIOClient_5( Object parent, Invocation parentInvocation, ) : super( @@ -318,12 +319,12 @@ class MockRsaUtils extends _i1.Mock implements _i6.RsaUtils { ) as _i9.Uint8List); } -/// A class which mocks [PrivacyIdeaIOClient]. +/// A class which mocks [PrivacyideaIOClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrivacyIdeaIOClient extends _i1.Mock - implements _i5.PrivacyIdeaIOClient { - MockPrivacyIdeaIOClient() { +class MockPrivacyideaIOClient extends _i1.Mock + implements _i5.PrivacyideaIOClient { + MockPrivacyideaIOClient() { _i1.throwOnMissingStub(this); } @@ -440,13 +441,13 @@ class MockPushProvider extends _i1.Mock implements _i12.PushProvider { ) as _i4.FirebaseUtils); @override - _i5.PrivacyIdeaIOClient get ioClient => (super.noSuchMethod( + _i5.PrivacyideaIOClient get ioClient => (super.noSuchMethod( Invocation.getter(#ioClient), - returnValue: _FakePrivacyIdeaIOClient_5( + returnValue: _FakePrivacyideaIOClient_5( this, Invocation.getter(#ioClient), ), - ) as _i5.PrivacyIdeaIOClient); + ) as _i5.PrivacyideaIOClient); @override _i6.RsaUtils get rsaUtils => (super.noSuchMethod( diff --git a/test/unit_test/state_notifiers/sortable_notifier_test.dart b/test/unit_test/state_notifiers/sortable_notifier_test.dart index 95fc8cab2..2d411e08a 100644 --- a/test/unit_test/state_notifiers/sortable_notifier_test.dart +++ b/test/unit_test/state_notifiers/sortable_notifier_test.dart @@ -2,10 +2,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/mockito.dart'; import 'package:privacyidea_authenticator/model/enums/algorithms.dart'; +import 'package:privacyidea_authenticator/model/states/settings_state.dart'; import 'package:privacyidea_authenticator/model/token_folder.dart'; import 'package:privacyidea_authenticator/model/tokens/hotp_token.dart'; import 'package:privacyidea_authenticator/model/tokens/token.dart'; import 'package:privacyidea_authenticator/model/tokens/totp_token.dart'; +import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart'; import 'package:privacyidea_authenticator/state_notifiers/sortable_notifier.dart'; import 'package:privacyidea_authenticator/state_notifiers/token_folder_notifier.dart'; import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart'; @@ -20,6 +22,8 @@ void main() { void _testSortableNotifier() { group('SortableNotifier test', () { test('handleNewList', () async { + final mockSettingsRepo = MockSettingsRepository(); + when(mockSettingsRepo.loadSettings()).thenAnswer((_) async => SettingsState()); final MockTokenFolderRepository mockTokenFolderRepository = MockTokenFolderRepository(); final MockTokenRepository mockTokenRepository = MockTokenRepository(); List tokenFolderState = [ @@ -51,6 +55,7 @@ void _testSortableNotifier() { }); final container = ProviderContainer(overrides: [ + settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)), tokenFolderProvider.overrideWith((ref) => TokenFolderNotifier(repository: mockTokenFolderRepository)), tokenProvider.overrideWith((ref) => TokenNotifier(repository: mockTokenRepository, ref: ref)), ]); @@ -63,8 +68,6 @@ void _testSortableNotifier() { final newState = await sortableNotifier.handleNewStateList(newTokenState); final newSortableState = container.read(sortableProvider); - print('newSortableState: $newSortableState'); - print('newState: $newState'); expect(newState.length, 6); expect(newSortableState.length, 6); expect(newSortableState[0], isA()); diff --git a/test/unit_test/state_notifiers/token_notifier_test.dart b/test/unit_test/state_notifiers/token_notifier_test.dart index 3436fb812..6020583af 100644 --- a/test/unit_test/state_notifiers/token_notifier_test.dart +++ b/test/unit_test/state_notifiers/token_notifier_test.dart @@ -20,7 +20,7 @@ import 'package:privacyidea_authenticator/state_notifiers/settings_notifier.dart import 'package:privacyidea_authenticator/state_notifiers/token_notifier.dart'; import 'package:privacyidea_authenticator/utils/firebase_utils.dart'; import 'package:privacyidea_authenticator/utils/logger.dart'; -import 'package:privacyidea_authenticator/utils/network_utils.dart'; +import 'package:privacyidea_authenticator/utils/privacyidea_io_client.dart'; import 'package:privacyidea_authenticator/utils/riverpod_providers.dart'; import 'package:privacyidea_authenticator/utils/rsa_utils.dart'; @@ -31,7 +31,7 @@ import 'token_notifier_test.mocks.dart'; TokenRepository, SettingsRepository, RsaUtils, - PrivacyIdeaIOClient, + PrivacyideaIOClient, FirebaseUtils, LegacyUtils, ], @@ -71,7 +71,11 @@ void _testTokenNotifier() { verify(mockRepo.loadTokens()).called(2); }); test('getTokenFromId', () async { - final container = ProviderContainer(); + final mockSettingsRepo = MockSettingsRepository(); + when(mockSettingsRepo.loadSettings()).thenAnswer((_) async => SettingsState()); + final container = ProviderContainer(overrides: [ + settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)), + ]); final mockRepo = MockTokenRepository(); final mockFirebaseUtils = MockFirebaseUtils(); final before = [HOTPToken(label: 'label', issuer: 'issuer', id: 'id', algorithm: Algorithms.SHA1, digits: 6, secret: 'secret')]; @@ -91,7 +95,11 @@ void _testTokenNotifier() { expect(state.tokens, after); }); test('incrementCounter', () async { - final container = ProviderContainer(); + final mockSettingsRepo = MockSettingsRepository(); + when(mockSettingsRepo.loadSettings()).thenAnswer((_) async => SettingsState()); + final container = ProviderContainer(overrides: [ + settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)), + ]); final mockRepo = MockTokenRepository(); final mockFirebaseUtils = MockFirebaseUtils(); final before = [ @@ -117,7 +125,11 @@ void _testTokenNotifier() { verify(mockRepo.saveOrReplaceToken(after.first)).called(1); }); test('removeToken', () async { - final container = ProviderContainer(); + final mockSettingsRepo = MockSettingsRepository(); + when(mockSettingsRepo.loadSettings()).thenAnswer((_) async => SettingsState()); + final container = ProviderContainer(overrides: [ + settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)), + ]); final mockRepo = MockTokenRepository(); final mockFirebaseUtils = MockFirebaseUtils(); final before = [ @@ -145,7 +157,11 @@ void _testTokenNotifier() { }); group('addOrReplaceToken', () { test('add Token', () async { - final container = ProviderContainer(); + final mockSettingsRepo = MockSettingsRepository(); + when(mockSettingsRepo.loadSettings()).thenAnswer((_) async => SettingsState()); + final container = ProviderContainer(overrides: [ + settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)), + ]); final mockRepo = MockTokenRepository(); final mockFirebaseUtils = MockFirebaseUtils(); final before = [ @@ -172,7 +188,11 @@ void _testTokenNotifier() { verify(mockRepo.saveOrReplaceToken(after.last)).called(1); }); test('replace Token', () async { - final container = ProviderContainer(); + final mockSettingsRepo = MockSettingsRepository(); + when(mockSettingsRepo.loadSettings()).thenAnswer((_) async => SettingsState()); + final container = ProviderContainer(overrides: [ + settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)), + ]); final mockRepo = MockTokenRepository(); final mockFirebaseUtils = MockFirebaseUtils(); final before = [ @@ -201,7 +221,11 @@ void _testTokenNotifier() { }); }); test('addOrReplaceTokens', () async { - final container = ProviderContainer(); + final mockSettingsRepo = MockSettingsRepository(); + when(mockSettingsRepo.loadSettings()).thenAnswer((_) async => SettingsState()); + final container = ProviderContainer(overrides: [ + settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)), + ]); final mockRepo = MockTokenRepository(); final mockFirebaseUtils = MockFirebaseUtils(); final before = [ @@ -261,7 +285,7 @@ void _testTokenNotifier() { ]); final mockTokenRepo = MockTokenRepository(); final mockRsaUtils = MockRsaUtils(); - final mockIOClient = MockPrivacyIdeaIOClient(); + final mockIOClient = MockPrivacyideaIOClient(); final mockFirebaseUtils = MockFirebaseUtils(); const rsaUtils = RsaUtils(); const publicServerKeyString = @@ -371,7 +395,7 @@ void _testTokenNotifier() { settingsProvider.overrideWith((ref) => SettingsNotifier(repository: mockSettingsRepo)), ]); final mockRepo = MockTokenRepository(); - final mockIOClient = MockPrivacyIdeaIOClient(); + final mockIOClient = MockPrivacyideaIOClient(); final mockFirebaseUtils = MockFirebaseUtils(); final mockRsaUtils = MockRsaUtils(); final uri = Uri.parse('https://example.com'); diff --git a/test/unit_test/state_notifiers/token_notifier_test.mocks.dart b/test/unit_test/state_notifiers/token_notifier_test.mocks.dart index 4d45662e1..a950d5238 100644 --- a/test/unit_test/state_notifiers/token_notifier_test.mocks.dart +++ b/test/unit_test/state_notifiers/token_notifier_test.mocks.dart @@ -21,7 +21,8 @@ import 'package:privacyidea_authenticator/model/states/settings_state.dart' import 'package:privacyidea_authenticator/model/tokens/push_token.dart' as _i12; import 'package:privacyidea_authenticator/model/tokens/token.dart' as _i7; import 'package:privacyidea_authenticator/utils/firebase_utils.dart' as _i14; -import 'package:privacyidea_authenticator/utils/network_utils.dart' as _i13; +import 'package:privacyidea_authenticator/utils/privacyidea_io_client.dart' + as _i13; import 'package:privacyidea_authenticator/utils/rsa_utils.dart' as _i9; // ignore_for_file: type=lint @@ -390,12 +391,12 @@ class MockRsaUtils extends _i1.Mock implements _i9.RsaUtils { ) as _i11.Uint8List); } -/// A class which mocks [PrivacyIdeaIOClient]. +/// A class which mocks [PrivacyideaIOClient]. /// /// See the documentation for Mockito's code generation for more information. -class MockPrivacyIdeaIOClient extends _i1.Mock - implements _i13.PrivacyIdeaIOClient { - MockPrivacyIdeaIOClient() { +class MockPrivacyideaIOClient extends _i1.Mock + implements _i13.PrivacyideaIOClient { + MockPrivacyideaIOClient() { _i1.throwOnMissingStub(this); }