Add tests for nginx.conf directives #1

Merged
ccm merged 26 commits from ccm-test-nginx-directives into trunk 2025-06-14 21:54:22 +00:00
2 changed files with 59 additions and 38 deletions
Showing only changes of commit 943ca92c32 - Show all commits

View File

@ -79,33 +79,54 @@ http {
} }
server { server {
# listen 443 ssl; listen 443 ssl;
server_name webdevcat.me; server_name webdevcat.me;
include mime.types; include mime.types;
charset utf-8; charset utf-8;
default_type text/html; default_type text/html;
ssl_certificate /var/www/certs/webdevcat.me/fullchain.pem;
ssl_certificate_key /var/www/certs/webdevcat.me/privkey.pem;
location / { location / {
return 301 http://miti.sh$request_uri; return 301 https://miti.sh$request_uri;
} }
location ~ ^/git/?(.*)$ { location ~ ^/git/?(.*)$ {
return 301 http://git.miti.sh/ccm/$1; return 301 https://git.miti.sh/ccm/$1;
} }
location ~ ^/apps/(.*)$ { location ~ ^/apps/(.*)$ {
return 301 http://apps.miti.sh/$1; return 301 https://apps.miti.sh/$1;
} }
} }
server { server {
listen 443 ssl;
server_name git.webdevcat.me; server_name git.webdevcat.me;
return 301 http://git.miti.sh$request_uri;
ssl_certificate /var/www/certs/webdevcat.me/fullchain.pem;
ssl_certificate_key /var/www/certs/webdevcat.me/privkey.pem;
location ^~ /.well-known/acme-challenge {
alias /var/www/dehydrated;
}
return 301 https://git.miti.sh$request_uri;
} }
server { server {
listen 443 ssl;
server_name apps.webdevcat.me; server_name apps.webdevcat.me;
return 301 http://apps.miti.sh$request_uri;
ssl_certificate /var/www/certs/webdevcat.me/fullchain.pem;
ssl_certificate_key /var/www/certs/webdevcat.me/privkey.pem;
location ^~ /.well-known/acme-challenge {
alias /var/www/dehydrated;
}
return 301 https://apps.miti.sh$request_uri;
} }
} }

View File

@ -18,61 +18,61 @@ describe "http://miti.sh", ->
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "https://miti.sh/" assert.same request\header!.Location, "https://miti.sh/"
describe "http://webdevcat.me", -> describe "https://webdevcat.me", ->
it "permanently redirects to http://miti.sh", -> it "permanently redirects to https://miti.sh", ->
request = req "http://webdevcat.me" request = req "https://webdevcat.me"
assert.same request\statusCode!, 301 assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://miti.sh/" assert.same request\header!.Location, "https://miti.sh/"
describe "http://webdevcat.me/git", -> describe "https://webdevcat.me/git", ->
it "permanently redirects to http://git.miti.sh/ccm/", -> it "permanently redirects to https://git.miti.sh/ccm/", ->
request = req "http://webdevcat.me/git" request = req "https://webdevcat.me/git"
assert.same request\statusCode!, 301 assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://git.miti.sh/ccm/" assert.same request\header!.Location, "https://git.miti.sh/ccm/"
describe "http://webdevcat.me/git/", -> describe "https://webdevcat.me/git/", ->
it "permanently redirects to http://git.miti.sh", -> it "permanently redirects to https://git.miti.sh", ->
request = req "http://webdevcat.me/git" request = req "https://webdevcat.me/git"
assert.same request\statusCode!, 301 assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://git.miti.sh/ccm/" assert.same request\header!.Location, "https://git.miti.sh/ccm/"
describe "http://webdevcat.me/git/pandoc", -> describe "https://webdevcat.me/git/pandoc", ->
it "permanently redirects to http://git.miti.sh/ccm/pandoc", -> it "permanently redirects to https://git.miti.sh/ccm/pandoc", ->
request = req "http://webdevcat.me/git/pandoc" request = req "https://webdevcat.me/git/pandoc"
assert.same request\statusCode!, 301 assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://git.miti.sh/ccm/pandoc" assert.same request\header!.Location, "https://git.miti.sh/ccm/pandoc"
describe "http://git.webdevcat.me", -> describe "https://git.webdevcat.me", ->
it "permanently redirects to http://git.miti.sh/", -> it "permanently redirects to https://git.miti.sh/", ->
request = req "http://git.webdevcat.me" request = req "https://git.webdevcat.me"
assert.same request\statusCode!, 301 assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://git.miti.sh/" assert.same request\header!.Location, "https://git.miti.sh/"
describe "http://webdevcat.me/apps/btroops", -> describe "https://webdevcat.me/apps/btroops", ->
it "permanently redirects to http://apps.miti.sh/btroops", -> it "permanently redirects to https://apps.miti.sh/btroops", ->
request = req "http://webdevcat.me/apps/btroops" request = req "https://webdevcat.me/apps/btroops"
assert.same request\statusCode!, 301 assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://apps.miti.sh/btroops" assert.same request\header!.Location, "https://apps.miti.sh/btroops"
describe "http://apps.webdevcat.me", -> describe "https://apps.webdevcat.me", ->
it "permanently redirects to http://apps.miti.sh/", -> it "permanently redirects to https://apps.miti.sh/", ->
request = req "http://apps.webdevcat.me" request = req "https://apps.webdevcat.me"
assert.same request\statusCode!, 301 assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://apps.miti.sh/" assert.same request\header!.Location, "https://apps.miti.sh/"
describe "http://apps.webdevcat.me/btroops", -> describe "https://apps.webdevcat.me/btroops", ->
it "permanently redirects to http://apps.miti.sh/btroops", -> it "permanently redirects to https://apps.miti.sh/btroops", ->
request = req "http://apps.webdevcat.me/btroops" request = req "https://apps.webdevcat.me/btroops"
assert.same request\statusCode!, 301 assert.same request\statusCode!, 301
assert.same request\statusMessage!, "Moved Permanently" assert.same request\statusMessage!, "Moved Permanently"
assert.same request\header!.Location, "http://apps.miti.sh/btroops" assert.same request\header!.Location, "https://apps.miti.sh/btroops"
describe "https://miti.sh", -> describe "https://miti.sh", ->
it "sends /index.html", -> it "sends /index.html", ->