Skip to content

Commit 6f65406

Browse files
authored
chore: kickoff release
2 parents b9a7baa + 3abc90b commit 6f65406

File tree

5 files changed

+70
-25
lines changed

5 files changed

+70
-25
lines changed

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Operations/Helpers/FetchAuthSessionOperationHelper.swift

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,21 @@ class FetchAuthSessionOperationHelper: DefaultLogger {
6666
authStateMachine: AuthStateMachine,
6767
forceRefresh: Bool) async throws -> AuthSession {
6868

69-
var event: AuthorizationEvent
7069
if forceRefresh || !credentials.areValid() {
71-
if case .identityPoolWithFederation(
72-
let federatedToken,
73-
let identityId,
74-
_
75-
) = credentials {
76-
event = AuthorizationEvent(
77-
eventType: .startFederationToIdentityPool(federatedToken, identityId)
78-
)
79-
} else {
70+
var event: AuthorizationEvent
71+
switch credentials {
72+
case .identityPoolWithFederation(let federatedToken, let identityId, _):
73+
event = AuthorizationEvent(eventType: .startFederationToIdentityPool(federatedToken, identityId))
74+
case .noCredentials:
75+
event = AuthorizationEvent(eventType: .fetchUnAuthSession)
76+
case .userPoolOnly, .identityPoolOnly, .userPoolAndIdentityPool:
8077
event = AuthorizationEvent(eventType: .refreshSession(forceRefresh))
8178
}
8279
await authStateMachine.send(event)
8380
return try await listenForSession(authStateMachine: authStateMachine)
81+
} else {
82+
return credentials.cognitoSession
8483
}
85-
return credentials.cognitoSession
8684
}
8785

8886
func listenForSession(authStateMachine: AuthStateMachine) async throws -> AuthSession {

AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/AuthorizationTests/AWSAuthFetchSignInSessionOperationTests.swift

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,59 @@ class AWSAuthFetchSignInSessionOperationTests: BaseAuthorizationTests {
584584
}
585585
}
586586

587+
/// Test fetch session with authorization in error state
588+
///
589+
/// - Given: An auth plugin with signedOut state
590+
/// - When:
591+
/// - I invoke fetchAuthSession and mock notSignedIn for getTokens
592+
/// - Then:
593+
/// - I should get an a valid session with the following details:
594+
/// - isSignedIn = false
595+
/// - aws credentails = valid values
596+
/// - identity id = valid values
597+
/// - cognito tokens = signedOut
598+
///
599+
func testFetchSessionWithAuthorizationInErrorState() async throws {
600+
601+
let initialState = AuthState.configured(
602+
AuthenticationState.signedOut(.testData),
603+
AuthorizationState.error(.sessionError(.service(AuthError.unknown("error")), .noCredentials)))
604+
605+
let getId: MockIdentity.MockGetIdResponse = { _ in
606+
return .init(identityId: "mockIdentityId")
607+
}
608+
609+
let getCredentials: MockIdentity.MockGetCredentialsResponse = { _ in
610+
let credentials = CognitoIdentityClientTypes.Credentials(accessKeyId: "accessKey",
611+
expiration: Date(),
612+
secretKey: "secret",
613+
sessionToken: "session")
614+
return .init(credentials: credentials, identityId: "responseIdentityID")
615+
}
616+
617+
let plugin = configurePluginWith(identityPool: {
618+
MockIdentity(mockGetIdResponse: getId,
619+
mockGetCredentialsResponse: getCredentials) },
620+
initialState: initialState)
621+
622+
let session = try await plugin.fetchAuthSession(options: AuthFetchSessionRequest.Options())
623+
XCTAssertFalse(session.isSignedIn)
624+
625+
let creds = try? (session as? AuthAWSCredentialsProvider)?.getAWSCredentials().get()
626+
XCTAssertNotNil(creds?.accessKeyId)
627+
XCTAssertNotNil(creds?.secretAccessKey)
628+
629+
let identityId = try? (session as? AuthCognitoIdentityProvider)?.getIdentityId().get()
630+
XCTAssertNotNil(identityId)
631+
632+
let tokensResult = (session as? AuthCognitoTokensProvider)?.getCognitoTokens()
633+
guard case .failure(let error) = tokensResult,
634+
case .signedOut = error else {
635+
XCTFail("Should return signed out error")
636+
return
637+
}
638+
}
639+
587640
/// Test signedOut state credential refresh
588641
///
589642
/// - Given: Given an auth plugin with signedOut state and expired AWS credentials

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
8383
try await clearDataStore()
8484
var snapshots = [DataStoreQuerySnapshot<Post>]()
8585
let snapshotWithIsSynced = expectation(description: "query snapshot with isSynced true")
86+
snapshotWithIsSynced.assertForOverFulfill = false
8687
Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in
8788
switch completed {
8889
case .finished:
@@ -130,6 +131,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
130131
var isObserveQueryReadyForTest = false
131132
let observeQueryReadyForTest = expectation(description: "received query snapshot with .isSynced true")
132133
let snapshotWithPost = expectation(description: "received first snapshot")
134+
snapshotWithPost.assertForOverFulfill = false
133135
let post = Post(title: "title", content: "content", createdAt: .now())
134136
Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in
135137
switch completed {
@@ -339,6 +341,7 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
339341
try await clearDataStore()
340342

341343
let snapshotWithIsSynced = expectation(description: "query snapshot with isSynced true")
344+
snapshotWithIsSynced.assertForOverFulfill = false
342345
var snapshots = [DataStoreQuerySnapshot<Post>]()
343346

344347
Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in
@@ -363,7 +366,6 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
363366
await fulfillment(of: [snapshotWithIsSynced], timeout: 30)
364367
XCTAssertTrue(snapshots.count >= 2)
365368
XCTAssertFalse(snapshots[0].isSynced)
366-
XCTAssertEqual(1, snapshots.filter({ $0.isSynced }).count)
367369

368370
let theSyncedSnapshot = snapshots.first(where: { $0.isSynced })
369371
XCTAssertNotNil(theSyncedSnapshot)

Package.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,6 @@ let package = Package(
484484
name: "AWSPluginsCore",
485485
targets: ["AWSPluginsCore"]
486486
),
487-
.library(
488-
name: "InternalAmplifyCredentials",
489-
targets: ["InternalAmplifyCredentials"]
490-
),
491487
.library(
492488
name: "AWSAPIPlugin",
493489
targets: ["AWSAPIPlugin"]

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,17 @@ of the library.
5656

5757
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.
5858

59+
#### Semantic versioning and dependencies update
60+
61+
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).
62+
5963
## License
6064

6165
This library is licensed under the Apache 2.0 License.
6266

6367
## Installation
6468

65-
Amplify requires the following Xcode versions, according to the targeted platform:
66-
67-
| Platform | Xcode Version |
68-
| -------------:| ------------: |
69-
| iOS | 15.0+ |
70-
| macOS | 15.0+ |
71-
| tvOS | 15.0+ |
72-
| watchOS | 15.0+ |
73-
| visionOS | 15 beta 2+ |
69+
Amplify requires Xcode 15.0 or later for all the supported platforms.
7470

7571
| For more detailed instructions, follow the getting started guides in our [documentation site](https://docs.amplify.aws/lib/q/platform/ios) |
7672
|-------------------------------------------------|

0 commit comments

Comments
 (0)