Skip to content

Commit b2c4832

Browse files
kneekey23wooj2
andauthored
chore: Update to smithy 1.9 (#269)
Co-authored-by: John Woo <[email protected]>
1 parent f5ec52e commit b2c4832

File tree

58 files changed

+1836
-967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1836
-967
lines changed

Packages/ClientRuntime/Sources/Networking/Http/CRT/CRTClientEngine.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import AwsCommonRuntimeKit
1212

1313
public class CRTClientEngine: HttpClientEngine {
1414

15-
1615
private var logger: LogAgent
1716
private var crtLogger: Logger
1817
private var connectionPools: [Endpoint: HttpClientConnectionManager] = [:]

Packages/ClientRuntime/Sources/Networking/Http/DefaultMiddlewares/LoggerMiddleware.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public struct LoggerMiddleware<Output: HttpResponseBinding,
3131

3232
if clientLogMode == .request || clientLogMode == .requestAndResponse {
3333
logger.debug("Request: \(input.debugDescription)")
34-
}else if clientLogMode == .requestAndResponseWithBody || clientLogMode == .requestWithBody {
34+
} else if clientLogMode == .requestAndResponseWithBody || clientLogMode == .requestWithBody {
3535
logger.debug("Request: \(input.debugDescriptionWithBody)")
3636
}
3737

Packages/ClientRuntime/Sources/Networking/Http/HttpStatusCode.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ extension HttpStatusCode: CustomStringConvertible {
147147
}
148148
}
149149

150-
151150
extension HttpStatusCode {
152151
public var isRetryable: Bool {
153152
if (502..<505).contains(rawValue) || rawValue == 500 {

Packages/ClientRuntime/Sources/Retries/ExponentialBackOffJitterMode.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ extension ExponentialBackOffJitterMode {
2323
}
2424
}
2525
}
26-

Packages/ClientRuntime/Sources/Retries/RetryOptions.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public struct RetryOptions {
1818
}
1919
}
2020

21-
2221
extension RetryOptions {
2322
func toCRTType() -> TransformRetryOptions {
2423
return TransformRetryOptions(initialBucketCapacity: initialBucketCapacity,

Packages/ClientRuntime/Sources/Retries/SDKRetrier.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,3 @@ public class SDKRetrier: Retrier {
9696
}
9797
}
9898
}
99-

Packages/ClientRuntime/Sources/Util/PlatformOperatingSystem.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public enum PlatformOperatingSystem: String {
1515
case unknown
1616
}
1717

18-
1918
public var currentOS: PlatformOperatingSystem {
2019
#if os(Linux)
2120
return .linux
@@ -33,4 +32,3 @@ public var currentOS: PlatformOperatingSystem {
3332
#error("Cannot use a an operating system we do not support")
3433
#endif
3534
}
36-

Packages/ClientRuntime/Sources/Util/SwiftVersion.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ public var swiftVersion: String {
2424
#error("Cannot use a version of Swift less than 5.0")
2525
#endif
2626
}
27-

Packages/SmithyTestUtil/Sources/RequestTestUtil/HttpRequestTestBase+FormURL.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import ClientRuntime
1010
extension HttpRequestTestBase {
1111
public func assertEqualFormURLBody(_ expected: Data, _ actual: Data) {
1212
let expectedQueryItems = convertToQueryItems(data: expected)
13-
let acutalQueryItems = convertToQueryItems(data: actual)
14-
assertEqualQueryItems(expectedQueryItems, acutalQueryItems)
13+
let actualQueryItems = convertToQueryItems(data: actual)
14+
assertEqualQueryItems(expectedQueryItems, actualQueryItems)
1515
}
1616

1717
private func convertToQueryItems(data: Data) -> [URLQueryItem] {
@@ -20,21 +20,18 @@ extension HttpRequestTestBase {
2020
return []
2121
}
2222
var queryItems: [URLQueryItem] = []
23-
let keyValuePairs = queryString.components(separatedBy: "\n")
23+
let sanitizedQueryString = queryString.replacingOccurrences(of: "\n", with: "")
24+
let keyValuePairs = sanitizedQueryString.components(separatedBy: "&")
2425
for keyValue in keyValuePairs {
2526
let keyValueArray = keyValue.components(separatedBy: "=")
2627
guard keyValueArray.count >= 1 else {
2728
XCTFail("Failed to decode query string. Problem with the encoding? Query string is:\n\(queryString)")
2829
return []
2930
}
30-
let name: String = sanitizeQueryStringName(keyValueArray[0])
31-
let value = keyValueArray.count >= 2 ? keyValueArray[1] : nil
31+
let name: String = keyValueArray[0]
32+
let value = keyValueArray.count >= 2 ? sanitizeStringForNonConformingValues(keyValueArray[1]) : nil
3233
queryItems.append(URLQueryItem(name: name, value: value))
3334
}
3435
return queryItems
3536
}
36-
37-
private func sanitizeQueryStringName(_ name: String) -> String {
38-
return name.hasPrefix("&") ? String(name.dropFirst()) : name
39-
}
4037
}

Packages/SmithyTestUtil/Sources/RequestTestUtil/HttpRequestTestBase.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,18 @@ open class HttpRequestTestBase: XCTestCase {
2828
for queryParam in queryParams {
2929
let queryParamComponents = queryParam.components(separatedBy: "=")
3030
if queryParamComponents.count > 1 {
31+
let value = sanitizeStringForNonConformingValues(queryParamComponents[1])
32+
3133
builder.withQueryItem(URLQueryItem(name: queryParamComponents[0],
32-
value: queryParamComponents[1]))
34+
value: value))
3335
} else {
3436
builder.withQueryItem(URLQueryItem(name: queryParamComponents[0], value: nil))
3537
}
3638
}
3739

3840
for (headerName, headerValue) in headers {
39-
builder.withHeader(name: headerName, value: headerValue)
41+
let value = sanitizeStringForNonConformingValues(headerValue)
42+
builder.withHeader(name: headerName, value: value)
4043
}
4144

4245
guard let body = body else {
@@ -53,6 +56,16 @@ open class HttpRequestTestBase: XCTestCase {
5356

5457
}
5558

59+
func sanitizeStringForNonConformingValues(_ input: String) -> String {
60+
switch input {
61+
case "Infinity": return "inf"
62+
case "-Infinity": return "-inf"
63+
case "NaN": return "nan"
64+
default:
65+
return input
66+
}
67+
}
68+
5669
/**
5770
Check if a Query Item with given name exists in array of `URLQueryItem`
5871
*/
@@ -187,7 +200,7 @@ open class HttpRequestTestBase: XCTestCase {
187200

188201
XCTAssert(expectedQueryItems.count == actualQueryItems.count, "Number of query params does not match")
189202
for (keyValue, expectedCount) in expectedKVCount {
190-
XCTAssert(actualKVCount[keyValue] == expectedCount, "Expected \(keyValue) to appear \(expectedCount) times. Acutal: \(actualKVCount[keyValue] ?? 0)")
203+
XCTAssert(actualKVCount[keyValue] == expectedCount, "Expected \(keyValue) to appear \(expectedCount) times. Actual: \(actualKVCount[keyValue] ?? 0)")
191204
}
192205
}
193206

0 commit comments

Comments
 (0)