fix: make WebID profile fetch respect NODE_TLS_REJECT_UNAUTHORIZED in tests
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 58/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- javascript, node.js
- Domínio
- backend, networking, testing
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.
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
- Linguagem predominante
- JavaScript
- Estrelas
- 1.8k
- Forks
- 308
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
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.
Mais de nodeSolidServer/node-solid-server
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
nodeSolidServer/node-solid-server#1848 · 2 comentários · 1 reação ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
nodeSolidServer/node-solid-server#1841 · 2 comentários ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
nodeSolidServer/node-solid-server#1147 ·
-
remove bootstrap dependency Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
nodeSolidServer/node-solid-server#1867 ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 45/100
nodeSolidServer/node-solid-server#1853 ·