From 03735d4c6fc17193e5019d3bd595bad2ce41c61f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20N=C3=A4slund?= Date: Thu, 17 Nov 2022 22:04:24 +0100 Subject: added tests --- dev-run.sh | 98 ++++++-------------------------------------------------------- 1 file changed, 9 insertions(+), 89 deletions(-) (limited to 'dev-run.sh') diff --git a/dev-run.sh b/dev-run.sh index 976b964..2d7f780 100755 --- a/dev-run.sh +++ b/dev-run.sh @@ -1,103 +1,23 @@ #!/bin/bash echo "Checking package" -mypy --strict --namespace-packages --ignore-missing-imports --cache-dir=/tmp/ src/soc_collector/*.py # || exit 1 +mypy --strict --namespace-packages --ignore-missing-imports --cache-dir=/tmp/ src/soc_collector/*.py || exit 1 black --line-length 120 src/soc_collector/*.py # || exit 1 pylint --max-line-length 120 src/soc_collector/*.py # || exit 1 +echo "Checking tests" +mypy --strict --namespace-packages --ignore-missing-imports --cache-dir=/tmp/ tests/*.py # || exit 1 +black --line-length 120 tests/*.py # || exit 1 +pylint --disable R0801 --max-line-length 120 tests/*.py # || exit 1 + mkdir -p data/mongodb_data -sudo chown -R $USER data/mongodb_data +sudo chown -R "$USER" data/mongodb_data docker-compose -f docker-compose.yml build sudo chown -R 101 data/mongodb_data docker-compose -f docker-compose.yml up -d sleep 3 - - -echo -echo -curl -v -k --data-binary @data/example_data_3.json https://127.0.0.1:8000/sc/v0 -echo -echo - -curl -v -k -X DELETE https://127.0.0.1:8000/sc/v0/63702570e004d2b0b2254d27 -echo -echo -curl -v -k -X DELETE https://127.0.0.1:8000/sc/v0/63702570e004d2b0b2254d27 -echo -echo - -curl -v -k -d '{"search": {"port": {"$lt": 4}}}' -H 'Content-Type: application/json' https://127.0.0.1:8000/sc/v0/search -echo -echo -curl -v -k -d '{"search": {"port": 112}}' -H 'Content-Type: application/json' https://127.0.0.1:8000/sc/v0/search -echo -echo -curl -v -k -d '{"search": {"port": {"$gt": 4}}}' -H 'Content-Type: application/json' https://127.0.0.1:8000/sc/v0/search -echo -echo -curl -v -k -d '{"search": {"port": 111}}' -H 'Content-Type: application/json' https://127.0.0.1:8000/sc/v0/search -echo -echo -curl -v -k -d '{"search": {"port": {"sdfsf": 7}}}' -H 'Content-Type: application/json' https://127.0.0.1:8000/sc/v0/search -echo -echo -curl -v -k -d '{"search": {"port": {"$sdfsf": 7}}}' -H 'Content-Type: application/json' https://127.0.0.1:8000/sc/v0/search -echo -echo -curl -v -k -d '{"search": {"portfdv": {"$asa": 7}}}' -H 'Content-Type: application/json' https://127.0.0.1:8000/sc/v0/search -echo -echo - -echo -echo -curl -v -k -X PUT --data-binary @data/example_data_3_replace_test.json https://127.0.0.1:8000/sc/v0 - -echo -echo -curl -v -k https://127.0.0.1:8000/info - - -# bash quickstart.sh -b || exit 1 -# sleep 3 -# JWT=$(curl -k http://localhost:8000/api/v1.0/auth -X POST -p -u usr:pwd | jq -r .access_token) || exit 1 -# curl -k --data-binary @example_data_1.json -H "Authorization: Bearer $JWT" https://localhost:1443/sc/v0/add || exit 1 -# curl -k --data-binary @example_data_3.json -H "Authorization: Bearer $JWT" https://localhost:1443/sc/v0/add || exit 1 -# sleep 1 -# curl -k -H "Authorization: Bearer $JWT" https://localhost:1443/sc/v0/get | json_pp -json_opt utf8,pretty || exit 1 - -# curl -k -H "Authorization: Bearer $JWT" https://localhost:1443/sc/v0/get?port=111 || exit 1 - -# echo "OK" -# exit 0 - - -#echo "Checking tests" -#mypy --strict --namespace-packages --ignore-missing-imports --cache-dir=/dev/null tests/*.py || exit 1 -#black --line-length 120 tests/*.py || exit 1 -#pylint --max-line-length 120 tests/*.py || exit 1 - -# Stop old container, build and run the new one -# docker build -t pkcs11_ca_service_http . -# docker stop /pkcs11_ca_service_http -# docker rm /pkcs11_ca_service_http -# docker run \ -# --name pkcs11_ca_service_http \ -# --net pkcs11_ca_service_network \ -# --restart always \ -# --security-opt no-new-privileges \ -# --cap-drop all \ -# --read-only \ -# --memory 256m \ -# --cpus 2.75 \ -# --mount type=tmpfs,target=/dev/shm,readonly=true \ -# -v /app_softhsm:/var/lib/softhsm/tokens \ -# -p 8000:8000 \ -# -d \ -# pkcs11_ca_service_http - -# sleep 2 -# echo "Running tests" -# python3 -m unittest +echo "Running tests" +python3 -m unittest -- cgit v1.1