You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Ubuntu自托管Runner的Cypress容器中运行cypress-ntlm遇SSO不支持错误

解决Ubuntu容器中Cypress NTLM SSO不支持的问题

问题原因

你使用的cypress-ntlm-auth插件的ntlmSso()方法依赖Windows系统专属的SSPI(Security Support Provider Interface)接口实现单点登录,Linux平台没有该接口,因此触发SSO is not supported on this platform错误。

解决方案

放弃SSO模式,改用手动NTLM认证,直接传入认证凭据:

1. 修改测试代码

将测试文件中before all钩子的ntlmSso()调用替换为ntlm()方法,示例:

// 原报错代码
beforeAll(() => {
  cy.ntlmSso('https://your-sso-site.com');
});

// 修改后代码
beforeAll(() => {
  cy.ntlm(
    'https://your-sso-site.com',
    Cypress.env('NTLM_USER'),
    Cypress.env('NTLM_PASSWORD'),
    Cypress.env('NTLM_DOMAIN')
  );
});

2. 配置GitHub Actions注入环境变量

在GitHub Actions的run cypress步骤中,通过环境变量传递认证信息(建议用GitHub Secrets存储敏感数据):

- name: run cypress
  run: npx cypress-ntlm run --env Environment=Development,NTLM_USER=${{ secrets.NTLM_USER }},NTLM_PASSWORD=${{ secrets.NTLM_PASSWORD }},NTLM_DOMAIN=${{ secrets.NTLM_DOMAIN }}

3. 额外检查

你的自定义cypress/included容器已通过install cypress Dependencies步骤安装了基础依赖,无需额外调整系统包。


原GitHub Actions配置

jobs:
  e2e-tests:
    runs-on: self-hosted
    container:
      image: xxxx(cypress/included with my company proxy settings)
    strategy:
      matrix:
        node-version: [16.x]
    steps:

    - uses: actions/checkout@v3

    - name: setup node
      uses: actions/setup-node@v3
      with:
        node-version: ${{matrix.node-version}}

    - name: npm
      run: npm install
      
    - name: install cypress Dependencies
      run: |
        apt-get -y install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb

      
    - name: run cypress
      run: npx cypress-ntlm run --env Environment=Development

原错误输出

Site load
    1) "before all" hook for "has logo"


  0 passing (324ms)
  1 failing

  1) Site load
       "before all" hook for "has logo":
     Error: SSO is not supported on this platform. Only Windows OSs are supported.

Because this error occurred during a `before all` hook we are skipping the remaining tests in the current suite: `Site load`
      at Context.ntlmSso (webpack:///./node_modules/cypress-ntlm-auth/dist/commands/index.js:111:0)




  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        1                                                                                │
  │ Passing:      0                                                                                │
  │ Failing:      1                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      0                                                                                │
  │ Screenshots:  1                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     0 seconds                                                                        │
  │ Spec Ran:     3-impact/fist-test.cy.ts                                                         │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘

内容的提问来源于stack exchange,提问作者Harel Moshayof

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 20:57:29