From 95343967c8eb042b42e908e01d969a0b428647f2 Mon Sep 17 00:00:00 2001 From: Michael Law <1365977+lawmicha@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:13:28 -0400 Subject: [PATCH 1/6] fix(datastore): call errorHandler in Sync operation when failure --- .../Sync/InitialSync/InitialSyncOperation.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOperation.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOperation.swift index 8ba67f6295..d90392260a 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOperation.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOperation.swift @@ -130,10 +130,13 @@ final class InitialSyncOperation: AsynchronousOperation { switch result { case .failure(let apiError): if self.isAuthSignedOutError(apiError: apiError) { - self.dataStoreConfiguration.errorHandler(DataStoreError.api(apiError)) + self.log.error("Sync for \(self.modelSchema.name) failed due to signed out error \(apiError.errorDescription)") } + // TODO: Retry query on error - self.finish(result: .failure(DataStoreError.api(apiError))) + let error = DataStoreError.api(apiError) + self.dataStoreConfiguration.errorHandler(error) + self.finish(result: .failure(error)) case .success(let graphQLResult): self.handleQueryResults(lastSyncTime: lastSyncTime, graphQLResult: graphQLResult) } From da81405b1fdb900bada3e4607c05f743732325f1 Mon Sep 17 00:00:00 2001 From: Michael Law <1365977+lawmicha@users.noreply.github.com> Date: Tue, 26 Sep 2023 11:26:40 -0400 Subject: [PATCH 2/6] chore: Update CHANGELOG.md for 2.18.0 (#3236) --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae38d59b4f..e5f8dbe5eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Features - Setting mininum watchOS version to 9 (#3229) +- change swift-tools-version to 5.7 (#3193) ## 2.17.2 (2023-09-18) From 0432e8efc774ba15b11edeae2c3591890dfd779b Mon Sep 17 00:00:00 2001 From: Tuan Pham <103537251+phantumcode@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:38:36 -0500 Subject: [PATCH 3/6] chore: remove unnecessary CloudWatch dependency from logger plugin (#3235) --- Package.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Package.swift b/Package.swift index b3b5351397..959479d75f 100644 --- a/Package.swift +++ b/Package.swift @@ -378,7 +378,6 @@ let loggingTargets: [Target] = [ dependencies: [ .target(name: "Amplify"), .target(name: "AWSPluginsCore"), - .product(name: "AWSCloudWatch", package: "aws-sdk-swift"), .product(name: "AWSCloudWatchLogs", package: "aws-sdk-swift"), ], path: "AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin" From 0a37e4a041ff5320a9616733bf85adfe08b1424e Mon Sep 17 00:00:00 2001 From: Tuan Pham <103537251+phantumcode@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:39:11 -0500 Subject: [PATCH 4/6] test(logging): add logging plugin integration test (#3218) * test: add logging pluging integration test * test(logging): add logging integration tests * test(logging): add logging integ test * test(logging): add more test cases * chore(logging): clean up build configuration * test: fix integration test in command line * chore: update integration test configuration * test(logging): remove logging integration test from integration test suite * test integration on branch * fix integration test names * introduce delay in getting current user id * resolve issue with parallel integration tests running on multiple platforms * revert base integration workflow to include all integration tests --- .github/workflows/integ_test.yml | 5 + .github/workflows/integ_test_logging.yml | 90 ++ .../AWSCloudWatchLoggingPlugin.swift | 2 +- .../AWSCloudWatchClientHelper.swift | 23 + ...udWatchLoggingPluginIntegrationTests.swift | 254 +++++ .../README.md | 15 + .../TestConfigHelper.swift | 53 ++ .../project.pbxproj | 888 ++++++++++++++++++ ...atchLoggingPluginIntegrationTests.xcscheme | 52 + ...oggingPluginIntegrationTestsWatch.xcscheme | 54 ++ .../CloudWatchLoggingHostApp.xcscheme | 88 ++ .../CloudWatchLoggingWatchApp.xcscheme | 88 ++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 98 ++ .../Assets.xcassets/Contents.json | 6 + .../CloudWatchLoggingApp.swift | 17 + .../ContentView.swift | 21 + .../Preview Assets.xcassets/Contents.json | 6 + 18 files changed, 1770 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/integ_test_logging.yml create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/AWSCloudWatchClientHelper.swift create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/AWSCloudWatchLoggingPluginIntegrationTests.swift create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/README.md create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/TestConfigHelper.swift create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/project.pbxproj create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/AWSCloudWatchLoggingPluginIntegrationTests.xcscheme create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/AWSCloudWatchLoggingPluginIntegrationTestsWatch.xcscheme create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/CloudWatchLoggingHostApp.xcscheme create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/CloudWatchLoggingWatchApp.xcscheme create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/Contents.json create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/CloudWatchLoggingApp.swift create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/ContentView.swift create mode 100644 AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/.github/workflows/integ_test.yml b/.github/workflows/integ_test.yml index 3d1d396912..daf6be7467 100644 --- a/.github/workflows/integ_test.yml +++ b/.github/workflows/integ_test.yml @@ -64,3 +64,8 @@ jobs: needs: prepare-for-test uses: ./.github/workflows/integ_test_storage.yml secrets: inherit + + logging-test: + needs: prepare-for-test + uses: ./.github/workflows/integ_test_logging.yml + secrets: inherit diff --git a/.github/workflows/integ_test_logging.yml b/.github/workflows/integ_test_logging.yml new file mode 100644 index 0000000000..b745f3d142 --- /dev/null +++ b/.github/workflows/integ_test_logging.yml @@ -0,0 +1,90 @@ +name: Integration Tests | Logging +on: + workflow_dispatch: + workflow_call: + +permissions: + id-token: write + contents: read + +jobs: + logging-integration-test-iOS: + runs-on: macos-12 + environment: IntegrationTest + steps: + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + persist-credentials: false + + - name: Make directory + run: mkdir -p ~/.aws-amplify/amplify-ios/testconfiguration/ + + - name: Copy integration test resouces + uses: ./.github/composite_actions/download_test_configuration + with: + resource_subfolder: logging + aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws_region: ${{ secrets.AWS_REGION }} + aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG_V2 }} + + - name: Run Integration test + uses: ./.github/composite_actions/run_xcodebuild_test + with: + project_path: ./AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp + scheme: AWSCloudWatchLoggingPluginIntegrationTests + + logging-integration-test-tvOS: + runs-on: macos-13 + environment: IntegrationTest + steps: + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + persist-credentials: false + + - name: Make directory + run: mkdir -p ~/.aws-amplify/amplify-ios/testconfiguration/ + + - name: Copy integration test resouces + uses: ./.github/composite_actions/download_test_configuration + with: + resource_subfolder: logging + aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws_region: ${{ secrets.AWS_REGION }} + aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG_V2 }} + + - name: Run Integration test + uses: ./.github/composite_actions/run_xcodebuild_test + with: + project_path: ./AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp + scheme: AWSCloudWatchLoggingPluginIntegrationTests + destination: platform=tvOS Simulator,name=Apple TV 4K (3rd generation),OS=latest + sdk: appletvsimulator + xcode_path: '/Applications/Xcode_14.3.app' + + logging-integration-test-watchOS: + runs-on: macos-13 + environment: IntegrationTest + steps: + - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + persist-credentials: false + + - name: Make directory + run: mkdir -p ~/.aws-amplify/amplify-ios/testconfiguration/ + + - name: Copy integration test resouces + uses: ./.github/composite_actions/download_test_configuration + with: + resource_subfolder: logging + aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }} + aws_region: ${{ secrets.AWS_REGION }} + aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG_V2 }} + + - name: Run Integration test + uses: ./.github/composite_actions/run_xcodebuild_test + with: + project_path: ./AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp + scheme: AWSCloudWatchLoggingPluginIntegrationTestsWatch + destination: platform=watchOS Simulator,name=Apple Watch Series 8 (45mm),OS=latest + sdk: watchsimulator + xcode_path: '/Applications/Xcode_14.3.app' diff --git a/AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin/AWSCloudWatchLoggingPlugin.swift b/AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin/AWSCloudWatchLoggingPlugin.swift index 8f40831cf7..e740e0618a 100644 --- a/AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin/AWSCloudWatchLoggingPlugin.swift +++ b/AmplifyPlugins/Logging/Sources/AWSCloudWatchLoggingPlugin/AWSCloudWatchLoggingPlugin.swift @@ -155,7 +155,7 @@ public class AWSCloudWatchLoggingPlugin: LoggingCategoryPlugin { localStore.reset() } - DispatchQueue.main.async { + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) { self.loggingClient.takeUserIdentifierFromCurrentUser() } } diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/AWSCloudWatchClientHelper.swift b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/AWSCloudWatchClientHelper.swift new file mode 100644 index 0000000000..caf0f08be1 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/AWSCloudWatchClientHelper.swift @@ -0,0 +1,23 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import Foundation +import AWSCloudWatchLogs + +class AWSCloudWatchClientHelper { + static func getFilterLogEventCount(client: CloudWatchLogsClientProtocol?, filterPattern: String?, startTime: Date?, endTime: Date?, logGroupName: String?) async throws -> [CloudWatchLogsClientTypes.FilteredLogEvent]? { + let filterEventInput = FilterLogEventsInput(endTime: endTime?.epochMilliseconds, filterPattern: filterPattern, logGroupName: logGroupName, startTime: startTime?.epochMilliseconds) + let response = try await client?.filterLogEvents(input: filterEventInput) + return response?.events + } +} + +extension Date { + var epochMilliseconds: Int { + Int(self.timeIntervalSince1970 * 1_000) + } +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/AWSCloudWatchLoggingPluginIntegrationTests.swift b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/AWSCloudWatchLoggingPluginIntegrationTests.swift new file mode 100644 index 0000000000..7befffdcc9 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/AWSCloudWatchLoggingPluginIntegrationTests.swift @@ -0,0 +1,254 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import XCTest +import AWSCloudWatchLogs +@testable import Amplify +@testable import AWSCognitoAuthPlugin +@testable import AWSCloudWatchLoggingPlugin + +class AWSCloudWatchLoggingPluginIntergrationTests: XCTestCase { + let amplifyConfigurationFile = "testconfiguration/AWSCloudWatchLoggingPluginIntegrationTests-amplifyconfiguration" + let amplifyConfigurationLoggingFile = "testconfiguration/AWSCloudWatchLoggingPluginIntegrationTests-amplifyconfiguration_logging" + var loggingConfiguration: AWSCloudWatchLoggingPluginConfiguration? + + override func setUp() async throws { + continueAfterFailure = false + do { + try Amplify.add(plugin: AWSCognitoAuthPlugin()) + let loggingConfigurationFile = try TestConfigHelper.retrieveLoggingConfiguration(forResource: amplifyConfigurationLoggingFile) + loggingConfiguration = try AWSCloudWatchLoggingPluginConfiguration.loadConfiguration(from: loggingConfigurationFile) + let loggingPlugin = AWSCloudWatchLoggingPlugin(loggingPluginConfiguration: loggingConfiguration) + try Amplify.add(plugin: loggingPlugin) + let configuration = try TestConfigHelper.retrieveAmplifyConfiguration(forResource: amplifyConfigurationFile) + try Amplify.configure(configuration) + try await Task.sleep(seconds: 5) + } catch { + XCTFail("Failed to initialize and configure Amplify: \(error)") + } + XCTAssertNotNil(Amplify.Auth.plugin) + XCTAssertTrue(Amplify.Auth.isConfigured) + } + + override func tearDown() async throws { + await Amplify.reset() + } + + /// - Given: a AWS CloudWatch Logging plugin + /// - When: the escape hatch is requested + /// - Then: the AWS CloudWatch client is returned + func testGetEscapeHatch() throws { + let plugin = try Amplify.Logging.getPlugin(for: "awsCloudWatchLoggingPlugin") + guard let loggingPlugin = plugin as? AWSCloudWatchLoggingPlugin else { + XCTFail("Could not get plugin of type AWSCloudWatchLoggingPlugin") + return + } + let cloudWatchClient = loggingPlugin.getEscapeHatch() + XCTAssertNotNil(cloudWatchClient) + } + + /// - Given: a AWS CloudWatch Logging plugin + /// - When: an error log message is logged and flushed + /// - Then: the error log message is logged and sent to AWS CloudWatch + func testFlushLogWithErrorMessage() async throws { + let category = "Analytics" + let namespace = UUID().uuidString + let message = "this is an error message in the integration test \(Date().epochMilliseconds)" + let logger = Amplify.Logging.logger(forCategory: category, forNamespace: namespace) + logger.error(message) + let plugin = try Amplify.Logging.getPlugin(for: "awsCloudWatchLoggingPlugin") + guard let loggingPlugin = plugin as? AWSCloudWatchLoggingPlugin else { + XCTFail("Could not get plugin of type AWSCloudWatchLoggingPlugin") + return + } + try await loggingPlugin.flushLogs() + try await Task.sleep(seconds: 30) + let cloudWatchClient = loggingPlugin.getEscapeHatch() + try await verifyMessageSent(client: cloudWatchClient, + logGroupName: loggingConfiguration?.logGroupName, + logLevel: "error", + message: message, + category: category, + namespace: namespace) + } + + /// - Given: a AWS CloudWatch Logging plugin + /// - When: an warn log message is logged and flushed + /// - Then: the warn log message is logged and sent to AWS CloudWatch + func testFlushLogWithWarnMessage() async throws { + let category = "API" + let namespace = UUID().uuidString + let message = "this is an warn message in the integration test \(Date().epochMilliseconds)" + let logger = Amplify.Logging.logger(forCategory: category, forNamespace: namespace) + logger.warn(message) + let plugin = try Amplify.Logging.getPlugin(for: "awsCloudWatchLoggingPlugin") + guard let loggingPlugin = plugin as? AWSCloudWatchLoggingPlugin else { + XCTFail("Could not get plugin of type AWSCloudWatchLoggingPlugin") + return + } + try await loggingPlugin.flushLogs() + try await Task.sleep(seconds: 30) + let cloudWatchClient = loggingPlugin.getEscapeHatch() + try await verifyMessageSent(client: cloudWatchClient, + logGroupName: loggingConfiguration?.logGroupName, + logLevel: "warn", + message: message, + category: category, + namespace: namespace) + } + + /// - Given: a AWS CloudWatch Logging plugin + /// - When: an debug log message is logged and flushed + /// - Then: the debug log message is logged and sent to AWS CloudWatch + func testFlushLogWithDebugMessage() async throws { + let category = "Geo" + let namespace = UUID().uuidString + let dateFormatter = DateFormatter() + dateFormatter.dateStyle = .long + dateFormatter.timeStyle = .long + let message = "this is an debug message in the integration test \(Date().epochMilliseconds)" + let logger = Amplify.Logging.logger(forCategory: category, forNamespace: namespace) + logger.debug(message) + let plugin = try Amplify.Logging.getPlugin(for: "awsCloudWatchLoggingPlugin") + guard let loggingPlugin = plugin as? AWSCloudWatchLoggingPlugin else { + XCTFail("Could not get plugin of type AWSCloudWatchLoggingPlugin") + return + } + try await loggingPlugin.flushLogs() + try await Task.sleep(seconds: 30) + let cloudWatchClient = loggingPlugin.getEscapeHatch() + try await verifyMessageSent(client: cloudWatchClient, + logGroupName: loggingConfiguration?.logGroupName, + logLevel: "debug", + message: message, + category: category, + namespace: namespace) + } + + /// - Given: a AWS CloudWatch Logging plugin + /// - When: an info log message is logged and flushed + /// - Then: the info log message is logged and sent to AWS CloudWatch + func testFlushLogWithInfoMessage() async throws { + let category = "Auth" + let namespace = UUID().uuidString + let message = "this is an info message in the integration test \(Date().epochMilliseconds)" + let logger = Amplify.Logging.logger(forCategory: category, forNamespace: namespace) + logger.info(message) + let plugin = try Amplify.Logging.getPlugin(for: "awsCloudWatchLoggingPlugin") + guard let loggingPlugin = plugin as? AWSCloudWatchLoggingPlugin else { + XCTFail("Could not get plugin of type AWSCloudWatchLoggingPlugin") + return + } + try await loggingPlugin.flushLogs() + try await Task.sleep(seconds: 30) + let cloudWatchClient = loggingPlugin.getEscapeHatch() + try await verifyMessageSent(client: cloudWatchClient, + logGroupName: loggingConfiguration?.logGroupName, + logLevel: "info", + message: message, + category: category, + namespace: namespace) + } + + /// - Given: a AWS CloudWatch Logging plugin with logging enabled + /// - When: an error log message is logged and flushed + /// - Then: the eror log message is logged and sent to AWS CloudWatch + func testFlushLogWithVerboseMessageAfterEnablingPlugin() async throws { + let category = "Storage" + let namespace = UUID().uuidString + let message = "this is an verbose message in the integration test after enabling logging \(Date().epochMilliseconds)" + let logger = Amplify.Logging.logger(forCategory: category, forNamespace: namespace) + Amplify.Logging.enable() + logger.verbose(message) + let plugin = try Amplify.Logging.getPlugin(for: "awsCloudWatchLoggingPlugin") + guard let loggingPlugin = plugin as? AWSCloudWatchLoggingPlugin else { + XCTFail("Could not get plugin of type AWSCloudWatchLoggingPlugin") + return + } + try await loggingPlugin.flushLogs() + try await Task.sleep(seconds: 30) + let cloudWatchClient = loggingPlugin.getEscapeHatch() + try await verifyMessageSent(client: cloudWatchClient, + logGroupName: loggingConfiguration?.logGroupName, + logLevel: "verbose", + message: message, + category: category, + namespace: namespace) + } + + /// - Given: a AWS CloudWatch Logging plugin with logging disabled + /// - When: an error log message is logged and flushed + /// - Then: the eror log message is not logged and sent to AWS CloudWatch + func testFlushLogWithVerboseMessageAfterDisablingPlugin() async throws { + let category = "Storage" + let namespace = UUID().uuidString + let message = "this is an verbose message in the integration test after disabling logging \(Date().epochMilliseconds)" + let logger = Amplify.Logging.logger(forCategory: category, forNamespace: namespace) + Amplify.Logging.disable() + logger.verbose(message) + let plugin = try Amplify.Logging.getPlugin(for: "awsCloudWatchLoggingPlugin") + guard let loggingPlugin = plugin as? AWSCloudWatchLoggingPlugin else { + XCTFail("Could not get plugin of type AWSCloudWatchLoggingPlugin") + return + } + try await loggingPlugin.flushLogs() + try await Task.sleep(seconds: 30) + let cloudWatchClient = loggingPlugin.getEscapeHatch() + try await verifyMessageNotSent(client: cloudWatchClient, + logGroupName: loggingConfiguration?.logGroupName, + message: message) + } + + func verifyMessageSent(client: CloudWatchLogsClientProtocol?, + logGroupName: String?, + logLevel: String, + message: String, + category: String, + namespace: String) async throws { + + let events = try await getLastMessageSent(client: client, logGroupName: logGroupName, message: message, requestAttempt: 0) + XCTAssertEqual(events?.count, 1) + guard let sentLogMessage = events?.first?.message else { + XCTFail("Unable to verify last log message") + return + } + XCTAssertTrue(sentLogMessage.lowercased().contains(logLevel)) + XCTAssertTrue(sentLogMessage.contains(message)) + XCTAssertTrue(sentLogMessage.contains(category)) + XCTAssertTrue(sentLogMessage.contains(namespace)) + } + + func verifyMessageNotSent(client: CloudWatchLogsClientProtocol?, + logGroupName: String?, + message: String) async throws { + + let events = try await getLastMessageSent(client: client, logGroupName: logGroupName, message: message, requestAttempt: 0) + XCTAssertEqual(events?.count, 0) + } + + func getLastMessageSent(client: CloudWatchLogsClientProtocol?, + logGroupName: String?, + message: String, + requestAttempt: Int) async throws -> [CloudWatchLogsClientTypes.FilteredLogEvent]? { + let endTime = Date() + let durationInMinutes = requestAttempt+1 + let startTime = endTime.addingTimeInterval(TimeInterval(-durationInMinutes*60)) + var events = try await AWSCloudWatchClientHelper.getFilterLogEventCount(client: client, filterPattern: message, startTime: startTime, endTime: endTime, logGroupName: logGroupName) + + if events?.count == 0 && requestAttempt <= 5 { + try await Task.sleep(seconds: 30) + let attempted = requestAttempt + 1 + events = try await getLastMessageSent( + client: client, + logGroupName: logGroupName, + message: message, + requestAttempt: attempted) + } + + return events + } +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/README.md b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/README.md new file mode 100644 index 0000000000..fa4c128b6c --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/README.md @@ -0,0 +1,15 @@ +## AWS CloudWatch Logging Integration Tests + +The following steps demonstrate how to set up Logging. Auth category is also required to allow unauthenticated and authenticated access. + +### Set-up + +1. Configure app with Auth category + +2. Copy `amplifyconfiguration.json` to a new file named `AWSCloudWatchLoggingPluginIntegrationTests-amplifyconfiguration.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`. + +3. Configure the `amplifyconfiguration-logging.json` file + +4. Copy `amplifyconfiguration-logging.json` to a new file named `AWSCloudWatchLoggingPluginIntegrationTests-amplifyconfiguration-logging.json` inside `~/.aws-amplify/amplify-ios/testconfiguration/`. + +3. You can now run all of the integration tests. diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/TestConfigHelper.swift b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/TestConfigHelper.swift new file mode 100644 index 0000000000..71bc4096d0 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/AWSCloudWatchLoggingPluginIntegrationTests/TestConfigHelper.swift @@ -0,0 +1,53 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import Foundation +@testable import Amplify + +class TestConfigHelper { + + static func retrieveAmplifyConfiguration(forResource: String) throws -> AmplifyConfiguration { + + let data = try retrieve(forResource: forResource) + return try AmplifyConfiguration.decodeAmplifyConfiguration(from: data) + } + + static func retrieveCredentials(forResource: String) throws -> [String: String] { + let data = try retrieve(forResource: forResource) + + let jsonOptional = try JSONSerialization.jsonObject(with: data, options: []) as? [String: String] + guard let json = jsonOptional else { + throw TestConfigError.jsonError("Could not deserialize `\(forResource)` into JSON object") + } + + return json + } + + static func retrieve(forResource: String) throws -> Data { + guard let path = Bundle(for: self).path(forResource: forResource, ofType: "json") else { + throw TestConfigError.bundlePathError("Could not retrieve configuration file: \(forResource)") + } + + let url = URL(fileURLWithPath: path) + return try Data(contentsOf: url) + } + + static func retrieveLoggingConfiguration(forResource: String) throws -> URL { + guard let path = Bundle(for: self).path(forResource: forResource, ofType: "json") else { + throw TestConfigError.bundlePathError("Could not retrieve logging configuration file: \(forResource)") + } + + return URL(fileURLWithPath: path) + } +} + +enum TestConfigError: Error { + + case jsonError(String) + + case bundlePathError(String) +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/project.pbxproj b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..5e3d1d941f --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/project.pbxproj @@ -0,0 +1,888 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + 730C2E772AAA8A4B00878E67 /* AWSCloudWatchClientHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 730C2E762AAA8A4B00878E67 /* AWSCloudWatchClientHelper.swift */; }; + 733390E92AAB8A6A006E3625 /* Amplify in Frameworks */ = {isa = PBXBuildFile; productRef = 733390E82AAB8A6A006E3625 /* Amplify */; }; + 733390EB2AAB8A6E006E3625 /* AWSCloudWatchLoggingPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 733390EA2AAB8A6E006E3625 /* AWSCloudWatchLoggingPlugin */; }; + 733390ED2AAB8A74006E3625 /* AWSCognitoAuthPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 733390EC2AAB8A74006E3625 /* AWSCognitoAuthPlugin */; }; + 73578A2C2AAB945E00505FB3 /* CloudWatchLoggingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97AD223128230B98001AFCC1 /* CloudWatchLoggingApp.swift */; }; + 73578A2D2AAB946300505FB3 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97AD223328230B98001AFCC1 /* ContentView.swift */; }; + 73578A3B2AAB94ED00505FB3 /* AWSCloudWatchLoggingPluginIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DB824628233A1D00FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.swift */; }; + 73578A3C2AAB94F100505FB3 /* AWSCloudWatchClientHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 730C2E762AAA8A4B00878E67 /* AWSCloudWatchClientHelper.swift */; }; + 73578A3D2AAB94F600505FB3 /* TestConfigHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DB82542823466800FC2228 /* TestConfigHelper.swift */; }; + 73607C792AA93466005105E6 /* Amplify in Frameworks */ = {isa = PBXBuildFile; productRef = 73607C782AA93466005105E6 /* Amplify */; }; + 73607C7B2AA93469005105E6 /* AWSCloudWatchLoggingPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 73607C7A2AA93469005105E6 /* AWSCloudWatchLoggingPlugin */; }; + 73607C7D2AA9346D005105E6 /* AWSCognitoAuthPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 73607C7C2AA9346D005105E6 /* AWSCognitoAuthPlugin */; }; + 73C43A2E2AB4ED800010F1B3 /* Amplify in Frameworks */ = {isa = PBXBuildFile; productRef = 73C43A2D2AB4ED800010F1B3 /* Amplify */; }; + 73C43A302AB4ED850010F1B3 /* AWSCognitoAuthPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 73C43A2F2AB4ED850010F1B3 /* AWSCognitoAuthPlugin */; }; + 73C43A322AB4ED8A0010F1B3 /* AWSCloudWatchLoggingPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 73C43A312AB4ED8A0010F1B3 /* AWSCloudWatchLoggingPlugin */; }; + 97AD223228230B98001AFCC1 /* CloudWatchLoggingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97AD223128230B98001AFCC1 /* CloudWatchLoggingApp.swift */; }; + 97AD223428230B98001AFCC1 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97AD223328230B98001AFCC1 /* ContentView.swift */; }; + 97AD223628230B9A001AFCC1 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97AD223528230B9A001AFCC1 /* Assets.xcassets */; }; + 97AD223928230B9A001AFCC1 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97AD223828230B9A001AFCC1 /* Preview Assets.xcassets */; }; + 97DB8245282339D200FC2228 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 97DB8244282339D200FC2228 /* README.md */; }; + 97DB824728233A1D00FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DB824628233A1D00FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.swift */; }; + 97DB82552823466800FC2228 /* TestConfigHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97DB82542823466800FC2228 /* TestConfigHelper.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 73578A362AAB94D100505FB3 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97AD222628230B98001AFCC1 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 733390D22AAB8A3B006E3625; + remoteInfo = CloudWatchLoggingWatchApp; + }; + 97DB823F282339B700FC2228 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97AD222628230B98001AFCC1 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97AD222D28230B98001AFCC1; + remoteInfo = GeoHostApp; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 730C2E762AAA8A4B00878E67 /* AWSCloudWatchClientHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSCloudWatchClientHelper.swift; sourceTree = ""; }; + 733390D32AAB8A3B006E3625 /* CloudWatchLoggingWatchApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CloudWatchLoggingWatchApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 73578A322AAB94D100505FB3 /* AWSCloudWatchLoggingPluginIntegrationTestsWatch.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AWSCloudWatchLoggingPluginIntegrationTestsWatch.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 73C80DCD2AA932AC002771DD /* amplify-swift */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "amplify-swift"; path = ../../../..; sourceTree = ""; }; + 97AD222E28230B98001AFCC1 /* CloudWatchLoggingHostApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CloudWatchLoggingHostApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97AD223128230B98001AFCC1 /* CloudWatchLoggingApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudWatchLoggingApp.swift; sourceTree = ""; }; + 97AD223328230B98001AFCC1 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 97AD223528230B9A001AFCC1 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97AD223828230B9A001AFCC1 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 97DB823B282339B700FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AWSCloudWatchLoggingPluginIntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 97DB8244282339D200FC2228 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + 97DB824628233A1D00FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AWSCloudWatchLoggingPluginIntegrationTests.swift; sourceTree = ""; }; + 97DB82542823466800FC2228 /* TestConfigHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestConfigHelper.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 733390D02AAB8A3B006E3625 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 733390E92AAB8A6A006E3625 /* Amplify in Frameworks */, + 733390EB2AAB8A6E006E3625 /* AWSCloudWatchLoggingPlugin in Frameworks */, + 733390ED2AAB8A74006E3625 /* AWSCognitoAuthPlugin in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 73578A2F2AAB94D100505FB3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 73C43A2E2AB4ED800010F1B3 /* Amplify in Frameworks */, + 73C43A302AB4ED850010F1B3 /* AWSCognitoAuthPlugin in Frameworks */, + 73C43A322AB4ED8A0010F1B3 /* AWSCloudWatchLoggingPlugin in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97AD222B28230B98001AFCC1 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 73607C792AA93466005105E6 /* Amplify in Frameworks */, + 73607C7B2AA93469005105E6 /* AWSCloudWatchLoggingPlugin in Frameworks */, + 73607C7D2AA9346D005105E6 /* AWSCognitoAuthPlugin in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97DB8238282339B700FC2228 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 97AD222528230B98001AFCC1 = { + isa = PBXGroup; + children = ( + 97DB824C28233F2B00FC2228 /* Packages */, + 97AD223028230B98001AFCC1 /* CloudWatchLoggingHostApp */, + 97DB823C282339B700FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests */, + 97AD222F28230B98001AFCC1 /* Products */, + 97DB824E2823417000FC2228 /* Frameworks */, + ); + sourceTree = ""; + }; + 97AD222F28230B98001AFCC1 /* Products */ = { + isa = PBXGroup; + children = ( + 97AD222E28230B98001AFCC1 /* CloudWatchLoggingHostApp.app */, + 97DB823B282339B700FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.xctest */, + 733390D32AAB8A3B006E3625 /* CloudWatchLoggingWatchApp.app */, + 73578A322AAB94D100505FB3 /* AWSCloudWatchLoggingPluginIntegrationTestsWatch.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97AD223028230B98001AFCC1 /* CloudWatchLoggingHostApp */ = { + isa = PBXGroup; + children = ( + 97AD223128230B98001AFCC1 /* CloudWatchLoggingApp.swift */, + 97AD223328230B98001AFCC1 /* ContentView.swift */, + 97AD223528230B9A001AFCC1 /* Assets.xcassets */, + 97AD223728230B9A001AFCC1 /* Preview Content */, + ); + path = CloudWatchLoggingHostApp; + sourceTree = ""; + }; + 97AD223728230B9A001AFCC1 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 97AD223828230B9A001AFCC1 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 97DB823C282339B700FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests */ = { + isa = PBXGroup; + children = ( + 97DB824628233A1D00FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.swift */, + 730C2E762AAA8A4B00878E67 /* AWSCloudWatchClientHelper.swift */, + 97DB82542823466800FC2228 /* TestConfigHelper.swift */, + 97DB8244282339D200FC2228 /* README.md */, + ); + path = AWSCloudWatchLoggingPluginIntegrationTests; + sourceTree = ""; + }; + 97DB824C28233F2B00FC2228 /* Packages */ = { + isa = PBXGroup; + children = ( + 73C80DCD2AA932AC002771DD /* amplify-swift */, + ); + name = Packages; + sourceTree = ""; + }; + 97DB824E2823417000FC2228 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 733390D22AAB8A3B006E3625 /* CloudWatchLoggingWatchApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 733390E62AAB8A3C006E3625 /* Build configuration list for PBXNativeTarget "CloudWatchLoggingWatchApp" */; + buildPhases = ( + 733390CF2AAB8A3B006E3625 /* Sources */, + 733390D02AAB8A3B006E3625 /* Frameworks */, + 733390D12AAB8A3B006E3625 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CloudWatchLoggingWatchApp; + packageProductDependencies = ( + 733390E82AAB8A6A006E3625 /* Amplify */, + 733390EA2AAB8A6E006E3625 /* AWSCloudWatchLoggingPlugin */, + 733390EC2AAB8A74006E3625 /* AWSCognitoAuthPlugin */, + ); + productName = "CloudWatchLoggingWatchApp Watch App"; + productReference = 733390D32AAB8A3B006E3625 /* CloudWatchLoggingWatchApp.app */; + productType = "com.apple.product-type.application"; + }; + 73578A312AAB94D100505FB3 /* AWSCloudWatchLoggingPluginIntegrationTestsWatch */ = { + isa = PBXNativeTarget; + buildConfigurationList = 73578A382AAB94D100505FB3 /* Build configuration list for PBXNativeTarget "AWSCloudWatchLoggingPluginIntegrationTestsWatch" */; + buildPhases = ( + 73578A2E2AAB94D100505FB3 /* Sources */, + 73578A2F2AAB94D100505FB3 /* Frameworks */, + 73578A302AAB94D100505FB3 /* Resources */, + 73EB19C52ABB4669007455F5 /* Copy Configuration Folder */, + ); + buildRules = ( + ); + dependencies = ( + 73578A372AAB94D100505FB3 /* PBXTargetDependency */, + ); + name = AWSCloudWatchLoggingPluginIntegrationTestsWatch; + packageProductDependencies = ( + 73C43A2D2AB4ED800010F1B3 /* Amplify */, + 73C43A2F2AB4ED850010F1B3 /* AWSCognitoAuthPlugin */, + 73C43A312AB4ED8A0010F1B3 /* AWSCloudWatchLoggingPlugin */, + ); + productName = AWSCloudWatchLoggingPluginIntegrationTestsWatch; + productReference = 73578A322AAB94D100505FB3 /* AWSCloudWatchLoggingPluginIntegrationTestsWatch.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97AD222D28230B98001AFCC1 /* CloudWatchLoggingHostApp */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97AD223C28230B9A001AFCC1 /* Build configuration list for PBXNativeTarget "CloudWatchLoggingHostApp" */; + buildPhases = ( + 97AD222A28230B98001AFCC1 /* Sources */, + 97AD222B28230B98001AFCC1 /* Frameworks */, + 97AD222C28230B98001AFCC1 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CloudWatchLoggingHostApp; + packageProductDependencies = ( + 73607C782AA93466005105E6 /* Amplify */, + 73607C7A2AA93469005105E6 /* AWSCloudWatchLoggingPlugin */, + 73607C7C2AA9346D005105E6 /* AWSCognitoAuthPlugin */, + ); + productName = GeoHostApp; + productReference = 97AD222E28230B98001AFCC1 /* CloudWatchLoggingHostApp.app */; + productType = "com.apple.product-type.application"; + }; + 97DB823A282339B700FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97DB8243282339B700FC2228 /* Build configuration list for PBXNativeTarget "AWSCloudWatchLoggingPluginIntegrationTests" */; + buildPhases = ( + 97DB8237282339B700FC2228 /* Sources */, + 97DB8238282339B700FC2228 /* Frameworks */, + 97DB8239282339B700FC2228 /* Resources */, + 97DB82512823429C00FC2228 /* Copy Configuration Folder */, + ); + buildRules = ( + ); + dependencies = ( + 97DB8240282339B700FC2228 /* PBXTargetDependency */, + ); + name = AWSCloudWatchLoggingPluginIntegrationTests; + productName = AWSLocationGeoPluginIntegrationTests; + productReference = 97DB823B282339B700FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97AD222628230B98001AFCC1 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1430; + LastUpgradeCheck = 1320; + TargetAttributes = { + 733390D22AAB8A3B006E3625 = { + CreatedOnToolsVersion = 14.3; + }; + 73578A312AAB94D100505FB3 = { + CreatedOnToolsVersion = 14.3; + TestTargetID = 733390D22AAB8A3B006E3625; + }; + 97AD222D28230B98001AFCC1 = { + CreatedOnToolsVersion = 13.2.1; + }; + 97DB823A282339B700FC2228 = { + CreatedOnToolsVersion = 13.2.1; + LastSwiftMigration = 1320; + TestTargetID = 97AD222D28230B98001AFCC1; + }; + }; + }; + buildConfigurationList = 97AD222928230B98001AFCC1 /* Build configuration list for PBXProject "CloudWatchLoggingHostApp" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97AD222528230B98001AFCC1; + productRefGroup = 97AD222F28230B98001AFCC1 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97AD222D28230B98001AFCC1 /* CloudWatchLoggingHostApp */, + 97DB823A282339B700FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests */, + 733390D22AAB8A3B006E3625 /* CloudWatchLoggingWatchApp */, + 73578A312AAB94D100505FB3 /* AWSCloudWatchLoggingPluginIntegrationTestsWatch */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 733390D12AAB8A3B006E3625 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 73578A302AAB94D100505FB3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97AD222C28230B98001AFCC1 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97AD223928230B9A001AFCC1 /* Preview Assets.xcassets in Resources */, + 97AD223628230B9A001AFCC1 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97DB8239282339B700FC2228 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97DB8245282339D200FC2228 /* README.md in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 73EB19C52ABB4669007455F5 /* Copy Configuration Folder */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy Configuration Folder"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "TEMP_FILE=$HOME/.aws-amplify/amplify-ios/testconfiguration/.\nDEST_PATH=\"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/testconfiguration/\"\n\nif [[ ! -d $TEMP_FILE ]] ; then\n echo \"${TEMP_FILE} does not exist. Using empty configuration.\"\n exit 0\nfi\n \nif [[ -f $DEST_PATH ]] ; then\n rm $DEST_PATH\nfi\n \ncp -r $TEMP_FILE $DEST_PATH\n\n"; + }; + 97DB82512823429C00FC2228 /* Copy Configuration Folder */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Copy Configuration Folder"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "TEMP_FILE=$HOME/.aws-amplify/amplify-ios/testconfiguration/.\nDEST_PATH=\"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/testconfiguration/\"\n\nif [[ ! -d $TEMP_FILE ]] ; then\n echo \"${TEMP_FILE} does not exist. Using empty configuration.\"\n exit 0\nfi\n \nif [[ -f $DEST_PATH ]] ; then\n rm $DEST_PATH\nfi\n \ncp -r $TEMP_FILE $DEST_PATH\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 733390CF2AAB8A3B006E3625 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 73578A2D2AAB946300505FB3 /* ContentView.swift in Sources */, + 73578A2C2AAB945E00505FB3 /* CloudWatchLoggingApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 73578A2E2AAB94D100505FB3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 73578A3D2AAB94F600505FB3 /* TestConfigHelper.swift in Sources */, + 73578A3C2AAB94F100505FB3 /* AWSCloudWatchClientHelper.swift in Sources */, + 73578A3B2AAB94ED00505FB3 /* AWSCloudWatchLoggingPluginIntegrationTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97AD222A28230B98001AFCC1 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97AD223428230B98001AFCC1 /* ContentView.swift in Sources */, + 97AD223228230B98001AFCC1 /* CloudWatchLoggingApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97DB8237282339B700FC2228 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 730C2E772AAA8A4B00878E67 /* AWSCloudWatchClientHelper.swift in Sources */, + 97DB824728233A1D00FC2228 /* AWSCloudWatchLoggingPluginIntegrationTests.swift in Sources */, + 97DB82552823466800FC2228 /* TestConfigHelper.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 73578A372AAB94D100505FB3 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 733390D22AAB8A3B006E3625 /* CloudWatchLoggingWatchApp */; + targetProxy = 73578A362AAB94D100505FB3 /* PBXContainerItemProxy */; + }; + 97DB8240282339B700FC2228 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97AD222D28230B98001AFCC1 /* CloudWatchLoggingHostApp */; + targetProxy = 97DB823F282339B700FC2228 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 733390E42AAB8A3C006E3625 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = ""; + DEVELOPMENT_TEAM = W3DRXD72QU; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_CFBundleDisplayName = CloudWatchLoggingWatchApp; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_WKWatchOnly = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.logging.CloudWatchLoggingWatchApp.watchkitapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 9.4; + }; + name = Debug; + }; + 733390E52AAB8A3C006E3625 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = ""; + DEVELOPMENT_TEAM = W3DRXD72QU; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_CFBundleDisplayName = CloudWatchLoggingWatchApp; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + INFOPLIST_KEY_WKWatchOnly = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.logging.CloudWatchLoggingWatchApp.watchkitapp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + WATCHOS_DEPLOYMENT_TARGET = 9.4; + }; + name = Release; + }; + 73578A392AAB94D100505FB3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = W3DRXD72QU; + GENERATE_INFOPLIST_FILE = YES; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.logging.AWSCloudWatchLoggingPluginIntegrationTestsWatch; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CloudWatchLoggingWatchApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/CloudWatchLoggingWatchApp"; + WATCHOS_DEPLOYMENT_TARGET = 9.4; + }; + name = Debug; + }; + 73578A3A2AAB94D100505FB3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = W3DRXD72QU; + GENERATE_INFOPLIST_FILE = YES; + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.logging.AWSCloudWatchLoggingPluginIntegrationTestsWatch; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = watchos; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = 4; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CloudWatchLoggingWatchApp.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/CloudWatchLoggingWatchApp"; + WATCHOS_DEPLOYMENT_TARGET = 9.4; + }; + name = Release; + }; + 97AD223A28230B9A001AFCC1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TVOS_DEPLOYMENT_TARGET = 16.4; + WATCHOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Debug; + }; + 97AD223B28230B9A001AFCC1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TVOS_DEPLOYMENT_TARGET = 16.4; + VALIDATE_PRODUCT = YES; + WATCHOS_DEPLOYMENT_TARGET = 9.0; + }; + name = Release; + }; + 97AD223D28230B9A001AFCC1 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"CloudWatchLoggingHostApp/Preview Content\""; + DEVELOPMENT_TEAM = W3DRXD72QU; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = NO; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.logging.CloudWatchLoggingHostApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; + TVOS_DEPLOYMENT_TARGET = 16.4; + WATCHOS_DEPLOYMENT_TARGET = 9.4; + }; + name = Debug; + }; + 97AD223E28230B9A001AFCC1 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"CloudWatchLoggingHostApp/Preview Content\""; + DEVELOPMENT_TEAM = W3DRXD72QU; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = NO; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.logging.CloudWatchLoggingHostApp; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; + TVOS_DEPLOYMENT_TARGET = 16.4; + WATCHOS_DEPLOYMENT_TARGET = 9.4; + }; + name = Release; + }; + 97DB8241282339B700FC2228 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = W3DRXD72QU; + GENERATE_INFOPLIST_FILE = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.amazon.com.AWSCloudWatchLoggingPluginIntegrationTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = YES; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CloudWatchLoggingHostApp.app/CloudWatchLoggingHostApp"; + TVOS_DEPLOYMENT_TARGET = 16.4; + WATCHOS_DEPLOYMENT_TARGET = 9.4; + }; + name = Debug; + }; + 97DB8242282339B700FC2228 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = W3DRXD72QU; + GENERATE_INFOPLIST_FILE = YES; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = "$(RECOMMENDED_MACOSX_DEPLOYMENT_TARGET)"; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.amazon.com.AWSCloudWatchLoggingPluginIntegrationTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = YES; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; + SWIFT_EMIT_LOC_STRINGS = NO; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CloudWatchLoggingHostApp.app/CloudWatchLoggingHostApp"; + TVOS_DEPLOYMENT_TARGET = 16.4; + WATCHOS_DEPLOYMENT_TARGET = 9.4; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 733390E62AAB8A3C006E3625 /* Build configuration list for PBXNativeTarget "CloudWatchLoggingWatchApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 733390E42AAB8A3C006E3625 /* Debug */, + 733390E52AAB8A3C006E3625 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 73578A382AAB94D100505FB3 /* Build configuration list for PBXNativeTarget "AWSCloudWatchLoggingPluginIntegrationTestsWatch" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 73578A392AAB94D100505FB3 /* Debug */, + 73578A3A2AAB94D100505FB3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 97AD222928230B98001AFCC1 /* Build configuration list for PBXProject "CloudWatchLoggingHostApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97AD223A28230B9A001AFCC1 /* Debug */, + 97AD223B28230B9A001AFCC1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 97AD223C28230B9A001AFCC1 /* Build configuration list for PBXNativeTarget "CloudWatchLoggingHostApp" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97AD223D28230B9A001AFCC1 /* Debug */, + 97AD223E28230B9A001AFCC1 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + 97DB8243282339B700FC2228 /* Build configuration list for PBXNativeTarget "AWSCloudWatchLoggingPluginIntegrationTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97DB8241282339B700FC2228 /* Debug */, + 97DB8242282339B700FC2228 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 733390E82AAB8A6A006E3625 /* Amplify */ = { + isa = XCSwiftPackageProductDependency; + productName = Amplify; + }; + 733390EA2AAB8A6E006E3625 /* AWSCloudWatchLoggingPlugin */ = { + isa = XCSwiftPackageProductDependency; + productName = AWSCloudWatchLoggingPlugin; + }; + 733390EC2AAB8A74006E3625 /* AWSCognitoAuthPlugin */ = { + isa = XCSwiftPackageProductDependency; + productName = AWSCognitoAuthPlugin; + }; + 73607C782AA93466005105E6 /* Amplify */ = { + isa = XCSwiftPackageProductDependency; + productName = Amplify; + }; + 73607C7A2AA93469005105E6 /* AWSCloudWatchLoggingPlugin */ = { + isa = XCSwiftPackageProductDependency; + productName = AWSCloudWatchLoggingPlugin; + }; + 73607C7C2AA9346D005105E6 /* AWSCognitoAuthPlugin */ = { + isa = XCSwiftPackageProductDependency; + productName = AWSCognitoAuthPlugin; + }; + 73C43A2D2AB4ED800010F1B3 /* Amplify */ = { + isa = XCSwiftPackageProductDependency; + productName = Amplify; + }; + 73C43A2F2AB4ED850010F1B3 /* AWSCognitoAuthPlugin */ = { + isa = XCSwiftPackageProductDependency; + productName = AWSCognitoAuthPlugin; + }; + 73C43A312AB4ED8A0010F1B3 /* AWSCloudWatchLoggingPlugin */ = { + isa = XCSwiftPackageProductDependency; + productName = AWSCloudWatchLoggingPlugin; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 97AD222628230B98001AFCC1 /* Project object */; +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/AWSCloudWatchLoggingPluginIntegrationTests.xcscheme b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/AWSCloudWatchLoggingPluginIntegrationTests.xcscheme new file mode 100644 index 0000000000..dd5e2ff1c9 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/AWSCloudWatchLoggingPluginIntegrationTests.xcscheme @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/AWSCloudWatchLoggingPluginIntegrationTestsWatch.xcscheme b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/AWSCloudWatchLoggingPluginIntegrationTestsWatch.xcscheme new file mode 100644 index 0000000000..fba1f5ca96 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/AWSCloudWatchLoggingPluginIntegrationTestsWatch.xcscheme @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/CloudWatchLoggingHostApp.xcscheme b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/CloudWatchLoggingHostApp.xcscheme new file mode 100644 index 0000000000..adc08ae428 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/CloudWatchLoggingHostApp.xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/CloudWatchLoggingWatchApp.xcscheme b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/CloudWatchLoggingWatchApp.xcscheme new file mode 100644 index 0000000000..7b58846762 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp.xcodeproj/xcshareddata/xcschemes/CloudWatchLoggingWatchApp.xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/AccentColor.colorset/Contents.json b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000000..eb87897008 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..9221b9bb1a --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/Contents.json b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..73c00596a7 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/CloudWatchLoggingApp.swift b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/CloudWatchLoggingApp.swift new file mode 100644 index 0000000000..7a0b1e1bf0 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/CloudWatchLoggingApp.swift @@ -0,0 +1,17 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import SwiftUI + +@main +struct CloudWatchLoggingApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/ContentView.swift b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/ContentView.swift new file mode 100644 index 0000000000..ba4724b6ac --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/ContentView.swift @@ -0,0 +1,21 @@ +// +// Copyright Amazon.com Inc. or its affiliates. +// All Rights Reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// + +import SwiftUI + +struct ContentView: View { + var body: some View { + Text("Hello, world!") + .padding() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Preview Content/Preview Assets.xcassets/Contents.json b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 0000000000..73c00596a7 --- /dev/null +++ b/AmplifyPlugins/Logging/Tests/AWSCloudWatchLoggingPluginHostApp/CloudWatchLoggingHostApp/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} From 318385dcdfdd19185c9092bc67ea4019200e0946 Mon Sep 17 00:00:00 2001 From: Ian Saultz <52051793+atierian@users.noreply.github.com> Date: Tue, 26 Sep 2023 13:39:26 -0400 Subject: [PATCH 5/6] chore(ci): update dependency review config file path (#3233) --- .github/workflows/dependency-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 421225b2cf..199ee76507 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -22,4 +22,4 @@ jobs: - name: Dependency Review uses: actions/dependency-review-action@7d90b4f05fea31dde1c4a1fb3fa787e197ea93ab # v3.0.7 with: - config-file: aws-amplify/amplify-ci-support/.github/dependency-review-config.yml@main + config-file: amazon-ospo/dependency-review-config/default/dependency-review-config.yml@main From 7d9e3daf23d5cdb73c8572c509b02fd0a839de05 Mon Sep 17 00:00:00 2001 From: Abhash Kumar Singh Date: Wed, 27 Sep 2023 09:40:15 -0700 Subject: [PATCH 6/6] fix(datastore): Continue initial sync if atleast one model syncs successfully and other models fail due to Unauthorized API error (#3224) * fix(datastore): Continue initial sync if atleast one model from schema succeeds * Address review comments * Remove unused import * Address review comments * Add unit test * Address review comments --- .../InitialSync/InitialSyncOrchestrator.swift | 19 +++++++- .../InitialSyncOrchestratorTests.swift | 48 ++++++++++++++++++- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOrchestrator.swift b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOrchestrator.swift index 872fb56fc3..3c2dec737d 100644 --- a/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOrchestrator.swift +++ b/AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/InitialSyncOrchestrator.swift @@ -164,6 +164,7 @@ final class AWSInitialSyncOrchestrator: InitialSyncOrchestrator { allMessages.joined(separator: "\n"), underlyingError ) + return .failure(syncError) } @@ -208,7 +209,7 @@ extension AWSInitialSyncOrchestrator { return errorTypeValue } - private func isUnauthorizedError(_ error: DataStoreError) -> Bool { + func isUnauthorizedError(_ error: DataStoreError) -> Bool { guard case let .sync(_, _, underlyingError) = error, let datastoreError = underlyingError as? DataStoreError else { @@ -245,6 +246,22 @@ extension AWSInitialSyncOrchestrator { case .unauthorized = AppSyncErrorType(errorTypeValue) { return true } + + // Check is API error is of unauthorized type + if case let .api(amplifyError, _) = datastoreError, + let apiError = amplifyError as? APIError { + if case .operationError(let errorDescription, _, _) = apiError, + errorDescription.range(of: "Unauthorized", + options: .caseInsensitive) != nil { + return true + } + + if case .httpStatusError(let statusCode, _) = apiError, + (statusCode == 401 || statusCode == 403) { + return true + } + } + return false } diff --git a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOrchestratorTests.swift b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOrchestratorTests.swift index e106b30d10..07ea9b3984 100644 --- a/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOrchestratorTests.swift +++ b/AmplifyPlugins/DataStore/Tests/AWSDataStorePluginTests/Sync/InitialSync/InitialSyncOrchestratorTests.swift @@ -6,6 +6,7 @@ // import XCTest +import Foundation @testable import Amplify @testable import AmplifyTestCommon @@ -101,7 +102,7 @@ class InitialSyncOrchestratorTests: XCTestCase { Amplify.Hub.removeListener(hubListener) sink.cancel() } - + /// - Given: An InitialSyncOrchestrator with a model dependency graph, API is expected to return an error for certain models /// - When: /// - The orchestrator starts up @@ -200,7 +201,7 @@ class InitialSyncOrchestratorTests: XCTestCase { Amplify.Hub.removeListener(hubListener) sink.cancel() } - + /// - Given: An InitialSyncOrchestrator with a model dependency graph containing no associations /// - When: /// - The orchestrator starts up @@ -409,4 +410,47 @@ class InitialSyncOrchestratorTests: XCTestCase { sink.cancel() } + /// - Given: + /// An InitialSyncOrchestrator with a model dependency graph + /// - When: + /// isUnauthorized() is called with an API Error with status code 401, 403 or "Unauthorized" description + /// and return false for other cases + /// - Then: + /// - It should return true for unauthorized cases and false for other cases + func testIsUnauthorized() { + let apiPlugin = MockAPICategoryPlugin() + let storageAdapter = MockSQLiteStorageEngineAdapter() + let reconciliationQueue = MockReconciliationQueue() + + let orchestrator = + AWSInitialSyncOrchestrator(dataStoreConfiguration: .default, + authModeStrategy: AWSDefaultAuthModeStrategy(), + api: apiPlugin, + reconciliationQueue: reconciliationQueue, + storageAdapter: storageAdapter) + + let error1 = DataStoreError.api(APIError.httpStatusError(401, HTTPURLResponse(url: URL(string: "https://aws.amazon.com")!, + statusCode: 401, + httpVersion: nil, + headerFields: nil)!)) + XCTAssertTrue(orchestrator.isUnauthorizedError(DataStoreError.sync("", "", error1))) + + let error2 = DataStoreError.api(APIError.httpStatusError(403, HTTPURLResponse(url: URL(string: "https://aws.amazon.com")!, + statusCode: 403, + httpVersion: nil, + headerFields: nil)!)) + XCTAssertTrue(orchestrator.isUnauthorizedError(DataStoreError.sync("", "", error2))) + + let error3 = DataStoreError.api(APIError.httpStatusError(404, HTTPURLResponse(url: URL(string: "https://aws.amazon.com")!, + statusCode: 404, + httpVersion: nil, + headerFields: nil)!)) + XCTAssertFalse(orchestrator.isUnauthorizedError(DataStoreError.sync("", "", error3))) + + let error4 = DataStoreError.api(APIError.operationError("Unauthorized error", "", nil)) + XCTAssertTrue(orchestrator.isUnauthorizedError(DataStoreError.sync("", "", error4))) + + let error5 = DataStoreError.api(APIError.operationError("An error occurred", "", nil)) + XCTAssertFalse(orchestrator.isUnauthorizedError(DataStoreError.sync("", "", error5))) + } }