proxyman-windows-linux icon indicating copy to clipboard operation
proxyman-windows-linux copied to clipboard

[Scripting] Color/Comment by Script

Open NghiaTranUIT opened this issue 1 year ago • 0 comments

Description

⚠️ this ticket should be implemented after the #379

  • The script can modify the comment and color
  • Doc: https://docs.proxyman.io/scripting/snippet-code#comment-and-highlight-with-color
function onRequest(context, url, request) {
    request.comment = "It's a Request"
    request.color = "red" // red, blue, yellow, purple, gray, green
    return request
}

function onResponse(context, url, request, response) {
    response.comment = "It's a Response"
    response.color = "yellow" // red, blue, yellow, purple, gray, green
    return response
}

Acceptance Criteria

  • [x] Support: Comment on flow.
  • [x] Support: Color on flow. If the color doesn't match. For example: request.color = "abc" -> Ignore it
  • [x] Write Unit Test for the Comment and Color logic -> Verify the flow in the FlowPool

how to test

  1. Make a script with the following script
///
async function onResponse(context, url, request, response) {

  if (request.method == "GET") {
    response.comment = "It's a GET Method"
    response.color = "green"
  } else if (request.method == "POST") {
    response.comment = "It's a POST Method"
    response.color = "yellow"
  }

  // Done
  return response;
}
  1. Make some GET, POST, PUT requests
  2. Verify we have color and comment correctly
  3. For the PUT Request -> No Color or comment
  4. Export these requests to ProxymanLog -> Important again -> Verify the color is correct

NghiaTranUIT avatar Mar 03 '24 03:03 NghiaTranUIT