Skip to content

Commit

Permalink
add integration test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Di Wu committed Aug 30, 2023
1 parent 81da31c commit c891933
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ final public class AWSRESTOperation: AmplifyOperation<
}
}

// apply customized request headers
// The headers from the request object should override any of the same header modifications done by the intercepters above
finalRequest = RESTOperationRequestUtils.applyCustomizeRequestHeaders(request.headers, on: finalRequest)

if isCancelled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,25 @@ class RESTWithIAMIntegrationTests: XCTestCase {
XCTAssertEqual(statusCode, 404)
}
}

func testRestRequest_withCustomizeHeaders_succefullyOverride() async throws {
let request = RESTRequest(path: "/items", headers: ["Content-Type": "text/plain"])
do {
_ = try await Amplify.API.get(request: request)
XCTFail("Should catch error")
} catch {
guard let apiError = error as? APIError else {
XCTFail("Error should be APIError")
return
}
guard case let .httpStatusError(statusCode, _) = apiError else {
XCTFail("Error should be httpStatusError")
return
}

XCTAssertEqual(statusCode, 403)
}
}
}

extension RESTWithIAMIntegrationTests: DefaultLogger { }

0 comments on commit c891933

Please sign in to comment.