tests - add status type
This commit is contained in:
parent
1513785705
commit
dc8570ca87
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $(id -u) -ne 0 ] ; then
|
||||
echo "❌ Run me as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir elasticsearch-data
|
||||
chown 1001:1001 elasticsearch-data
|
||||
chmod 770 elasticsearch-data
|
|
@ -11,7 +11,7 @@
|
|||
{
|
||||
"type": "string",
|
||||
"url": "https://www.example.com",
|
||||
"string": "hello"
|
||||
"string": "magento"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
mongo:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
bw-services:
|
||||
aliases:
|
||||
- mongo
|
||||
volumes:
|
||||
- ./db:/data/db
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=root # replace with a less obvious username
|
||||
- MONGO_INITDB_ROOT_PASSWORD=toor # replace with a better password
|
||||
- MONGO_INITDB_DATABASE=mongo # replace with the database name of your choice
|
||||
|
||||
mongo-ui:
|
||||
image: mongo-express:latest
|
||||
networks:
|
||||
bw-services:
|
||||
aliases:
|
||||
- mongo-ui
|
||||
environment:
|
||||
- ME_CONFIG_MONGODB_SERVER=mongo
|
||||
- ME_CONFIG_MONGODB_ADMINUSERNAME=root # replace with a less obvious username
|
||||
- ME_CONFIG_MONGODB_ADMINPASSWORD=toor # replace with a better password
|
||||
- ME_CONFIG_BASICAUTH_USERNAME=changeme # replace with a better username
|
||||
- ME_CONFIG_BASICAUTH_PASSWORD=changeme # replace with a better password
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- mongo
|
||||
labels:
|
||||
- bunkerweb.USE_REVERSE_PROXY=yes
|
||||
- bunkerweb.REVERSE_PROXY_URL=/
|
||||
- bunkerweb.REVERSE_PROXY_HOST=http://mongo-ui:8081
|
||||
|
||||
networks:
|
||||
bw-services:
|
||||
external:
|
||||
name: bw-services
|
|
@ -1,9 +1,28 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
mybunker:
|
||||
image: bunkerity/bunkerweb:1.4.2
|
||||
ports:
|
||||
- 80:8080
|
||||
- 443:8443
|
||||
volumes:
|
||||
- ./bw-data:/data
|
||||
environment:
|
||||
- SERVER_NAME=www.example.com # replace with your domain
|
||||
- SERVE_FILES=no
|
||||
- DISABLE_DEFAULT_SERVER=yes
|
||||
- AUTO_LETS_ENCRYPT=yes
|
||||
- USE_CLIENT_CACHE=yes
|
||||
- USE_GZIP=yes
|
||||
- AUTO_LETS_ENCRYPT=yes
|
||||
- USE_REVERSE_PROXY=yes
|
||||
- REVERSE_PROXY_URL=/
|
||||
- REVERSE_PROXY_HOST=http://mongo-ui:8081
|
||||
|
||||
mongo:
|
||||
image: mongo:latest
|
||||
container_name: mongo
|
||||
volumes:
|
||||
- ./db:/data/db
|
||||
environment:
|
||||
|
@ -21,27 +40,4 @@ services:
|
|||
- ME_CONFIG_BASICAUTH_PASSWORD=changeme # replace with a better password
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- mongo
|
||||
|
||||
mybunker:
|
||||
image: bunkerity/bunkerweb:1.4.2
|
||||
ports:
|
||||
- 80:8080
|
||||
- 443:8443
|
||||
volumes:
|
||||
- ./bw_data:/data
|
||||
environment:
|
||||
- SERVER_NAME=www.example.com # replace with your domain
|
||||
- SERVE_FILES=no
|
||||
- DISABLE_DEFAULT_SERVER=yes
|
||||
- AUTO_LETS_ENCRYPT=yes
|
||||
- USE_CLIENT_CACHE=yes
|
||||
- USE_GZIP=yes
|
||||
- AUTO_LETS_ENCRYPT=yes
|
||||
- USE_REVERSE_PROXY=yes
|
||||
- REVERSE_PROXY_URL=/
|
||||
- REVERSE_PROXY_HOST=http://mongo-ui:8081
|
||||
- USE_ANTIBOT=javascript # put the antibot of your choice here
|
||||
|
||||
volumes:
|
||||
bw_config:
|
||||
- mongo
|
4
examples/mongo-express/setup.sh → examples/mongo-express/setup-docker.sh
Normal file → Executable file
4
examples/mongo-express/setup.sh → examples/mongo-express/setup-docker.sh
Normal file → Executable file
|
@ -5,5 +5,5 @@ if [ $(id -u) -ne 0 ] ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
chown -R root:101 bw_data
|
||||
chmod -R 770 bw_data
|
||||
chown -R root:101 bw-data
|
||||
chmod -R 770 bw-data
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
# docker-compose doesn't support assigning labels to configs
|
||||
# so we need to create the configs with the CLI
|
||||
# bunkerweb.CONFIG_TYPE accepted values are http, stream, server-http, server-stream, default-server-http, modsec and modsec-crs
|
||||
# bunkerweb.CONFIG_SITE lets you choose on which web service the config should be applied (MULTISITE mode) and if it's not set, the config will be applied for all services
|
||||
# more info at https://docs.bunkerweb.io
|
||||
|
||||
# remove configs if existing
|
||||
docker config rm cfg_me_modsec
|
||||
|
||||
# create configs
|
||||
docker config create -l bunkerweb.CONFIG_TYPE=modsec -l bunkerweb.CONFIG_SITE=www.example.com cfg_me_modsec ./bw-data/configs/modsec/www.example.com/mongo-express.conf
|
|
@ -0,0 +1,48 @@
|
|||
version: "3"
|
||||
|
||||
services:
|
||||
|
||||
mongo:
|
||||
image: mongo:latest
|
||||
networks:
|
||||
- bw-services
|
||||
volumes:
|
||||
- db:/data/db
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=root # replace with a less obvious username
|
||||
- MONGO_INITDB_ROOT_PASSWORD=toor # replace with a better password
|
||||
- MONGO_INITDB_DATABASE=mongo # replace with the database name of your choice
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- "node.role==worker"
|
||||
|
||||
mongo-ui:
|
||||
image: mongo-express:latest
|
||||
networks:
|
||||
- bw-services
|
||||
environment:
|
||||
- ME_CONFIG_MONGODB_SERVER=mongo
|
||||
- ME_CONFIG_MONGODB_ADMINUSERNAME=root # replace with a less obvious username
|
||||
- ME_CONFIG_MONGODB_ADMINPASSWORD=toor # replace with a better password
|
||||
- ME_CONFIG_BASICAUTH_USERNAME=changeme # replace with a better username
|
||||
- ME_CONFIG_BASICAUTH_PASSWORD=changeme # replace with a better password
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- mongo
|
||||
deploy:
|
||||
placement:
|
||||
constraints:
|
||||
- "node.role==worker"
|
||||
labels:
|
||||
- bunkerweb.USE_REVERSE_PROXY=yes
|
||||
- bunkerweb.REVERSE_PROXY_URL=/
|
||||
- bunkerweb.REVERSE_PROXY_HOST=http://mongo-ui:8081
|
||||
|
||||
networks:
|
||||
bw-services:
|
||||
external:
|
||||
name: bw-services
|
||||
|
||||
volumes:
|
||||
db:
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "mongo-express",
|
||||
"kinds": [
|
||||
"docker",
|
||||
"autoconf",
|
||||
"swarm"
|
||||
],
|
||||
"timeout": 60,
|
||||
"tests": [
|
||||
{
|
||||
"type": "status",
|
||||
"url": "https://www.example.com",
|
||||
"status": 401
|
||||
}
|
||||
]
|
||||
}
|
|
@ -94,14 +94,17 @@ class Test(ABC) :
|
|||
# run a single test
|
||||
def __run_test(self, test) :
|
||||
try :
|
||||
ex_url = test["url"]
|
||||
for ex_domain, test_domain in self._domains.items() :
|
||||
if search(ex_domain, ex_url) :
|
||||
ex_url = sub(ex_domain, test_domain, ex_url)
|
||||
break
|
||||
if test["type"] == "string" :
|
||||
ex_url = test["url"]
|
||||
for ex_domain, test_domain in self._domains.items() :
|
||||
if search(ex_domain, ex_url) :
|
||||
ex_url = sub(ex_domain, test_domain, ex_url)
|
||||
break
|
||||
r = get(ex_url, timeout=5)
|
||||
return test["string"].casefold() in r.text.casefold()
|
||||
elif test["type"] == "status" :
|
||||
r = get(ex_url, timeout=5)
|
||||
return test["status"] == r.status_code
|
||||
except :
|
||||
#log("TEST", "❌", "exception while running test of type " + test["type"] + " on URL " + ex_url + "\n" + format_exc())
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue