nodeSolidServer / nodeSolidServer/node-solid-server

fix: make WebID profile fetch respect NODE_TLS_REJECT_UNAUTHORIZED in tests

未關閉
#1,843 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
JavaScript
星號
1.8k
分支
308
PR 合併指標
30 天內沒有已合併 PR

描述

Problem

The WebID-TLS integration tests timeout because the internal fetch() in lib/webid/lib/get.mjs doesn't respect NODE_TLS_REJECT_UNAUTHORIZED=0.

When verifying a WebID certificate, the server fetches the user's profile (e.g., https://tim.localhost:7777/profile/card#me). In tests, this URL uses a self-signed certificate that the internal fetch rejects.

Simplest Fix (~5 lines)

Modify lib/webid/lib/get.mjs to use an HTTPS agent that respects the environment variable:

import fetch from 'node-fetch'
import https from 'https'
import { URL } from 'url'

// Respect NODE_TLS_REJECT_UNAUTHORIZED for testing with self-signed certs
const agent = process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0'
  ? new https.Agent({ rejectUnauthorized: false })
  : undefined

export default function get (webid, callback) {
  // ... existing code ...
  fetch(uri.href, { method: 'GET', headers, agent })
  // ...
}

Why This Works

  • In production: NODE_TLS_REJECT_UNAUTHORIZED is not set, so normal cert validation applies
  • In tests: The env var is already set by the test runner (cross-env NODE_TLS_REJECT_UNAUTHORIZED=0)
  • No changes needed to test infrastructure or certificates

After This Fix

Remove describe.skip from test/integration/acl-tls-test.mjs and the tests should pass.

Related

  • #1841 - Original tracking issue
  • #1842 - Documentation PR explaining the issue

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 lib/webid/lib/get.mjs 開始,檢查其中的內部 fetch 呼叫和 HTTPS 處理。接著移除其 describe.skip 並執行 test/integration/acl-tls-test.mjs;當 WebID-TLS 整合測試在 NODE_TLS_REJECT_UNAUTHORIZED=0 下通過,同時正常的憑證驗證維持不變時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript, node.js
領域
backend, networking, testing
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
58/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。