Packet capture tool Charles (6) - use remote mapping to redirect interface requests (Map remote)

  • During testing and development, it is sometimes necessary to modify the return status or return value of an interface.
  • In Charles, the response of another interface can be returned to the original interface through remote mapping, so as to achieve the purpose of modifying the interface response.
  • This function can also be switched between the official line domain name and the test line domain name.

1. Principle

2. Operation steps

(1), Add interface mapping

1. Single interface

  • Select the target interface, right-click, and find "Map Remote"
    insert image description here

2. Batch add

  • Or under the "Tool" menu, find "Map Remote"
    insert image description here
  • After opening the remote mapping settings, check "Enable MapRemote", click "Add" to add interface mapping
    insert image description here

(2), set the matching mapping interface

  • After opening the interface mapping dialog box, you can see that the upper part is the interface URL information that matches the mapping.
  • Charles will match specific URLs based on protocol, host, port, path, and query parameters.
  • These settings support wildcards. For example, if the query parameter is configured as "*", all query parameters under this path will be matched.
    insert image description here

(3), specify the target address of the mapping

  • Like configuring the interface that needs to match, the second half sets the target interface of the mapping
  • You can also set the protocol, host, port, path, query parameters,
  • These settings support wildcards.insert image description here
  • The check box at the bottom of the pop-up box is to preserve the original host in the request header (Preserve host in header fields), which can be set as needed.
    insert image description here

(4), example steps

  • Take the interface of Charles official website as an example: through remote mapping, return other webpages to the official website address
    insert image description here
  • Configure remote mapping
    insert image description here
  • After the configuration is complete, refresh the page. It can be seen in Charles that a new address is requested, and it is also marked under the overview tab that this interface is requested by the remote mapping of the original interface.
    insert image description here
  • View the page and you can see that now requesting the address of the official website returns other websites
    insert image description here

3. Note: Remember to turn off when not in use!

  • Sometimes I encountered situations where the data did not match the actual expectations. After checking for a long time, the result was that I forgot to turn off the interface mapping [wry smile]
  • Under the "Tools" menu, find "Map Remote"
    insert image description here
  • Uncheck "Enable Map Remote" and save it.
    insert image description here

Appendix: Interface Functional Testing Series Tutorial Contents

Packet capture tool Charles (1) - download, install and set up
packet capture tool Charles (2) - mobile APP packet capture (set up mobile phone proxy, install certificate)
packet capture tool Charles (3) - tutorial interface introduction, basic functions ( Weak network, editing, retransmission)
Packet capture tool Charles (4) - Introduction to common functions (save, import and export, filter, sort)
Packet capture tool Charles (5) - Use local mapping to modify interface response content (Map local)
Packet capture Tool Charles (6) - use remote mapping to redirect interface requests (Map remote)

General Catalog-Zero-Basic Getting Started Interface Functional Testing Tutorial
———————————————————————————————————————————————————
Charles installation package has been uploaded to I run a blog with the same name as the public account [Software Testing Essential Skills].
The public will also upload test-related materials from time to time, and they can go to collect them if necessary.
insert image description here
If necessary, click on the QR code at the bottom of the article to get it~insert image description here

Acho que você gosta

Origin blog.csdn.net/weixin_40883833/article/details/129868041
Recomendado
Clasificación