[GH-ISSUE #223] [Breakpoint] #6 Unit Test for Breakpoint Service #223

Open
opened 2026-03-03 19:49:17 +03:00 by kerem · 5 comments
Owner

Originally created by @NghiaTranUIT on GitHub (Apr 10, 2023).
Original GitHub issue: https://github.com/ProxymanApp/proxyman-windows-linux/issues/223

Originally assigned to: @kics223w1 on GitHub.

Description

It's time to write Unit Tests for the Breakpoint Service to verify it covers all user-case

⚠️ Ping @NghiaTranUIT to get the sample of BreakpointServiceTests file

In general, it's similar to #209:

  1. Start the Core
  2. Setup Breakpoint Rule with the given criteria
  3. Make a request to httpbin.org
  4. Modify the Request/Response data
  5. Verify the HTTPBin Body that the Request is updated by Breakpoint
  6. Verify the Response to verify the Header, Status Code, and body is updated by Breakpoint

Unit Test cases: Continue logic

1: Request Breakpoint on GET - HTTPS - Update Query Tab

Given:

  • Create a Breakpoint Rule (Request Only)
  • Make a GET https://httpbin.org/get Request
  • Modify the Header and Query tab.

Expected:

  • New Header and Query are in the Response Body

2: Request Breakpoint on GET - HTTPS - Update query from URL

Given:

  • Create a Breakpoint Rule (Request Only)
  • Make a GET https://httpbin.org/get Request, Modify the Header, and Query from the URL, e.g https://httpbin.org/get?id=123

Expected:

  • New Header and Query are in the Response Body

3: Request Breakpoint on POST JSON

  • Given: Make a POST httpbin.org Request, Modify the Header, and Query and JSON Body. Create a Breakpoint Rule (Request Only)
  • Expected: New Header and Query and the body are in the Response Body

4: Request Breakpoint on POST Form - Update by Body Tab

  • Given: Make a POST httpbin.org Request, Modify the Header, and Query and Form Body (in the Body Tab). Create a Breakpoint Rule (Request Only)
  • Expected: New Header and Query and the body are in the Response Body

5: Request Breakpoint on POST Form - Update by Form Tab

  • Given: Make a POST httpbin.org Request, Modify the Header, and Query and Form Body (in the Form Tab). Create a Breakpoint Rule (Request Only)
  • Expected: New Header and Query and the body are in the Response Body

6: Request Breakpoint and change the Method and URL

  • Given: Make a GET https://httpbin.org/get Request, Modify Method = POST, URL = https://httpbin.org/post?id=123, add some JSON Body. Create a Breakpoint Rule (Request Only)
  • Expected: There is a Query (id=123), and URL = "https://httpbin.org/post?id=123" and the JSON Body are in the Response Body

7: Request Breakpoint - Change different URL

  • Given: Make a GET httpbin.org Request => Update URL to www.google.com Create a Breakpoint Rule (Request Only)
  • Expected: The Response Body is not from httpbin.org, it's a google HTML
Originally created by @NghiaTranUIT on GitHub (Apr 10, 2023). Original GitHub issue: https://github.com/ProxymanApp/proxyman-windows-linux/issues/223 Originally assigned to: @kics223w1 on GitHub. ## Description It's time to write Unit Tests for the Breakpoint Service to verify it covers all user-case ⚠️ Ping @NghiaTranUIT to get the sample of `BreakpointServiceTests` file In general, it's similar to #209: 1. Start the Core 2. Setup Breakpoint Rule with the given criteria 3. Make a request to `httpbin.org` 4. Modify the Request/Response data 5. Verify the HTTPBin Body that the Request is updated by Breakpoint 6. Verify the Response to verify the Header, Status Code, and body is updated by Breakpoint ## Unit Test cases: Continue logic ### 1: Request Breakpoint on GET - HTTPS - Update Query Tab Given: - Create a Breakpoint Rule (Request Only) - Make a GET https://httpbin.org/get Request - Modify the Header and Query tab. Expected: - New Header and Query are in the Response Body ### 2: Request Breakpoint on GET - HTTPS - Update query from URL Given: - Create a Breakpoint Rule (Request Only) - Make a GET https://httpbin.org/get Request, Modify the Header, and Query from the URL, e.g `https://httpbin.org/get?id=123` Expected: - New Header and Query are in the Response Body ### 3: Request Breakpoint on POST JSON - Given: Make a POST httpbin.org Request, Modify the Header, and Query and JSON Body. Create a Breakpoint Rule (Request Only) - Expected: New Header and Query and the body are in the Response Body ### 4: Request Breakpoint on POST Form - Update by Body Tab - Given: Make a POST httpbin.org Request, Modify the Header, and Query and Form Body (in the Body Tab). Create a Breakpoint Rule (Request Only) - Expected: New Header and Query and the body are in the Response Body ### 5: Request Breakpoint on POST Form - Update by Form Tab - Given: Make a POST httpbin.org Request, Modify the Header, and Query and Form Body (in the Form Tab). Create a Breakpoint Rule (Request Only) - Expected: New Header and Query and the body are in the Response Body ### 6: Request Breakpoint and change the Method and URL - Given: Make a GET https://httpbin.org/get Request, Modify Method = POST, URL = `https://httpbin.org/post?id=123`, add some JSON Body. Create a Breakpoint Rule (Request Only) - Expected: There is a Query (id=123), and URL = "https://httpbin.org/post?id=123" and the JSON Body are in the Response Body ### 7: Request Breakpoint - Change different URL - Given: Make a GET httpbin.org Request => Update URL to `www.google.com` Create a Breakpoint Rule (Request Only) - Expected: The Response Body is not from httpbin.org, it's a google HTML
Author
Owner

@NghiaTranUIT commented on GitHub (Apr 10, 2023):

Unit Test cases: Abort logic

1: Abort a single request

Given:

  • Make a httpbin.org request -> Create a Breakpoint Rule
  • Abort a request

Expected:

  • The fetch library returns an error (Socket closed or anything means that the connection is aborted)

2: Abort all

Given:

  • Create a Breakpoint Rule
  • Make 5 requests
  • Call Abort all

Expected:

  • The fetch library returns an error for all requests (Socket closed or anything means that the connection is aborted)
<!-- gh-comment-id:1501560749 --> @NghiaTranUIT commented on GitHub (Apr 10, 2023): ## Unit Test cases: Abort logic ### 1: Abort a single request Given: - Make a httpbin.org request -> Create a Breakpoint Rule - Abort a request Expected: - The `fetch` library returns an error (Socket closed or anything means that the connection is aborted) ### 2: Abort all Given: - Create a Breakpoint Rule - Make 5 requests - Call Abort all Expected: - The `fetch` library returns an error for all requests (Socket closed or anything means that the connection is aborted)
Author
Owner

@NghiaTranUIT commented on GitHub (Apr 10, 2023):

Unit Test cases: Continue Logic

1: Continue a Request

Given:

  • Create a Breakpoint Rule (Request Only)
  • Make a httpbin.org request
  • Try to modify some URL, Method, Query, Header, and the Body
  • Continue the Request

Expected:

  • The HTTPBin Response contains the original request (Make sure the breakpoint doesn't change the data)

1: Continue a Response

Given:

  • Create a Breakpoint Rule (Response Only)
  • Make a httpbin.org request
  • Try to modify some Status Code, Header and the Body
  • Continue the Response

Expected:

  • The HTTPBin Response contains the original request (Make sure the breakpoint doesn't change the data)
<!-- gh-comment-id:1501562091 --> @NghiaTranUIT commented on GitHub (Apr 10, 2023): ## Unit Test cases: Continue Logic ### 1: Continue a Request Given: - Create a Breakpoint Rule (Request Only) - Make a httpbin.org request - Try to modify some URL, Method, Query, Header, and the Body - Continue the Request Expected: - The HTTPBin Response contains the original request (Make sure the breakpoint doesn't change the data) ### 1: Continue a Response Given: - Create a Breakpoint Rule (Response Only) - Make a httpbin.org request - Try to modify some Status Code, Header and the Body - Continue the Response Expected: - The HTTPBin Response contains the original request (Make sure the breakpoint doesn't change the data)
Author
Owner

@NghiaTranUIT commented on GitHub (Apr 10, 2023):

Unit Test cases: Breakpoint on Response

1: Response Breakpoint: Header and Body

Given:

  • Create a Breakpoint Rule (Response Only)
  • Make a GET https://httpbin.org/get Request
  • Modify the Header and Body on the Response by Breakpoint

Expected:

  • New Header and Body are in the Response Body

2: Response Breakpoint: Status Code

Given:

Expected:

  • Response has new status code
<!-- gh-comment-id:1501563482 --> @NghiaTranUIT commented on GitHub (Apr 10, 2023): ## Unit Test cases: Breakpoint on Response ### 1: Response Breakpoint: Header and Body Given: - Create a Breakpoint Rule (Response Only) - Make a GET https://httpbin.org/get Request - Modify the Header and Body on the Response by Breakpoint Expected: - New Header and Body are in the Response Body ### 2: Response Breakpoint: Status Code Given: - Create a Breakpoint Rule (Response Only) - Make a GET https://httpbin.org/get Request - Modify the Status Code Expected: - Response has new status code
Author
Owner

@NghiaTranUIT commented on GitHub (Apr 10, 2023):

Unit Test cases: Breakpoint on Request & Response

1: Modify everything

Given:

  • Create a Breakpoint Rule (Request & Response)
  • Make a POST https://httpbin.org/get
  • Modify the Header and Body, Query the Request by Breakpoint
  • Set "Execute"
  • Modify the Header and Body the Response by Breakpoint

Expected:

  • Verify the Response HTTPBin Body that new headers, query, body is updated properly
  • Verify the Response to the Headers and body is correct.
<!-- gh-comment-id:1501569470 --> @NghiaTranUIT commented on GitHub (Apr 10, 2023): ## Unit Test cases: Breakpoint on Request & Response ### 1: Modify everything Given: - Create a Breakpoint Rule (Request & Response) - Make a POST https://httpbin.org/get - Modify the Header and Body, Query the Request by Breakpoint - Set "Execute" - Modify the Header and Body the Response by Breakpoint Expected: - Verify the Response HTTPBin Body that new headers, query, body is updated properly - Verify the Response to the Headers and body is correct.
Author
Owner

@NghiaTranUIT commented on GitHub (May 8, 2023):

Additionally Test

<!-- gh-comment-id:1537830026 --> @NghiaTranUIT commented on GitHub (May 8, 2023): ### Additionally Test - Please write a Unit Test for 2 scenarios at https://github.com/ProxymanApp/proxyman-electron-app/pull/236#pullrequestreview-1416200372
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxyman-windows-linux#223
No description provided.