【问题标题】:How do I test the API using REST + CodeceptJS, access to which is protected with Auth0?如何使用 REST + CodeceptJS 测试 API,访问受 Auth0 保护?
【发布时间】:2021-12-21 07:43:34
【问题描述】:

我想使用REST helper(用于 CodeceptJS)为 API 编写自动化测试

困难在于对 API 的访问受到 OAuth2 的保护。

如果有人有通过 OAuth2 授权使用 REST + CodeceptJS 编写自动测试的经验,如果您能告诉我您的案例,我将不胜感激

【问题讨论】:

    标签: rest oauth-2.0 codeceptjs


    【解决方案1】:

    您可以使用 OAuth2 在帮助程序中添加默认标头,如下所示:

    REST: {
          endpoint: 'https://baseurl/endpoint',
          defaultHeaders:{
            Authorization: 'Bearer xxxtoken'
          },
        },
    

    【讨论】:

    • 非常感谢!你的建议有帮助!!!
    猜你喜欢
    • 1970-01-01
    • 2015-03-21
    • 1970-01-01
    • 1970-01-01
    • 2020-02-10
    • 2016-01-09
    • 2019-01-14
    • 2012-11-18
    • 1970-01-01
    相关资源
    最近更新 更多