Skip to content

Commit

Permalink
feat: Updating to AWS SDK for Swift 0.77.0
Browse files Browse the repository at this point in the history
also addressing some PR comments
  • Loading branch information
ruisebas committed Sep 16, 2024
1 parent c4f8aca commit 12fa369
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension Smithy.ClientError: AuthErrorConvertible {
case .serializationFailed(let message),
.dataNotFound(let message),
.invalidValue(let message):
return .service(message, "", self)
return .service(message, "Check the underlying error and try again", self)

case .authError(let message):
return .notAuthorized(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public class AmplifyAWSSignatureV4Signer: AWSSignatureV4Signer {
signingRegion: Swift.String,
date: Date) async throws -> SmithyHTTPAPI.HTTPRequest? {
do {
let credentials = try await credentialIdentityResolver.getIdentity()
let credentialIdentity = try await credentialIdentityResolver.getIdentity()

let flags = SigningFlags(useDoubleURIEncode: true,
shouldNormalizeURIPath: true,
omitSessionToken: false)
let signedBodyHeader: AWSSignedBodyHeader = .none
let signedBodyValue: AWSSignedBodyValue = .empty
let signingConfig = AWSSigningConfig(credentials: credentials,
let signingConfig = AWSSigningConfig(credentials: credentialIdentity,
signedBodyHeader: signedBodyHeader,
signedBodyValue: signedBodyValue,
flags: flags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import Foundation
import Smithy
import SmithyHTTPAPI

// From an Analytics perspective, a non-retryable error thrown by a PutEvents request
// means that all those events should be immediately pruned from the local database.
//
// Any "transient" error should be retried on the next event submission,
// so only `ClientError.serializationFailed` is considered to be non-retryable.

extension Smithy.ClientError {
// TODO: Should some of these really be retried?
var isRetryable: Bool {
switch self {
case .authError:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

import AWSPinpoint
@testable import InternalAWSPinpoint
import XCTest

class PinpointClientTypesCodableTests: XCTestCase {
/// Given: Instances of PinpointClient types that conform to Codable
/// When: They are encoded and decoded
/// Then: The encoded data can be decoded, and the decoded data is equal to the original one
func testCodableTypes_shouldEncodeAndDecodeSuccesfully() throws {
let location = PinpointClientTypes.EndpointLocation(
city: "city",
country: "country",
latitude: 10.0,
longitude: 10.0,
postalCode: "postalCode",
region: "region"
)

let demographic = PinpointClientTypes.EndpointDemographic(
appVersion: "appVersion",
locale: "locale",
make: "make",
model: "model",
modelVersion: "modelVersion",
platform: "platform",
platformVersion: "platformVersion",
timezone: "timezone"
)

let user = PinpointClientTypes.EndpointUser(
userAttributes: [
"attributes": ["value1", "value2"]
],
userId: "userId"
)

let archiver = AmplifyArchiver()

// Encode types
let encodedLocation = try archiver.encode(location)
let encodedDemographic = try archiver.encode(demographic)
let encodedUser = try archiver.encode(user)

// Decode types
let decodedLocation = try archiver.decode(
PinpointClientTypes.EndpointLocation.self,
from: encodedLocation
)
XCTAssertEqual(decodedLocation, location)

let decodedDemographic = try archiver.decode(
PinpointClientTypes.EndpointDemographic.self,
from: encodedDemographic
)
XCTAssertEqual(decodedDemographic, demographic)

let decodedUser = try archiver.decode(
PinpointClientTypes.EndpointUser.self,
from: encodedUser
)
XCTAssertEqual(decodedUser, user)
}
}
12 changes: 6 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/aws-crt-swift",
"state" : {
"revision" : "26be7379c9d74ccf0a32d4429181ef06d72683f6",
"version" : "0.33.0"
"revision" : "7b42e0343f28b3451aab20840dc670abd12790bd",
"version" : "0.36.0"
}
},
{
"identity" : "aws-sdk-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/aws-sdk-swift.git",
"state" : {
"revision" : "8dc5c2b0bace8851efe1fd42d449d8eefafc0db0",
"version" : "0.76.2"
"revision" : "629d1c7f08b2e8026dd2779ca16a1871e5d2fecf",
"version" : "0.77.0"
}
},
{
Expand All @@ -50,8 +50,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/smithy-lang/smithy-swift",
"state" : {
"revision" : "e32c3fbbd865ac3c256a864b0563b2b759a45420",
"version" : "0.68.0"
"revision" : "9115a71bacee15f7cc6f567c34b7a16e66d4626e",
"version" : "0.70.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let platforms: [SupportedPlatform] = [
.watchOS(.v9)
]
let dependencies: [Package.Dependency] = [
.package(url: "https://github.com/awslabs/aws-sdk-swift.git", exact: "0.76.2"),
.package(url: "https://github.com/awslabs/aws-sdk-swift.git", exact: "0.77.0"),
.package(url: "https://github.com/stephencelis/SQLite.swift.git", exact: "0.15.3"),
.package(url: "https://github.com/mattgallagher/CwlPreconditionTesting.git", from: "2.1.0"),
.package(url: "https://github.com/aws-amplify/amplify-swift-utils-notifications.git", from: "1.1.0")
Expand Down

0 comments on commit 12fa369

Please sign in to comment.