smd*_*smd 4 reactjs identityserver4 cypress
我们有一个由单独的 Identity Server 站点保护的 React 应用程序。如果未经身份验证,用户将被重定向到 Identity Server 中的登录页面,然后在成功登录后,他们将被重定向到 React 应用程序中的回调 URL。
我试图尽可能地自动化这个过程,以提高我们 Cypress.io 测试的速度和可靠性,这样我们就不需要每次都通过 UI 登录——允许测试是原子的,没有不必要的复杂性.
实现这一目标的最佳方法是什么?
我遵循了 Cypress 团队提供的有关登录的示例,但未能使其接近最佳状态: https //github.com/cypress-io/cypress-example-recipes/tree/master/examples /登录__单点登录
到目前为止,我最接近的是遵循这篇 Auth0 文章,但没有填充 id_token、nonce 和 state 值以传递给回调 URL: https用 cypress-and-auth0/ 进行测试
任何方向都非常感谢。
我能够通过点击/connect/token身份服务器的端点来解决这个问题:
POST /connect/token
client_id=client1&
client_secret=secret&
grant_type=password&
username=username&
password=password&
scope=openid profile <client_scope>
Run Code Online (Sandbox Code Playgroud)
然后使用响应将项目添加到会话存储中:
window.sessionStorage.setItem("oidc:<auth_url>:<client_id>", JSON.stringify(response));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1101 次 |
| 最近记录: |