【问题标题】:Mock Session in Spring Boot and RestAssuredSpring Boot 和 RestAssured 中的模拟会话
【发布时间】:2016-06-29 07:52:58
【问题描述】:

我有一个使用 Spring Boot 运行的 Web 应用程序。现在我必须用 Rest Assured 编写测试。 但是,为了运行其中一些,我必须在服务器上进行身份验证。服务器使用 google oauth 身份验证。有什么办法可以放心地模拟会话吗? 文档并没有对此进行太多说明,并且其中涵盖​​的方法也无济于事。

when()
      .sessionId("id here")

在服务器端,我使用的是带有 userId 参数的 HttpSession。

【问题讨论】:

  • 你可以使用restito来模拟认证服务器。

标签: spring authentication testing mocking rest-assured


【解决方案1】:

我找到了解决办法。 RestAssured(自 3.0.0 起)与 MockMvc 集成,可以通过调用类似的方法来实现会话模拟

given().sessionAttr("name", value)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-01
    • 1970-01-01
    • 2019-11-19
    • 2022-10-13
    • 2017-07-29
    • 2017-06-12
    • 2017-07-30
    • 1970-01-01
    相关资源
    最近更新 更多