Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update aws-swift-sdk dependency to 0.36.1 #3519

Merged
merged 23 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct IAMURLRequestInterceptor: URLRequestInterceptor {
.flatMap(HttpMethodType.init(rawValue:)) ?? .get

let queryItems = URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?
.map { ClientRuntime.URLQueryItem(name: $0.name, value: $0.value)} ?? []
.map { ClientRuntime.SDKURLQueryItem(name: $0.name, value: $0.value)} ?? []

let requestBuilder = SdkHttpRequestBuilder()
.withHost(host)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ extension AWSCognitoAuthPlugin {
}

if let requestTimeout = networkPreferences?.timeoutIntervalForRequest {
let requestTimeOutMs = requestTimeout * 1_000
configuration.connectTimeoutMs = UInt32(requestTimeOutMs)
configuration.httpClientConfiguration = HttpClientConfiguration(connectTimeout: requestTimeout)
}

if let maxRetryUnwrapped = networkPreferences?.maxRetryCount {
Expand All @@ -126,8 +125,7 @@ extension AWSCognitoAuthPlugin {
configuration.httpClientEngine = .userAgentEngine(for: configuration)

if let requestTimeout = networkPreferences?.timeoutIntervalForRequest {
let requestTimeOutMs = requestTimeout * 1_000
configuration.connectTimeoutMs = UInt32(requestTimeOutMs)
configuration.httpClientConfiguration = HttpClientConfiguration(connectTimeout: requestTimeout)
}

if let maxRetryUnwrapped = networkPreferences?.maxRetryCount {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import ClientRuntime
import Foundation

protocol HttpClientEngineProxy: HttpClientEngine {
var target: HttpClientEngine? { get set }
protocol HttpClientEngineProxy: HTTPClient {
var target: HTTPClient? { get set }
}

extension UserAgentSuffixAppender: HttpClientEngineProxy {}
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ class AWSAuthSignInPluginTests: BasePluginTest {

self.mockIdentityProvider = MockIdentityProvider(mockInitiateAuthResponse: { _ in
throw try await AWSCognitoIdentityProvider.PasswordResetRequiredException(
httpResponse: .init(body: .none, statusCode: .badRequest),
httpResponse: .init(body: .empty, statusCode: .badRequest),
decoder: nil,
message: nil,
requestID: nil
Expand Down Expand Up @@ -1133,7 +1133,7 @@ class AWSAuthSignInPluginTests: BasePluginTest {

self.mockIdentityProvider = MockIdentityProvider(mockInitiateAuthResponse: { _ in
throw try await AWSCognitoIdentityProvider.UserNotConfirmedException(
httpResponse: .init(body: .none, statusCode: .badRequest)
httpResponse: .init(body: .empty, statusCode: .badRequest)
)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1111,11 +1111,18 @@
681B76C22A3CBBAE004B59D9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 94KV3E626L;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = IntegTests;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@loader_path/Frameworks",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.auth.AuthIntegrationTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1132,11 +1139,18 @@
681B76C32A3CBBAE004B59D9 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 94KV3E626L;
DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_CFBundleDisplayName = IntegTests;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@loader_path/Frameworks",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.aws.amplify.auth.AuthIntegrationTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
enableThreadSanitizer = "YES"
codeCoverageEnabled = "YES">
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AuthSignOutTests: AWSAuthBaseTest {
try await super.setUp()
AuthSessionHelper.clearSession()
if Self.setSDKLogLevelDebug {
SDKLoggingSystem.initialize(logLevel: .debug)
await SDKLoggingSystem.initialize(logLevel: .debug)
Self.setSDKLogLevelDebug = false
}
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,25 @@ import AWSClientRuntime
@_spi(PluginHTTPClientEngine)
public func baseClientEngine(
for configuration: AWSClientConfiguration<some AWSServiceSpecificConfiguration>
) -> HttpClientEngine {
let baseClientEngine: HttpClientEngine
#if os(iOS) || os(macOS)
// networking goes through CRT
baseClientEngine = configuration.httpClientEngine
#else
// networking goes through Foundation
baseClientEngine = FoundationClientEngine()
#endif
return baseClientEngine
) -> HTTPClient {

/// An example of how a client engine provided by aws-swift-sdk can be overridden
/// ```
/// let baseClientEngine: HTTPClient
/// #if os(iOS) || os(macOS)
/// // networking goes through default aws sdk engine
/// baseClientEngine = configuration.httpClientEngine
/// #else
/// // The custom client engine from where we want to route requests
/// // FoundationClientEngine() was an example used in 2.26.x and before
/// baseClientEngine = <your custom client engine>
/// #endif
/// return baseClientEngine
/// ```
///
/// Starting aws-sdk-release 0.34.0, base HTTP client has been defaulted to foundation.
/// Hence, amplify doesn't need an override. So return the httpClientEngine present in the configuration.
return configuration.httpClientEngine


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,33 @@ import AWSClientRuntime
@_spi(PluginHTTPClientEngine)
public struct UserAgentSettingClientEngine: AWSPluginExtension {
@_spi(InternalHttpEngineProxy)
public let target: HttpClientEngine
public let target: HTTPClient
private let userAgentKey = "User-Agent"

public init(target: HttpClientEngine) {
public init(target: HTTPClient) {
self.target = target
}
}

@_spi(PluginHTTPClientEngine)
extension UserAgentSettingClientEngine: HttpClientEngine {
// CI updates the `platformName` property in `AmplifyAWSServiceConfiguration`.
extension UserAgentSettingClientEngine: HTTPClient {

// CI updates the `platformName` property in `AmplifyAWSServiceConfiguration`.
// We can / probably should move this in the future
// as it's no longer necessary there.
var lib: String { AmplifyAWSServiceConfiguration.userAgentLib }

public func execute(request: SdkHttpRequest) async throws -> HttpResponse {
public func send(request: SdkHttpRequest) async throws -> HttpResponse {
let existingUserAgent = request.headers.value(for: userAgentKey) ?? ""
let userAgent = "\(existingUserAgent) \(lib)"
let updatedRequest = request.updatingUserAgent(with: userAgent)

return try await target.execute(request: updatedRequest)
return try await target.send(request: updatedRequest)
}
}

@_spi(PluginHTTPClientEngine)
extension HttpClientEngine where Self == UserAgentSettingClientEngine {
extension HTTPClient where Self == UserAgentSettingClientEngine {
public static func userAgentEngine(
for configuration: AWSClientConfiguration<some AWSServiceSpecificConfiguration>
) -> Self {
Expand Down
Loading
Loading