nodeSolidServer / nodeSolidServer/node-solid-server

fix: make WebID profile fetch respect NODE_TLS_REJECT_UNAUTHORIZED in tests

Ouverte
#1,843 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
JavaScript
Étoiles
1.8k
Forks
308
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par lib/webid/lib/get.mjs et examinez son appel interne à fetch ainsi que la gestion de HTTPS. Exécutez ensuite test/integration/acl-tls-test.mjs après avoir supprimé son describe.skip ; le travail est terminé lorsque les tests d’intégration WebID-TLS réussissent avec NODE_TLS_REJECT_UNAUTHORIZED=0, tandis que la validation normale des certificats reste inchangée.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, node.js
Domaine
backend, networking, testing
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
58/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.