jasmine / jasmine-browser-runner

Serve and run your Jasmine specs in a browser
50 stars 25 forks source link

Add TLS and hostname support #49

Closed joeyparrish closed 8 months ago

joeyparrish commented 8 months ago

This adds both TLS and hostname support.

TLS support is activated by specifying paths to a key and a cert. There are caveats about self-signed certs in the README.

This also adds hostname support. This impacts both the URL sent to browsers and the IP the server socket listens to. There are caveats about valid names, valid IPs, and HSTS preload in the README. HSTS-type errors in both Chrome and Firefox are detected automatically and translated into friendlier errors with a short link to the documentation.

Closes #42 Replaces PR #43 One part of solving shaka-project/shaka-player#5547

joeyparrish commented 8 months ago

Checking the Windows test failure against our Windows lab machine.

joeyparrish commented 8 months ago

I get a different failure on our Windows machine:

Failures:
1) server starting the server starts a server with the specified hostname
  Message:
    TypeError: Invalid URL
  Stack:
    error properties: Object({ code: 'ERR_INVALID_URL', input: 'http://2401:fa00:480:2207:464d:7a11:92b1:129:64237/__jasmine__/jazz.js' })

On CircleCI, we get:

1) server When an importMap is provided includes an import map with both imports and scopes
  Message:
    Error: connect ECONNREFUSED ::1:63613

And similar on several tests.

I think CircleCI's Windows box only has a localhost interface, and localhost resolves to ::1 instead of 127.0.0.1. I'll see if I can simulate that in a more comfortable local Linux environment. I can't connect to a remote Windows machine if it only has localhost. 😁

The failure I get on my own Windows box seems to be an issue with my getIP() method choosing IPv6. I think the URL formatting is wrong in that case.

joeyparrish commented 8 months ago

Forcing localhost to IPv6 in /etc/hosts on Linux reproduces the failures I get in CircleCI on Windows:

::1 localhost
# 127.0.0.1 localhost
joeyparrish commented 8 months ago

Ah, the problem with IPv6 for localhost is my defaults for hostname. Using "0.0.0.0" for the listening address doesn't mean "all IPs from all interfaces", it means "all IPs from IPv4 interfaces only". Easy to fix.

joeyparrish commented 8 months ago

Tests passing on all platforms, with IPv4 and IPv6. Please take a look!

sgravrock commented 8 months ago

Thanks for the PR. This looks solid at first glance. I'll review it in more detail soon.

joeyparrish commented 8 months ago

Thanks!