【发布时间】:2017-11-23 02:06:47
【问题描述】:
什么是 websocket 的 MockHttpServletRequestBuilder 等价物。即在我想测试 Websockets 的情况下,我想测试一个长时间运行的 websocket 应用程序并避免 SecurityContextPersistenceFilter 在应该进行升级的第一个 http get 调用之后覆盖 SecurityContex 的情况。对于普通的 rest http 应用程序,到目前为止,这是通过利用 SecurityMockMvcRequestPostProcessors 完成的。 这里的例子using the SecurityMockMvcRequestPostProcessors
但是当我想测试一个长时间运行的 websocket 应用程序时该怎么办。即我想为 websockets 创建类似 MockHttpServletRequestBuilder 的东西。春天有这样的东西吗?或者有没有办法为此目的使用 MockHttpServletRequestBuilder ? IE。目标是创建websocket端点,避免升级后SecurityContex被清空的情况。
我找到了一些替代方法,例如按照here 的描述传递会话,但这对我来说并不是真正的替代方法,因为使用方法级别安全性的代码不起作用,因为 SecurityContex 正在被更改。
【问题讨论】:
标签: spring spring-mvc spring-boot junit spring-security