使用抓包工具fiddler和apipost進行接口測試

{"type":"doc","content":[{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"一、進行接口測試準備的東西"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.接口測試工具:apipost、jmeter等"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.接口文檔,沒有接口文檔就用接口信息獲取工具"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3.接口信息收取工具:fiddler抓包工具、瀏覽器開發者工具(f12)等"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"二、web接口測試需要獲取的東西"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"web接口測試需要知道的三個條件"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.請求方式:get、post、put、patch、delete等"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.url地址:分爲http請求和https是請求,如:"},{"type":"link","attrs":{"href":"https://link.zhihu.com/?target=http%3A//www.baidu.com","title":null},"content":[{"type":"text","text":"http://www.baidu.com"}]},{"type":"text","text":"和"},{"type":"link","attrs":{"href":"https://link.zhihu.com/?target=https%3A//www.baidu.com","title":null},"content":[{"type":"text","text":"https://www.baidu.com"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3.body傳遞的參數:一般是以json的格式傳遞參數如:\"name\":\"xiaoming\",\"pwd\":\"123\"。一般以post傳遞參數請求爲多"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/d5/d5c15b9116689833877cc15e97e15596.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"三、fiddler抓包工具"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"fiddler是由 C# 開發的最強大好用的免費web調試工具之一,可記錄所有客戶端和服務見的 http 以及 https 請求,可監視設斷點,甚至修改輸入輸出數據,它還包含了一個強大的基於事件腳本的子系統,並且能使用 .net 語言來拓展。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"fiddler就是通過我們對網頁的操作使用而進行的接口信息的抓取的。抓取之後按照上面需求的請求方法、url和body來查找需要的數據。"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/48/488d4783d42fba96f0e59d8611f5d2ba.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這是一個簡單的登錄請求被fiddler抓取到的信息,我們可以用到的分別是:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1.Protocol請求類型:http或https。這裏是http"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"2.host+url兩個加起來形成的接口訪問地址。這裏的請求地址爲:"},{"type":"link","attrs":{"href":"https://link.zhihu.com/?target=http%3A//127.0.0.1%3A8888/login","title":null},"content":[{"type":"text","text":"127.0.0.1:8888/login"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"3.Request Haeders(請求頭部信息)中的請求方法:get、post等。這裏是post請求"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/47/477dc6c86ab5c2d0ac4879b744066504.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"之後再點擊Inspectors中的WebForms查看body參數。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"獲取的參數爲,參數名:參數值,name:xiaoming,pwd:111"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/3f/3f97d90506dcd6dcda3ea1f6d7640c9e.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"四、接口測試"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過fiddler已經收取到這個接口的具體信息之後,我們通過接口測試工具apipost進行接口測試。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"選擇請求方法post、請求地址:"},{"type":"link","attrs":{"href":"https://link.zhihu.com/?target=http%3A//127.0.0.1%3A8888/login","title":null},"content":[{"type":"text","text":"http://127.0.0.1:8888/login"}]},{"type":"text","text":"、body參數:name:xiaoming,pwd:111"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/0f/0fa46e7c285aa6aac8ae3384d90d7327.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"查看請求結果"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/8a/8afa82e5c5dd02a5731e743fe695a2f7.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這就是通過fiddler和apipost進行接口測試的步驟。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"fiddler下載地址:https://www.telerik.com/fiddler"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"apipost下載地址:"},{"type":"link","attrs":{"href":"https://www.apipost.cn/?dt=20201031","title":""},"content":[{"type":"text","text":"https://www.apipost.cn/?dt=20201031"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章