fix: make WebID profile fetch respect NODE_TLS_REJECT_UNAUTHORIZED in tests
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
- Ambito
- backend, networking, testing
Direzione di ricerca
Inizia da lib/webid/lib/get.mjs e analizza la sua chiamata interna a fetch e la gestione di HTTPS. Esegui quindi test/integration/acl-tls-test.mjs dopo aver rimosso il relativo describe.skip; il lavoro è completato quando i test di integrazione WebID-TLS passano con NODE_TLS_REJECT_UNAUTHORIZED=0, mentre la normale convalida dei certificati rimane invariata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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_UNAUTHORIZEDis 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
- Lingua principale
- JavaScript
- Stelle
- 1.8k
- Fork
- 308
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nodeSolidServer/node-solid-server
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
nodeSolidServer/node-solid-server#1848 · 2 commenti · 1 reazione ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
nodeSolidServer/node-solid-server#1841 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
nodeSolidServer/node-solid-server#1147 ·
-
remove bootstrap dependency Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
nodeSolidServer/node-solid-server#1867 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
nodeSolidServer/node-solid-server#1853 ·
Tutte le issue di nodeSolidServer/node-solid-server
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Seeed-Studio/wiki-documents#5655 · 2 commenti ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
capricorn86/happy-dom#2435 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Edit: CW+ Apertachannels:edit check:passed
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
01 type: bug 30 needs: triage 99 tag: UX Accessibility
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100