Add some self-signed TSL certs to test https

This commit is contained in:
2025-06-13 22:03:11 -07:00
parent 027b8616d3
commit a14be2cbde
4 changed files with 57 additions and 14 deletions

View File

@@ -11,6 +11,13 @@ describe "test environment", ->
it "can't connect to the internet", ->
assert.has_error (-> req "http://example.org"), "Couldn't resolve host name"
describe "http://miti.sh", ->
it "redirects to https", ->
request = req "http://miti.sh"
assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "https://miti.sh/"
describe "http://webdevcat.me", ->
it "permanently redirects to http://miti.sh", ->
request = req "http://webdevcat.me"
@@ -67,42 +74,42 @@ describe "http://apps.webdevcat.me/btroops", ->
assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://apps.miti.sh/btroops"
describe "http://miti.sh", ->
describe "https://miti.sh", ->
it "sends /index.html", ->
request = req "http://miti.sh"
request = req "https://miti.sh"
assert.same request\statusCode!, 200
assert.same request\statusMessage!, "OK"
assert.same request\body!\match("<title>(.*)</title>"), index_title
describe "http://miti.sh/index", ->
describe "https://miti.sh/index", ->
it "sends /index.html", ->
request = req "http://miti.sh/index"
request = req "https://miti.sh/index"
assert.same request\statusCode!, 200
assert.same request\statusMessage!, "OK"
assert.same request\body!\match("<title>(.*)</title>"), index_title
describe "http://miti.sh/index.html", ->
describe "https://miti.sh/index.html", ->
it "sends /index.html", ->
request = req "http://miti.sh/index.html"
request = req "https://miti.sh/index.html"
assert.same request\statusCode!, 200
assert.same request\statusMessage!, "OK"
assert.same request\body!\match("<title>(.*)</title>"), index_title
describe "http://miti.sh/posts/", ->
describe "https://miti.sh/posts/", ->
it "permanently redirects to http://miti.sh/posts", ->
request = req "http://miti.sh/posts/"
request = req "https://miti.sh/posts/"
assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://miti.sh/posts"
assert.same request\header!.Location, "https://miti.sh/posts"
describe "http://miti.sh/posts", ->
describe "https://miti.sh/posts", ->
it "sends /posts/index.html", ->
request = req "http://miti.sh/posts"
request = req "https://miti.sh/posts"
assert.same request\statusCode!, 200
assert.same request\statusMessage!, "OK"
assert.same request\body!\match("<title>(.*)</title>"), "miti.sh · Posts"
describe "http://git.miti.sh", ->
describe "https://git.miti.sh", ->
it "reverse-proxies request to a gitea unix socket", ->
Path = require "sitegen.path"
socket_fname = "unixstreamsrvr.moon"
@@ -117,7 +124,7 @@ describe "http://git.miti.sh", ->
result = Path.read_exec "find", socket_dir, "-type", "s", "-ls"
assert.truthy result\match "nobody%s+root.+" .. Path.join(socket_dir, "gitea.socket")
req "http://git.miti.sh"
req "https://git.miti.sh"
reqheader = with server\read "*a"
server\close!