Skip to content

Add Regex skipPath/skipDomain to Builder, fixes #1236#1242

Merged
cortinico merged 10 commits into
ChuckerTeam:mainfrom
VenomVendor:main
Jul 16, 2024
Merged

Add Regex skipPath/skipDomain to Builder, fixes #1236#1242
cortinico merged 10 commits into
ChuckerTeam:mainfrom
VenomVendor:main

Conversation

@VenomVendor

Copy link
Copy Markdown
Contributor

📷 Screenshots

When .skipPaths(".*(jpg|jpeg|png|gif|webp|svg|bmp|ico)$".toRegex()) is set

filter-image.mp4

When .skipDomain(".*akamai.com".toRegex(), "httpbin.org".toRegex()) is set

filter-domain.mp4

📄 Context

Fixes #1236

📝 Changes

  • Added two new functions to Builder
    • skipPath(...Regex)
    • skipDomain(...Regex)

🛠️ How to test

Check commmit eaff3e1, and uncomment skipPath and/or skipDomain as needed.

Skip domian and/path when matches with regex
Fixes #1236
Moved tests
Code clean up
To ensure tests are properly tested, check for no transaction before expecting new one
Added autogenerated API changes
@VenomVendor VenomVendor requested a review from a team as a code owner July 10, 2024 03:14
Comment thread detekt-config.yml Outdated
executeRequestForPath(client, "/", "Response from /")
val transaction = chuckerInterceptorWithoutSkipping.expectTransaction()
assertThat(transaction.responseBody).isEqualTo("Response from /")
chuckerInterceptorWithoutSkipping.expectNoTransactions()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added chuckerInterceptorWithoutSkipping.expectNoTransactions() to ensure false positive checks.

@cortinico cortinico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code looks good to me @VenomVendor 👍
Thanks for adding this. I've left some comments on the API but we can merge it just after it

* ".*path/ends/with/dev$".toRegex(),
* ```
*/
public fun skipPaths(vararg skipPaths: Regex): Builder =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't need to be a vararg, it can just be a single Regex

* ".*.dev$".toRegex(),
* ```
*/
public fun skipDomain(vararg skipDomain: Regex): Builder =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we add this, we'll have to add also skipDomain(vararg skipDomain: String)

Also here please remove the vararg

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

vararg to be removed.
Should we have both string and regex or deprecate string?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can have both 👍 they're so simple no need to deprecate the Regex

@cortinico cortinico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(see API comments)

@cortinico cortinico left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't forget to add also skipDomain(vararg skipDomain: String) 👍 and then we can merge this

Comment thread library/src/main/kotlin/com/chuckerteam/chucker/api/ChuckerInterceptor.kt Outdated
@cortinico cortinico enabled auto-merge (squash) July 16, 2024 10:09
@cortinico cortinico merged commit 5261314 into ChuckerTeam:main Jul 16, 2024
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.

Ignore domains and paths from interceptor

2 participants