Add tests for nginx.conf directives #1
@ -32,6 +32,21 @@ http {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
server_name git.miti.sh;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
client_max_body_size 1024M;
|
||||||
|
proxy_pass http://localhost:3000;
|
||||||
|
proxy_set_header Connection $http_connection;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
server_name apps.miti.sh;
|
server_name apps.miti.sh;
|
||||||
root /var/www/sites/apps.miti.sh;
|
root /var/www/sites/apps.miti.sh;
|
||||||
@ -57,4 +72,14 @@ http {
|
|||||||
return 301 http://apps.miti.sh/$1;
|
return 301 http://apps.miti.sh/$1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
server_name git.webdevcat.me;
|
||||||
|
return 301 http://git.miti.sh$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
server_name apps.webdevcat.me;
|
||||||
|
return 301 http://apps.miti.sh$request_uri;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,7 @@ req = (url) ->
|
|||||||
|
|
||||||
describe "test environment", ->
|
describe "test environment", ->
|
||||||
it "can't connect to the internet", ->
|
it "can't connect to the internet", ->
|
||||||
request = http.init "http://example.org"
|
assert.has_error (-> req "http://example.org"), "Couldn't resolve host name"
|
||||||
assert.not_true request\perform!
|
|
||||||
assert.same request\lastError!, "Couldn't resolve host name"
|
|
||||||
|
|
||||||
describe "http://webdevcat.me", ->
|
describe "http://webdevcat.me", ->
|
||||||
it "permanently redirects to http://miti.sh", ->
|
it "permanently redirects to http://miti.sh", ->
|
||||||
@ -24,21 +22,50 @@ describe "http://webdevcat.me", ->
|
|||||||
describe "http://webdevcat.me/git", ->
|
describe "http://webdevcat.me/git", ->
|
||||||
it "permanently redirects to http://git.miti.sh/ccm/", ->
|
it "permanently redirects to http://git.miti.sh/ccm/", ->
|
||||||
request = req "http://webdevcat.me/git"
|
request = req "http://webdevcat.me/git"
|
||||||
|
assert.same request\statusCode!, 301
|
||||||
|
assert.same request\statusMessage!, "Moved Permanently"
|
||||||
assert.same request\header!.Location, "http://git.miti.sh/ccm/"
|
assert.same request\header!.Location, "http://git.miti.sh/ccm/"
|
||||||
|
|
||||||
describe "http://webdevcat.me/git/", ->
|
describe "http://webdevcat.me/git/", ->
|
||||||
it "permanently redirects to http://git.miti.sh", ->
|
it "permanently redirects to http://git.miti.sh", ->
|
||||||
request = req "http://webdevcat.me/git"
|
request = req "http://webdevcat.me/git"
|
||||||
|
assert.same request\statusCode!, 301
|
||||||
|
assert.same request\statusMessage!, "Moved Permanently"
|
||||||
assert.same request\header!.Location, "http://git.miti.sh/ccm/"
|
assert.same request\header!.Location, "http://git.miti.sh/ccm/"
|
||||||
|
|
||||||
describe "http://webdevcat.me/git/pandoc", ->
|
describe "http://webdevcat.me/git/pandoc", ->
|
||||||
it "permanently redirects to http://git.miti.sh/ccm/pandoc", ->
|
it "permanently redirects to http://git.miti.sh/ccm/pandoc", ->
|
||||||
request = req "http://webdevcat.me/git/pandoc"
|
request = req "http://webdevcat.me/git/pandoc"
|
||||||
|
assert.same request\statusCode!, 301
|
||||||
|
assert.same request\statusMessage!, "Moved Permanently"
|
||||||
assert.same request\header!.Location, "http://git.miti.sh/ccm/pandoc"
|
assert.same request\header!.Location, "http://git.miti.sh/ccm/pandoc"
|
||||||
|
|
||||||
|
describe "http://git.webdevcat.me", ->
|
||||||
|
it "permanently redirects to http://git.miti.sh/", ->
|
||||||
|
request = req "http://git.webdevcat.me"
|
||||||
|
assert.same request\statusCode!, 301
|
||||||
|
assert.same request\statusMessage!, "Moved Permanently"
|
||||||
|
assert.same request\header!.Location, "http://git.miti.sh/"
|
||||||
|
|
||||||
describe "http://webdevcat.me/apps/btroops", ->
|
describe "http://webdevcat.me/apps/btroops", ->
|
||||||
it "permanently redirects to http://apps.miti.sh/btroops", ->
|
it "permanently redirects to http://apps.miti.sh/btroops", ->
|
||||||
request = req "http://webdevcat.me/apps/btroops"
|
request = req "http://webdevcat.me/apps/btroops"
|
||||||
|
assert.same request\statusCode!, 301
|
||||||
|
assert.same request\statusMessage!, "Moved Permanently"
|
||||||
|
assert.same request\header!.Location, "http://apps.miti.sh/btroops"
|
||||||
|
|
||||||
|
describe "http://apps.webdevcat.me", ->
|
||||||
|
it "permanently redirects to http://apps.miti.sh/", ->
|
||||||
|
request = req "http://apps.webdevcat.me"
|
||||||
|
assert.same request\statusCode!, 301
|
||||||
|
assert.same request\statusMessage!, "Moved Permanently"
|
||||||
|
assert.same request\header!.Location, "http://apps.miti.sh/"
|
||||||
|
|
||||||
|
describe "http://apps.webdevcat.me/btroops", ->
|
||||||
|
it "permanently redirects to http://apps.miti.sh/btroops", ->
|
||||||
|
request = req "http://apps.webdevcat.me/btroops"
|
||||||
|
assert.same request\statusCode!, 301
|
||||||
|
assert.same request\statusMessage!, "Moved Permanently"
|
||||||
assert.same request\header!.Location, "http://apps.miti.sh/btroops"
|
assert.same request\header!.Location, "http://apps.miti.sh/btroops"
|
||||||
|
|
||||||
describe "http://miti.sh", ->
|
describe "http://miti.sh", ->
|
||||||
@ -76,6 +103,14 @@ describe "http://miti.sh/posts", ->
|
|||||||
assert.same request\statusMessage!, "OK"
|
assert.same request\statusMessage!, "OK"
|
||||||
assert.same request\body!\match("<title>(.*)</title>"), "miti.sh · Posts"
|
assert.same request\body!\match("<title>(.*)</title>"), "miti.sh · Posts"
|
||||||
|
|
||||||
|
describe "http://git.miti.sh", ->
|
||||||
|
it "doesn't find it?", ->
|
||||||
|
request = req "http://git.miti.sh"
|
||||||
|
require("moon").p request\body!
|
||||||
|
require("moon").p request\header!
|
||||||
|
-- assert.same request\statusCode!, 404
|
||||||
|
-- assert.same request\statusMessage!, "Not Found"
|
||||||
|
|
||||||
describe "http://apps.miti.sh", ->
|
describe "http://apps.miti.sh", ->
|
||||||
it "doesn't find it", ->
|
it "doesn't find it", ->
|
||||||
request = req "http://apps.miti.sh"
|
request = req "http://apps.miti.sh"
|
||||||
|
5
test.sh
5
test.sh
@ -11,11 +11,16 @@ echo "Starting test container..."
|
|||||||
container_id=$(docker run --rm -d -v $(pwd):/opt/app --network no-internet \
|
container_id=$(docker run --rm -d -v $(pwd):/opt/app --network no-internet \
|
||||||
--add-host=miti.sh=127.0.0.1 \
|
--add-host=miti.sh=127.0.0.1 \
|
||||||
--add-host=apps.miti.sh=127.0.0.1 \
|
--add-host=apps.miti.sh=127.0.0.1 \
|
||||||
|
--add-host=git.miti.sh=127.0.0.1 \
|
||||||
--add-host=webdevcat.me=127.0.0.1 \
|
--add-host=webdevcat.me=127.0.0.1 \
|
||||||
|
--add-host=apps.webdevcat.me=127.0.0.1 \
|
||||||
|
--add-host=git.webdevcat.me=127.0.0.1 \
|
||||||
$image)
|
$image)
|
||||||
|
|
||||||
echo "Test container started"
|
echo "Test container started"
|
||||||
|
|
||||||
|
# docker exec -t $container_id cat /etc/hosts
|
||||||
|
# docker exec -t $container_id cat /opt/app/logs/error.log
|
||||||
docker exec -t $container_id busted
|
docker exec -t $container_id busted
|
||||||
|
|
||||||
# echo "redirects webdevcat.me to miti.sh"
|
# echo "redirects webdevcat.me to miti.sh"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user