nodeSolidServer / nodeSolidServer/node-solid-server
fix: make WebID profile fetch respect NODE_TLS_REJECT_UNAUTHORIZED in tests
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- JavaScript
- Estrelas
- 1.8k
- Forks
- 308
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece por lib/webid/lib/get.mjs e inspecione sua chamada interna a fetch e o tratamento de HTTPS. Em seguida, execute test/integration/acl-tls-test.mjs após remover seu describe.skip; considera-se concluído quando os testes de integração WebID-TLS passam com NODE_TLS_REJECT_UNAUTHORIZED=0, enquanto a validação normal de certificados permanece inalterada.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript, node.js
- Domínio
- backend, networking, testing
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 58/100