-
Notifications
You must be signed in to change notification settings - Fork 77
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
Monitored requests have no httpBody #203
Comments
Hi there! I just tried running the library's test suite on an iOS 17.2 simulator, and tests are passing including a few that also verify the httpBody. Moreover we have several tests in the codebase @Subito that monitor requests and checks the httpBody. Did you try to replicate the issue in a separate project that can be shared? It would make debugging the issue easier. |
Hey @tcamin, I have the same problem. Try to change httpBody in this test to
|
That's interesting! I'll try to take a look as soon as I can. |
I've have this open branch to test out |
hey @tcamin thanks for the quick fix. I just tried and whereas now the request has an
|
I'm checking the diff:
it seems that |
Yeah so the original body is something like this:
and what I get in the monitored |
The logic should be right, I've slightly modified the implementation which should address the issue you are experiencing. Let me know if it works now. |
Thanks @tcamin . I've updated my dependency to point at What is it that you tweaked? |
Same issue as in |
Getting UUID |
Could you try again on e5c0f7f? |
hey same issue on
|
@tcamin it seems that the properties saved in |
@tcamin we have the same issue, any updates about the fix |
Hi! Sorry for the late reply. It would help if you could provide a way to replicate this locally, ideally by adding a failing test to the libary. |
@tcamin We appreciate your support and adding this test will help reproduce the issue locally. Please add the following test to func testMonitorPostRequestWithHTTPLargeBodyInAppProcess() {
let largeBody = String(repeating: "a", count: 20000)
let matchingRequest = SBTRequestMatch(url: "httpbin.org", method: "POST")
app.monitorRequests(matching: matchingRequest)
XCTAssertTrue(app.tables.firstMatch.staticTexts["executePostDataTaskRequestWithLargeHTTPBody"].waitForExistence(timeout: 5))
app.tables.firstMatch.staticTexts["executePostDataTaskRequestWithLargeHTTPBody"].tap()
XCTAssertTrue(app.waitForMonitoredRequests(matching: matchingRequest, timeout: 10))
let requests = app.monitoredRequestsFlushAll()
XCTAssertEqual(requests.count, 1)
print(requests.map(\.debugDescription))
for request in requests {
guard let httpBody = request.request?.httpBody else {
XCTFail("Missing http body")
continue
}
XCTAssertEqual(String(data: httpBody, encoding: .utf8), largeBody)
XCTAssert((request.responseString()!).contains("httpbin.org"))
XCTAssert(request.timestamp > 0.0)
XCTAssert(request.requestTime > 0.0)
}
XCTAssert(app.stubRequestsRemoveAll())
XCTAssert(app.monitorRequestRemoveAll())
} and add in @objc func executePostDataTaskRequestWithLargeHTTPBody() {
let largeBody = String(repeating: "a", count: 20000)
dataTaskNetwork(urlString: "https://httpbin.org/post", httpMethod: "POST", httpBody: largeBody)
} The issue is that the request being fired is from the app process and not from the UITest process. As a result, we are unable to obtain the original request body. |
this is working @AhmedAshraf605 , thanks for the contribution 🙌 @tcamin will you cut a new version soon? |
Hi! If everything works on our tests suites for a few days I will release a new version in the coming week. |
Hi, I have this UITest that was previously working in iOS 16.4 simulator. We've moved now to use iOS 17.2 simulator. We're using latest version 10.0.0. I'm monitoring a request and debugging I can see we send a body. However, when I peek the requests:
I see my requests have no
httpBody
somehow whereas if I run the same test on iOS 16.4 I can see the body. This is a regular request usingURLSession.dataTask(with:completionHandler)
.Any ideas what's wrong?
The text was updated successfully, but these errors were encountered: