当前位置:网站首页>Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
Interface Test Framework Practice | Process Encapsulation and Test Case Design Based on Encrypted Interface
2022-08-03 04:34:00 【CSDN】
Interface testing is not enough just to master the usage of Requests or some other powerful libraries. It also needs to have the ability to customize an interface automation testing framework according to the company's business processes and needs.Therefore, next, we mainly introduce the interface test case analysis and how the general process encapsulation is completed.
First of all, before doing the use case analysis, you can find out the quality pain points by tracing all the fault causes of the company in the past year, and locate the cause of the problem, or by conducting investigations with the CTO, product manager, R&D, operation and maintenance, and testing to obtain the quality pain points, and also analyze the business structure., process invocation, and the monitoring system to understand the usage data of the business, so as to obtain the quality requirements.
After obtaining the quality requirements, through the docking with the product manager, project manager, R&D director, etc., we can learn the business scope to be tested, business scenario use cases, and business interface analysis, so as to determine the company's test plan.Combining the test plan with the quality requirements for analysis, the design of business use cases can begin, and the analysis of interface test cases is also included.
The idea of interface encapsulation is mainly divided into three major dimensions: configuration, interface encapsulation, and business process.Of which:
- Configuration is mainly used to obtain initial configuration and dependencies from configuration files;
- Interface encapsulation follows the APIObject design pattern and abstractly encapsulates interface calls;
- The business process is responsible for data initialization and business use case design. It includes process definitions formed by multiple APIs, and does not include any interface implementation details and assertions.
The following will be combined with actual combat cases for a detailed introduction.
Due to information security reasons, many interfaces encrypt requests and responses during transmission. It is obviously not feasible to directly assert this part of the data.It is also necessary to perform additional decryption processing on this part of the interface before asserting the decrypted interface.
Before the actual combat, you need to prepare an interface to encrypt the response.After initiating a get request to it, get an encrypted response message.
First prepare a JSON format demo:
Use base64 to encrypt it to get an encrypted file demo64.txt
Use Python command to start a service in the directory where "demo64.txt" is located
StartIt will look like this: li>
If the request is successful, it means that the environment has been successfully prepared
Call base64, decrypt the returned request directly, and get the decrypted response, convert the decrypted response into JSON format, and then you canThis return value is asserted and no error is reported.
This way of writing is obviously not elegant enough. If the protocol of the tested interface changes, the Requests library cannot support the changed protocol. If you need to call another third library to send the request information, you still need to modify the underlying source code.In this case, you can add a layer of encapsulation to construct a more general sending method.
First of all, it is necessary to store all the request information through a dictionary structure, including the protocol sent, the decoding method, the request method, etc., and this dictionary structure is also ready for the subsequent data-driven transformation.important foreshadowing.
Through the schema in the structure of the request information, add judgment conditions to select different request protocols.For example, if the schema is "http", choose to call the encapsulated requests library.
Call the send method in the ApiRequest class to send the request and make an assertion
If faced with different algorithms, the underlying source code needs to be modified, so the algorithm needs to be encapsulated.Use whichever algorithm you need to use.The idea of encapsulation is the same as above.First add an encoding field to the dictionary structure to determine the different encryption conditions selected.
Or through the encoding in the structure of the request information, add judgment conditions to choose different decryption methods.
First of all, it is necessary to clarify what kind of processing method can be used in the face of an encrypted response result:
1. If you know which general encryption algorithm is used, you can solve it yourself.
2. If you don't know the corresponding encryption algorithm, you can let R&D provide the lib for encryption and decryption.
3. If it is neither a general-purpose encryption algorithm, nor a research and development lib that can provide encryption and decryption, the encryption party can provide remote parsing services, so that the algorithm is still confidential.
This article mainly talks about how to deal with such a decryption algorithm in the case of understanding the use of an encryption algorithm.But the idea of encapsulation is the same. No matter what kind of situation you are facing, you can specify the content of the data through formatted data, and encapsulate the encryption and decryption or the selected protocol through a layer of logical encapsulation.
Recommended Learning
Interface testing framework is actually used. I recommend the "Advanced Test Development Practice" course produced by Hogwarts, which is the cutting-edge practice of BAT factory, and is taught by the author of the open source project.
5-month intensive training of 20+ projects in actual combat, taught by the test master Sihan, and one-stop mastering of the core skills necessary for BAT test development engineers (compared to Ali P6+, annual salary of 50W+)!Students directly push the test managers of famous BAT companies, and the salary is generally increased by 50%+!
24 hot enrollments in progress
【Related Articles】
- Interface Test Framework Practice (1) | Requests and Interface Request Construction
- Interface Test Framework Practice (2) | Interface Request Assertion
边栏推荐
- Where is the value of testers
- js garbage collection mechanism
- Concepts and Methods of Exploratory Testing
- 【生物素叠氮化物|cas:908007-17-0】价格_厂家
- flink sql任务变更,在sql里面增加几个字段后,从以前保存的savepoint恢复启动出错。
- 链动2+1模式简单,奖励结构丰厚,自主裂变?
- ScanNet数据集讲解与点云数据下载
- 刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
- 普乐蛙VR台风体验馆厂家VR防震减灾模拟VR沉浸式体验设备
- 直播|StarRocks 技术内幕 :低基数全局字典优化
猜你喜欢
移动流量的爆发式增长,社交电商如何选择商业模式
t条件判断语句与if循环
社交电商如何做粉丝运营?云平台怎么选择商业模式?
【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
Kotlin-Flow common encapsulation class: the use of StateFlow
Dialog manager in the fourth chapter: the dialog message loop
【Harmony OS】【FAQ】Hongmeng Questions Collection 1
软件开发的最大的区别是什么?
DC-5靶场下载及渗透实战详细过程(DC靶场系列)
接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
随机推荐
刚上线就狂吸70W粉,新型商业模式“分享购”来了,你知道吗?
online test paper concept
自考六级雅思托福备战之路
Live | StarRocks technology insider: low base dictionary global optimization
3.张量运算
redis键值出现 xacxedx00x05tx00&的解决方法
常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
【精讲】利用原生js实现todolist
在线密码生成工具推荐
社交电商:流量红利已尽,裂变营销是最低成本的获客之道
常见荧光染料修饰多种基团及其激发和发射波长数据一览数据
OSI的分层特点、传输过程与三次握手、四次挥手、tcp与udp包头的描述
EssilorLuxottica借助Boomi的智能集成平台实现订单处理的现代化
Shell编程的条件语句
MCM箱模型建模方法及大气O3来源解析
【Harmony OS】【FAQ】Hongmeng Questions Collection 1
数值类型转换02
工程制图点的投影练习
Bubble sort in c language structure
The flink sql task is changed, and after adding several fields to the sql, an error occurs when restoring from the previously saved savepoint.