From 11302caf660609463a896929b0ae926d6612b5c4 Mon Sep 17 00:00:00 2001 From: Di Wu Date: Fri, 14 Jun 2024 14:53:26 -0700 Subject: [PATCH 1/5] fix(core): remove InternalAmplifyCredentials from products (#3750) --- Package.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Package.swift b/Package.swift index 0fe21039e6..3a679faade 100644 --- a/Package.swift +++ b/Package.swift @@ -484,10 +484,6 @@ let package = Package( name: "AWSPluginsCore", targets: ["AWSPluginsCore"] ), - .library( - name: "InternalAmplifyCredentials", - targets: ["InternalAmplifyCredentials"] - ), .library( name: "AWSAPIPlugin", targets: ["AWSAPIPlugin"] From 9ed6c1c7031f2c1dc962d2eb0f87ae44d8532eb4 Mon Sep 17 00:00:00 2001 From: Di Wu Date: Tue, 18 Jun 2024 18:01:30 -0700 Subject: [PATCH 2/5] test(datastore): fix broken datastore observeQuery integ tests (#3752) --- .../DataStoreObserveQueryTests.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift index 4e13e3e2ff..fe67f60806 100644 --- a/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift +++ b/AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift @@ -83,6 +83,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { try await clearDataStore() var snapshots = [DataStoreQuerySnapshot]() let snapshotWithIsSynced = expectation(description: "query snapshot with isSynced true") + snapshotWithIsSynced.assertForOverFulfill = false Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in switch completed { case .finished: @@ -130,6 +131,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { var isObserveQueryReadyForTest = false let observeQueryReadyForTest = expectation(description: "received query snapshot with .isSynced true") let snapshotWithPost = expectation(description: "received first snapshot") + snapshotWithPost.assertForOverFulfill = false let post = Post(title: "title", content: "content", createdAt: .now()) Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in switch completed { @@ -339,6 +341,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { try await clearDataStore() let snapshotWithIsSynced = expectation(description: "query snapshot with isSynced true") + snapshotWithIsSynced.assertForOverFulfill = false var snapshots = [DataStoreQuerySnapshot]() Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in @@ -363,7 +366,6 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase { await fulfillment(of: [snapshotWithIsSynced], timeout: 30) XCTAssertTrue(snapshots.count >= 2) XCTAssertFalse(snapshots[0].isSynced) - XCTAssertEqual(1, snapshots.filter({ $0.isSynced }).count) let theSyncedSnapshot = snapshots.first(where: { $0.isSynced }) XCTAssertNotNil(theSyncedSnapshot) From e338d9e770107a10f46c73dceb53ec7dca69e902 Mon Sep 17 00:00:00 2001 From: Harsh <6162866+harsh62@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:39:12 -0400 Subject: [PATCH 3/5] chore: update readme with correct Xcode version for visionOS (#3761) * chore: update readme with correct Xcode version for visionOS * worked on review comment --- README.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index 3f766dc3bf..9a1fce0a83 100644 --- a/README.md +++ b/README.md @@ -62,15 +62,7 @@ This library is licensed under the Apache 2.0 License. ## Installation -Amplify requires the following Xcode versions, according to the targeted platform: - -| Platform | Xcode Version | -| -------------:| ------------: | -| iOS | 15.0+ | -| macOS | 15.0+ | -| tvOS | 15.0+ | -| watchOS | 15.0+ | -| visionOS | 15 beta 2+ | +Amplify requires Xcode 15.0 or later for all the supported platforms. | For more detailed instructions, follow the getting started guides in our [documentation site](https://docs.amplify.aws/lib/q/platform/ios) | |-------------------------------------------------| From 540fba239ecc1f937053cf991e0fca131c423ec8 Mon Sep 17 00:00:00 2001 From: Matt Creaser Date: Mon, 24 Jun 2024 23:44:17 -0300 Subject: [PATCH 4/5] chore: Add note about Semver implications for dependency updates (#3740) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9a1fce0a83..bb77a62dbf 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,10 @@ of the library. Applications that evaluate all members of an enumeration using a `switch` statement can add a `default` case to prevent new cases from causing compile warnings or errors. +#### Semantic versioning and dependencies update + +We follow [semantic versioning for updating our dependencies](https://semver.org/#what-should-i-do-if-i-update-my-own-dependencies-without-changing-the-public-api). + ## License This library is licensed under the Apache 2.0 License. From 3abc90b7cca5427ae8079b1e3ef6d78307e20d22 Mon Sep 17 00:00:00 2001 From: Harsh <6162866+harsh62@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:54:43 -0400 Subject: [PATCH 5/5] fix(Auth): Resolve AuthZ state correctly when in error state (#3762) --- .../FetchAuthSessionOperationHelper.swift | 20 ++++--- ...AuthFetchSignInSessionOperationTests.swift | 53 +++++++++++++++++++ 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Operations/Helpers/FetchAuthSessionOperationHelper.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Operations/Helpers/FetchAuthSessionOperationHelper.swift index d39751956a..b4a7aa9d4a 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Operations/Helpers/FetchAuthSessionOperationHelper.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Operations/Helpers/FetchAuthSessionOperationHelper.swift @@ -66,23 +66,21 @@ class FetchAuthSessionOperationHelper: DefaultLogger { authStateMachine: AuthStateMachine, forceRefresh: Bool) async throws -> AuthSession { - var event: AuthorizationEvent if forceRefresh || !credentials.areValid() { - if case .identityPoolWithFederation( - let federatedToken, - let identityId, - _ - ) = credentials { - event = AuthorizationEvent( - eventType: .startFederationToIdentityPool(federatedToken, identityId) - ) - } else { + var event: AuthorizationEvent + switch credentials { + case .identityPoolWithFederation(let federatedToken, let identityId, _): + event = AuthorizationEvent(eventType: .startFederationToIdentityPool(federatedToken, identityId)) + case .noCredentials: + event = AuthorizationEvent(eventType: .fetchUnAuthSession) + case .userPoolOnly, .identityPoolOnly, .userPoolAndIdentityPool: event = AuthorizationEvent(eventType: .refreshSession(forceRefresh)) } await authStateMachine.send(event) return try await listenForSession(authStateMachine: authStateMachine) + } else { + return credentials.cognitoSession } - return credentials.cognitoSession } func listenForSession(authStateMachine: AuthStateMachine) async throws -> AuthSession { diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/AuthorizationTests/AWSAuthFetchSignInSessionOperationTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/AuthorizationTests/AWSAuthFetchSignInSessionOperationTests.swift index 9bee6c05b1..a67aa2522b 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/AuthorizationTests/AWSAuthFetchSignInSessionOperationTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/AuthorizationTests/AWSAuthFetchSignInSessionOperationTests.swift @@ -584,6 +584,59 @@ class AWSAuthFetchSignInSessionOperationTests: BaseAuthorizationTests { } } + /// Test fetch session with authorization in error state + /// + /// - Given: An auth plugin with signedOut state + /// - When: + /// - I invoke fetchAuthSession and mock notSignedIn for getTokens + /// - Then: + /// - I should get an a valid session with the following details: + /// - isSignedIn = false + /// - aws credentails = valid values + /// - identity id = valid values + /// - cognito tokens = signedOut + /// + func testFetchSessionWithAuthorizationInErrorState() async throws { + + let initialState = AuthState.configured( + AuthenticationState.signedOut(.testData), + AuthorizationState.error(.sessionError(.service(AuthError.unknown("error")), .noCredentials))) + + let getId: MockIdentity.MockGetIdResponse = { _ in + return .init(identityId: "mockIdentityId") + } + + let getCredentials: MockIdentity.MockGetCredentialsResponse = { _ in + let credentials = CognitoIdentityClientTypes.Credentials(accessKeyId: "accessKey", + expiration: Date(), + secretKey: "secret", + sessionToken: "session") + return .init(credentials: credentials, identityId: "responseIdentityID") + } + + let plugin = configurePluginWith(identityPool: { + MockIdentity(mockGetIdResponse: getId, + mockGetCredentialsResponse: getCredentials) }, + initialState: initialState) + + let session = try await plugin.fetchAuthSession(options: AuthFetchSessionRequest.Options()) + XCTAssertFalse(session.isSignedIn) + + let creds = try? (session as? AuthAWSCredentialsProvider)?.getAWSCredentials().get() + XCTAssertNotNil(creds?.accessKeyId) + XCTAssertNotNil(creds?.secretAccessKey) + + let identityId = try? (session as? AuthCognitoIdentityProvider)?.getIdentityId().get() + XCTAssertNotNil(identityId) + + let tokensResult = (session as? AuthCognitoTokensProvider)?.getCognitoTokens() + guard case .failure(let error) = tokensResult, + case .signedOut = error else { + XCTFail("Should return signed out error") + return + } + } + /// Test signedOut state credential refresh /// /// - Given: Given an auth plugin with signedOut state and expired AWS credentials