nodeSolidServer / nodeSolidServer/node-solid-server

fix: make WebID profile fetch respect NODE_TLS_REJECT_UNAUTHORIZED in tests

Aperta
#1,843 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
JavaScript
Stelle
1.8k
Fork
308
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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_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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

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.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
backend, networking, testing
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
58/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.