[论文解读] Morest: Model-based RESTful API Testing with Execution Feedback
Morest 是一种基于模型的 RESTful API 黑盒测试技术,通过构建并动态更新 RESTful 服务属性图(RPG)来指导测试生成。通过将执行反馈整合到 RPG 中,Morest 改进了调用序列的生成,相比最先进的方法,实现了 152.66%–232.45% 更多的 API 操作、26.16%–103.24% 更高的代码覆盖率,以及 40.64%–215.94% 更多的错误检测。
RESTful APIs are arguably the most popular endpoints for accessing Web services. Blackbox testing is one of the emerging techniques for ensuring the reliability of RESTful APIs. The major challenge in testing RESTful APIs is the need for correct sequences of API operation calls for in-depth testing. To build meaningful operation call sequences, researchers have proposed techniques to learn and utilize the API dependencies based on OpenAPI specifications. However, these techniques either lack the overall awareness of how all the APIs are connected or the flexibility of adaptively fixing the learned knowledge. In this paper, we propose Morest, a model-based RESTful API testing technique that builds and maintains a dynamically updating RESTful-service Property Graph (RPG) to model the behaviors of RESTful-services and guide the call sequence generation. We empirically evaluated Morest and the results demonstrate that Morest can successfully request an average of 152.66%-232.45% more API operations, cover 26.16%-103.24% more lines of code, and detect 40.64%-215.94% more bugs than state-of-the-art techniques. In total, we applied Morest to 6 real-world projects and found 44 bugs (13 of them cannot be detected by existing approaches). Specifically, 2 of the confirmed bugs are from Bitbucket, a famous code management service with more than 6 million users.
研究动机与目标
- 解决在 RESTful 服务的黑盒测试中生成正确且有意义的 API 调用序列的挑战。
- 通过支持动态模型精炼,克服现有方法的局限性,例如缺乏全局依赖意识(Restler)或过度依赖静态规范(Resttestgen)。
- 通过结合高层次的模型指导与实际 API 执行的自适应反馈,提升测试的有效性。
- 在真实世界的 RESTful 服务中实现更全面的代码覆盖率和更高的错误检测率。
- 在无需源代码或代码插桩的情况下,支持实际且可扩展的生产级 Web 服务测试。
提出的方法
- Morest 从 OpenAPI 规范构建 RESTful 服务属性图(RPG),编码了模式和操作级别的依赖关系。
- RPG 将 API 操作表示为节点,其依赖关系(如生产者-消费者)表示为边,从而支持结构化的调用序列生成。
- Morest 使用 RPG 上的图遍历技术生成有效且语义正确的 API 调用序列。
- 通过实际 API 调用的执行反馈,在测试过程中动态地精炼和更新 RPG,纠正来自不完整或错误规范的不准确性。
- 该技术整合反馈以优先处理和自适应调整测试生成,随着时间推移提升覆盖率和故障检测能力。
- Morest 将基于模型的指导与反馈驱动的适应性相结合,实现了自顶向下结构与自底向上灵活性之间的平衡。
实验结果
研究问题
- RQ1与静态或纯启发式方法相比,动态更新的模型是否能提升黑盒 RESTful API 测试的有效性?
- RQ2执行反馈在多大程度上能精炼模型,以纠正 OpenAPI 规范中的不准确性?
- RQ3在 API 操作覆盖率和故障检测方面,Morest 的方法与最先进的技术相比如何?
- RQ4Morest 是否能检测到现有工具遗漏的错误,特别是在真实世界的生产服务中?
- RQ5将反馈集成到属性图模型中是否能带来更高效和更有效的测试生成?
主要发现
- 与最先进的技术相比,Morest 平均实现了 152.66%–232.45% 更多的 API 操作调用。
- 在所评估的服务中,其代码覆盖率比现有方法高出 26.16%–103.24%。
- Morest 比基线工具多检测出 40.64%–215.94% 的错误,包括 13 个此前未被发现的错误。
- 在 6 个真实项目中总共发现了 44 个错误,其中包括在广泛使用的代码管理服务 Bitbucket 中确认的 2 个关键错误。
- 动态反馈机制显著提升了模型的准确性和测试的有效性,尤其是在 OpenAPI 规范编写质量较差的服务中表现尤为突出。
- Morest 通过结合高层次指导与执行结果的自适应学习,优于 Restler(自底向上)和 Resttestgen(自顶向下)两种方法。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。