Fix test env having access to internet; add apps.miti.sh server to conf

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-11 13:15:50 -07:00
parent 54052e3890
commit dc8fb2f1f2
3 changed files with 22 additions and 1 deletions

View File

@ -32,6 +32,11 @@ http {
} }
} }
server {
server_name apps.miti.sh;
root /var/www/sites/apps.miti.sh;
}
server { server {
# listen 443 ssl; # listen 443 ssl;
server_name webdevcat.me; server_name webdevcat.me;

View File

@ -8,6 +8,12 @@ req = (url) ->
error request\lastError! if not st error request\lastError! if not st
request request
describe "test environment", ->
it "can't connect to the internet", ->
request = http.init "http://example.org"
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", ->
request = req "http://webdevcat.me" request = req "http://webdevcat.me"
@ -69,3 +75,9 @@ describe "http://miti.sh/posts", ->
assert.same request\statusCode!, 200 assert.same request\statusCode!, 200
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://apps.miti.sh", ->
it "doesn't find it", ->
request = req "http://apps.miti.sh"
assert.same request\statusCode!, 404
assert.same request\statusMessage!, "Not Found"

View File

@ -5,8 +5,12 @@
image=miti.sh image=miti.sh
echo "Starting test container..." echo "Starting test container..."
container_id=$(docker run --rm -d -v $(pwd):/opt/app \
# Make sure to create 'no-internet' network, if it doesn't already exist:
# $ docker network create --internal 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=webdevcat.me=127.0.0.1 \ --add-host=webdevcat.me=127.0.0.1 \
$image) $image)