当前位置:网站首页>Authentication processing in interface testing framework
Authentication processing in interface testing framework
2022-07-01 16:18:00 【Code classmate software test】
picture
There is usually an authentication mechanism in interface automated testing , It is to judge whether it is in the login state , The logged in party can call the interface , If you are not logged in, you cannot call . This article will lead you to learn and use rest-assured The framework implementation is based on cookies and token Authentication Association of , Realize interface automation test .
1
be based on cookies Authentication Association of
Familiar with business interface
Code classmate full stack interface project is based on cookies Query balance interface , You must call the login interface to get cookie And pass it to the query balance interface , The information of the two interfaces is as follows
View through packet capture cookies
Log in to the banking system on the page , adopt Chrome Developer tools grab packages , You can see that after the login is successful, the interface returns cookie Information
- Use rest-assured Framework implementations cookie relation
First , Use script to call login interface , And get from the returned information cookie, The code is as follows , After the method is executed, the logged in cookies Stored in code cookies In the object
secondly , Call the query balance interface , And add cookies object , In this way, the query balance interface can bring validity when requesting cookies, The code is as follows
2
be based on token Authentication Association of
Familiar with business interface
Code classmate full stack interface project is based on token Query balance interface , You must call the login interface to get token And pass it to the query balance interface , The information of the two interfaces is as follows
- Caught analysis token The generation and transmission of
Log in to the banking system on the page , adopt fiddler Tool grab bag , You can see the generated in the interface return after successful login data The message is token Value
Then let's analyze the interface for querying the balance when it is initiated token How information is transmitted , Is still fidder Tool grab bag , We can find in the request header There is a field called testfan-token, The corresponding value is returned by the login interface token value
- Use rest-assured Framework implementations token relation
First , Use script to call login interface , And get from the returned information token, The code is as follows , After the method is executed, the logged in token Values are stored in the code token variable
secondly , Call the query balance interface , And add header Information , In this way, the query balance interface can bring validity when requesting token, The code is as follows
Okay , Whether it's cookies still token, We all have in rest-assured Associated use of framework , Try it now
边栏推荐
- Embedded development: five revision control best practices
- Uncover the "intelligence tax" of mousse: spend 4billion on marketing, and only 7 invention patents
- When ABAP screen switching, refresh the previous screen
- 【Hot100】17. Letter combination of telephone number
- Microservice tracking SQL (support Gorm query tracking under isto control)
- Huawei issued hcsp-solution-5g security talent certification to help build 5g security talent ecosystem
- 【每日一题】1175. 质数排列
- MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
- 投稿开奖丨轻量应用服务器征文活动(5月)奖励公布
- Go 语言怎么使用对称加密?
猜你喜欢
[PHP graduation design] design and implementation of textbook management system based on php+mysql+apache (graduation thesis + program source code) -- textbook management system
Share the daily work and welfare of DJI (Shenzhen headquarters) in Dajiang
ADS算力芯片的多模型架构研究
DO280管理应用部署--pod调度控制
Sales management system of lightweight enterprises based on PHP
【Hot100】19. Delete the penultimate node of the linked list
idea启动Command line is too long问题处理
OJ questions related to complexity (leetcode, C language, complexity, vanishing numbers, rotating array)
[SQL statement] Why do you select two Shanghai and query different counts here? I want it to become a Shanghai, and count only displays a sum
process.env.NODE_ENV
随机推荐
IM即時通訊開發實現心跳保活遇到的問題
Smart Party Building: faith through time and space | 7.1 dedication
Factory high-precision positioning management system, digital safety production management
接口测试框架中的鉴权处理
In the era of super video, what kind of technology will become the base?
【LeetCode】43. 字符串相乘
Do280 management application deployment - pod scheduling control
大龄测试/开发程序员该何去何从?是否会被时代抛弃?
虚拟串口模拟器和串口调试助手使用教程「建议收藏」
process.env.NODE_ENV
Win11如何设置用户权限?Win11设置用户权限的方法
圈铁发音,动感与无噪强强出彩,魔浪HIFIair蓝牙耳机测评
The supply of chips has turned to excess, and the daily output of Chinese chips has increased to 1billion, which will make it more difficult for foreign chips
Automatic, intelligent and visual! Deeply convinced of the eight designs behind sslo scheme
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
Motion capture system for apple picking robot
Go 语言源码级调试器 Delve
The sharp drop in electricity consumption in Guangdong shows that the substitution of high-tech industries for high-energy consumption industries has achieved preliminary results
智慧党建: 穿越时空的信仰 | 7·1 献礼
Comment utiliser le langage MySQL pour les appareils de ligne et de ligne?