Skip to content

Commit

Permalink
Fix merge & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins committed Jan 14, 2025
1 parent 31ffa70 commit 51db47a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public enum AWSEndpointConfig {
).value ?? .preferred
}

public enum AWSEndpointConfig {
static func configuredEndpoint(
sdkID: String,
ignoreConfiguredEndpointURLs: Bool?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ private func setFlagsIntoContext(
}
}

// Handle S
if context.selectedAuthScheme?.schemeID == "aws.auth#sigv4a" {
context.businessMetrics = ["SIGV4A_SIGNING": "S"]
}
Expand All @@ -107,12 +106,6 @@ private func setFlagsIntoContext(
context.businessMetrics = ["RESOLVED_ACCOUNT_ID": "T"]
}

if let endpoint = config.endpoint, !endpoint.isEmpty {
context.businessMetrics = ["ENDPOINT_OVERRIDE": "N"]
}
if context.selectedAuthScheme?.schemeID == "aws.auth#sigv4a" {
context.businessMetrics = ["SIGV4A_SIGNING": "S"]
}
switch context.checksum {
case .crc32:
context.businessMetrics = ["FLEXIBLE_CHECKSUMS_REQ_CRC32": "U"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BusinessMetricsTests: XCTestCase {
var headers: Headers!

override func setUp() async throws {
config = UserAgentValuesFromConfig(appID: nil, endpoint: nil, awsRetryMode: .standard)
config = UserAgentValuesFromConfig(appID: nil, endpoint: nil, awsRetryMode: .standard, requestChecksumCalculation: .whenSupported, responseChecksumValidation: .whenSupported)
context = Context(attributes: Attributes())
headers = Headers()
}
Expand All @@ -33,24 +33,10 @@ class BusinessMetricsTests: XCTestCase {
context.businessMetrics = ["SHORT_FILLER": "A"]
let longMetricValue = String(repeating: "F", count: 1025)
context.businessMetrics = ["LONG_FILLER": longMetricValue]
config = UserAgentValuesFromConfig(appID: nil, endpoint: nil, awsRetryMode: .standard, requestChecksumCalculation: .whenRequired, responseChecksumValidation: .whenRequired)

let userAgent = testUserAgent()
let userAgent = createTestUserAgent()

=======
let userAgent = AWSUserAgentMetadata.fromConfigAndContext(
serviceID: "test",
version: "1.0",
config: UserAgentValuesFromConfig(
appID: nil,
endpoint: nil,
awsRetryMode: .standard,
requestChecksumCalculation: .whenRequired,
responseChecksumValidation: .whenRequired
),
context: context,
headers: headers
)
>>>>>>> main
// Assert values in context match with values assigned to user agent
XCTAssertEqual(userAgent.businessMetrics?.features, context.businessMetrics)
// Assert string gets truncated successfully
Expand All @@ -69,26 +55,10 @@ class BusinessMetricsTests: XCTestCase {
signingProperties: nil,
signer: nil
))
<<<<<<< HEAD

config = UserAgentValuesFromConfig(appID: nil, endpoint: "test-endpoint", awsRetryMode: .adaptive)
let userAgent = testUserAgent()
config = UserAgentValuesFromConfig(appID: nil, endpoint: "test-endpoint", awsRetryMode: .adaptive, requestChecksumCalculation: .whenSupported, responseChecksumValidation: .whenSupported)
let userAgent = createTestUserAgent()

=======
let userAgent = AWSUserAgentMetadata.fromConfigAndContext(
serviceID: "test",
version: "1.0",
config: UserAgentValuesFromConfig(
appID: nil,
endpoint: "test-endpoint",
awsRetryMode: .adaptive,
requestChecksumCalculation: .whenSupported,
responseChecksumValidation: .whenSupported
),
context: context,
headers: headers
)
>>>>>>> main
// F comes from retry mode being adaptive & N comes from endpoint override
let expectedString = "m/A,B,F,N,S,Z,b"
XCTAssertEqual(userAgent.businessMetrics?.description, expectedString)
Expand All @@ -99,20 +69,20 @@ class BusinessMetricsTests: XCTestCase {
func test_accountIDInEndpoint_noAccountIDInEndpoint() {
configureContext(host: "dynamodb.us-east-1.amazonaws.com", accountID: "0123456789")

let userAgent = testUserAgent()
let userAgent = createTestUserAgent()

// E comes from retry mode & T comes from resolving account ID
let expectedString = "m/E,T"
let expectedString = "m/E,T,Z,b"
XCTAssertEqual(userAgent.businessMetrics?.description, expectedString)
}

func test_accountIDInEndpoint_hasAccountIDInEndpoint() {
configureContext(host: "0123456789.dynamodb.us-east-1.amazonaws.com", accountID: "0123456789")

let userAgent = testUserAgent()
let userAgent = createTestUserAgent()

// E comes from retry mode, O comes from account ID in endpoint, & T comes from resolving account ID
let expectedString = "m/E,O,T"
let expectedString = "m/E,O,T,Z,b"
XCTAssertEqual(userAgent.businessMetrics?.description, expectedString)
}

Expand All @@ -121,36 +91,36 @@ class BusinessMetricsTests: XCTestCase {
func test_accountIDEndpointMode_recordsPreferredCorrectly() {
context.accountIDEndpointMode = .preferred

let userAgent = testUserAgent()
let userAgent = createTestUserAgent()

// E comes from retry mode & P comes from preferred account ID endpoint mode
let expectedString = "m/E,P"
let expectedString = "m/E,P,Z,b"
XCTAssertEqual(userAgent.businessMetrics?.description, expectedString)
}

func test_accountIDEndpointMode_recordsDisabledCorrectly() {
context.accountIDEndpointMode = .disabled

let userAgent = testUserAgent()
let userAgent = createTestUserAgent()

// E comes from retry mode & Q comes from disabled account ID endpoint mode
let expectedString = "m/E,Q"
let expectedString = "m/E,Q,Z,b"
XCTAssertEqual(userAgent.businessMetrics?.description, expectedString)
}

func test_accountIDEndpointMode_recordsRequiredCorrectly() {
context.accountIDEndpointMode = .required

let userAgent = testUserAgent()
let userAgent = createTestUserAgent()

// E comes from retry mode & R comes from required account ID endpoint mode
let expectedString = "m/E,R"
let expectedString = "m/E,R,Z,b"
XCTAssertEqual(userAgent.businessMetrics?.description, expectedString)
}

// MARK: - Private methods

private func testUserAgent() -> AWSUserAgentMetadata {
private func createTestUserAgent() -> AWSUserAgentMetadata {
AWSUserAgentMetadata.fromConfigAndContext(
serviceID: "test",
version: "1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,10 @@ let projection2: [Swift.String]? = objects2?.compactMap { original in
let id = original.id
return id
}
<<<<<<< HEAD
let endpointParamsBlock = { [config] (context: Smithy.Context) in
EndpointParams(boolBar: true, boolBaz: input.fuzz, boolFoo: config.boolFoo, endpoint: config.endpoint, flattenedArray: projection, keysFunctionArray: keys, region: region, stringArrayBar: ["five", "six", "seven"], stringBar: "some value", stringBaz: input.buzz, stringFoo: config.stringFoo, subfield: subfield2, wildcardProjectionArray: projection2)
EndpointParams(boolBar: true, boolBaz: input.fuzz, boolFoo: config.boolFoo, endpoint: configuredEndpoint, flattenedArray: projection, keysFunctionArray: keys, region: region, stringArrayBar: ["five", "six", "seven"], stringBar: "some value", stringBaz: input.buzz, stringFoo: config.stringFoo, subfield: subfield2, wildcardProjectionArray: projection2)
}
builder.applyEndpoint(AWSClientRuntime.AWSEndpointResolverMiddleware<GetThingOutput, EndpointParams>(paramsBlock: endpointParamsBlock, resolverBlock: { [config] in try config.endpointResolver.resolve(params: ${'$'}0) }))
=======
let endpointParams = EndpointParams(boolBar: true, boolBaz: input.fuzz, boolFoo: config.boolFoo, endpoint: configuredEndpoint, flattenedArray: projection, keysFunctionArray: keys, region: region, stringArrayBar: ["five", "six", "seven"], stringBar: "some value", stringBaz: input.buzz, stringFoo: config.stringFoo, subfield: subfield2, wildcardProjectionArray: projection2)
builder.applyEndpoint(AWSClientRuntime.EndpointResolverMiddleware<GetThingOutput, EndpointParams>(endpointResolverBlock: { [config] in try config.endpointResolver.resolve(params: ${'$'}0) }, endpointParams: endpointParams))
>>>>>>> main
"""
contents.shouldContainOnlyOnce(expected)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ extension ExampleClient {
try AWSClientConfigDefaultsProvider.awsCredentialIdentityResolver(),
try AWSClientRuntime.AWSClientConfigDefaultsProvider.retryMode(),
nil,
try AWSClientConfigDefaultsProvider.requestChecksumCalculation(),
try AWSClientConfigDefaultsProvider.responseChecksumValidation(),
nil,
region,
region,
Expand Down

0 comments on commit 51db47a

Please sign in to comment.