Skip to content
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

Additional EmbraceUrlConnectionDelegate unit tests and bug fixes #50

Merged
merged 4 commits into from
Nov 9, 2023

Conversation

bidetofevil
Copy link
Collaborator

@bidetofevil bidetofevil commented Nov 7, 2023

Goal

Add additional unit tests for more cases for logging URLConnection requests and fix a few issues that were found. Specifically:

  • Making it more consistent and efficient when the SDK is not on to bypass the logging code
  • Add query string to the URL logged if there's a custom path override
  • Record response body even when the network call data had been previously cached.

Testing

Add unit tests of important cases where breakage may not be obvious

Copy link
Collaborator Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@bidetofevil bidetofevil force-pushed the hho/moar-network-tests branch 2 times, most recently from b16e8ba to 115affb Compare November 7, 2023 23:05
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #50 (adf9383) into master (eded592) will increase coverage by 1.13%.
The diff coverage is 83.78%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   73.47%   74.60%   +1.13%     
==========================================
  Files         306      306              
  Lines       10070    10082      +12     
  Branches     1448     1454       +6     
==========================================
+ Hits         7399     7522     +123     
+ Misses       2103     1980     -123     
- Partials      568      580      +12     
Files Coverage Δ
...network/http/EmbraceHttpUrlConnectionOverride.java 60.00% <100.00%> (+20.00%) ⬆️
...nal/network/http/EmbraceUrlConnectionDelegate.java 82.85% <83.33%> (+32.85%) ⬆️

... and 2 files with indirect coverage changes

@bidetofevil bidetofevil force-pushed the hho/moar-network-tests branch from 115affb to 3d53364 Compare November 7, 2023 23:34
@bidetofevil bidetofevil force-pushed the hho/moar-network-tests branch from 8de4c9f to c78bdc8 Compare November 8, 2023 00:16
@bidetofevil bidetofevil marked this pull request as ready for review November 8, 2023 03:34
@bidetofevil bidetofevil requested a review from a team as a code owner November 8, 2023 03:34
@@ -28,7 +28,7 @@ public String getHeaderByName(@NonNull String name) {
public String getOverriddenURL(@NonNull String pathOverride) {
try {
return new URL(connection.getURL().getProtocol(), connection.getURL().getHost(),
connection.getURL().getPort(), pathOverride).toString();
connection.getURL().getPort(), pathOverride + "?" + connection.getURL().getQuery()).toString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this change? Is it because we were discarding the query params?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This is the bug I mention in the second bullet point in the PR description. When you toString() a URL, it includes the query path as part of the returned string. When we return teh URL with an overridden path, we should do the same. (This is what the OkHttp implementation does)

@bidetofevil bidetofevil merged commit 830b97e into master Nov 9, 2023
4 checks passed
@bidetofevil bidetofevil deleted the hho/moar-network-tests branch November 9, 2023 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants