Don't publish any ports from the test container
This allows us to make test requests to port 80, like in production
This commit is contained in:
parent
9f019dbac5
commit
831a86c738
@ -7,8 +7,7 @@ events {
|
|||||||
|
|
||||||
http {
|
http {
|
||||||
server {
|
server {
|
||||||
# listen 80;
|
listen 80;
|
||||||
listen 8080;
|
|
||||||
# listen 443 ssl;
|
# listen 443 ssl;
|
||||||
|
|
||||||
include mime.types;
|
include mime.types;
|
||||||
@ -34,7 +33,6 @@ http {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 8080;
|
|
||||||
# listen 443 ssl;
|
# listen 443 ssl;
|
||||||
server_name webdevcat.me;
|
server_name webdevcat.me;
|
||||||
|
|
||||||
@ -43,7 +41,7 @@ http {
|
|||||||
default_type text/html;
|
default_type text/html;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
return 301 http://miti.sh:8080$request_uri;
|
return 301 http://miti.sh$request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ ^/git/(.*)$ {
|
location ~ ^/git/(.*)$ {
|
||||||
|
@ -1,31 +1,50 @@
|
|||||||
http = require "luajit-curl-helper.http"
|
http = require "luajit-curl-helper.http"
|
||||||
|
|
||||||
describe "routes", ->
|
index_title = "miti.sh · Catalin Constantin Mititiuc"
|
||||||
it "loads miti.sh", ->
|
|
||||||
request = http.init "http://miti.sh:8080"
|
req = (url) ->
|
||||||
|
request = http.init url
|
||||||
st = request\perform!
|
st = request\perform!
|
||||||
|
|
||||||
error request\lastError! if not st
|
error request\lastError! if not st
|
||||||
|
request
|
||||||
|
|
||||||
status_code = request\statusCode!
|
describe "http://webdevcat.me", ->
|
||||||
status_message = request\statusMessage!
|
it "permanently redirects to http://miti.sh", ->
|
||||||
|
request = req "http://webdevcat.me"
|
||||||
|
assert.same request\statusCode!, 301
|
||||||
|
assert.same request\statusMessage!, "Moved Permanently"
|
||||||
|
assert.same request\header!.Location, "http://miti.sh/"
|
||||||
|
|
||||||
assert.same status_code, 200
|
describe "http://webdevcat.me/git", ->
|
||||||
assert.same status_message, "OK"
|
it "permanently redirects to http://git.miti.sh", ->
|
||||||
|
request = req "http://webdevcat.me/git"
|
||||||
|
assert.same request\header!.Location, "http://git.miti.sh/"
|
||||||
|
|
||||||
it "redirects webdevcat.me to miti.sh", ->
|
describe "http://webdevcat.me/git/", ->
|
||||||
request = http.init "http://webdevcat.me:8080"
|
it "permanently redirects to http://git.miti.sh", ->
|
||||||
st = request\perform!
|
request = req "http://webdevcat.me/git"
|
||||||
|
assert.same request\header!.Location, "http://git.miti.sh/"
|
||||||
|
|
||||||
error request\lastError! if not st
|
describe "http://webdevcat.me/git/pandoc/", ->
|
||||||
|
pending "permanently redirects to http://git.miti.sh/ccm/pandoc"
|
||||||
|
|
||||||
status_code = request\statusCode!
|
describe "http://miti.sh", ->
|
||||||
status_message = request\statusMessage!
|
it "sends /index.html", ->
|
||||||
header = request\header!
|
request = req "http://miti.sh"
|
||||||
|
assert.same request\statusCode!, 200
|
||||||
|
assert.same request\statusMessage!, "OK"
|
||||||
|
assert.same request\body!\match("<title>(.*)</title>"), index_title
|
||||||
|
|
||||||
assert.same status_code, 301
|
describe "http://miti.sh/index", ->
|
||||||
assert.same status_message, "Moved Permanently"
|
it "sends /index.html", ->
|
||||||
assert.same header.Location, "http://miti.sh:8080/"
|
request = req "http://miti.sh/index"
|
||||||
|
assert.same request\statusCode!, 200
|
||||||
|
assert.same request\statusMessage!, "OK"
|
||||||
|
assert.same request\body!\match("<title>(.*)</title>"), index_title
|
||||||
|
|
||||||
-- body = request\body!
|
describe "http://miti.sh/index.html", ->
|
||||||
-- print "body", body
|
it "sends /index.html", ->
|
||||||
|
request = req "http://miti.sh/index.html"
|
||||||
|
assert.same request\statusCode!, 200
|
||||||
|
assert.same request\statusMessage!, "OK"
|
||||||
|
assert.same request\body!\match("<title>(.*)</title>"), index_title
|
||||||
|
5
test.sh
5
test.sh
@ -5,16 +5,13 @@
|
|||||||
image=miti.sh
|
image=miti.sh
|
||||||
|
|
||||||
echo "Starting test container..."
|
echo "Starting test container..."
|
||||||
container_id=$(docker run --rm -d -v $(pwd):/opt/app -p 8080:8080 \
|
container_id=$(docker run --rm -d -v $(pwd):/opt/app \
|
||||||
--add-host=miti.sh=127.0.0.1 \
|
--add-host=miti.sh=127.0.0.1 \
|
||||||
--add-host=webdevcat.me=127.0.0.1 \
|
--add-host=webdevcat.me=127.0.0.1 \
|
||||||
$image)
|
$image)
|
||||||
|
|
||||||
echo "Test container started"
|
echo "Test container started"
|
||||||
|
|
||||||
# docker exec -t $container_id curl http://miti.sh:8080
|
|
||||||
# docker exec -t $container_id curl -v http://webdevcat.me:8080
|
|
||||||
|
|
||||||
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