nodeSolidServer / nodeSolidServer/node-solid-server

fix: make WebID profile fetch respect NODE_TLS_REJECT_UNAUTHORIZED in tests

Đang mở
#1,843 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
JavaScript
Star
1.8k
Fork
308
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với lib/webid/lib/get.mjs và kiểm tra lời gọi fetch nội bộ của nó cũng như cách xử lý HTTPS. Sau đó chạy test/integration/acl-tls-test.mjs sau khi xóa describe.skip; được xem là hoàn tất khi các bài kiểm thử tích hợp WebID-TLS vượt qua với NODE_TLS_REJECT_UNAUTHORIZED=0, trong khi việc xác thực chứng chỉ thông thường vẫn không thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
backend, networking, testing
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
58/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.