From 7d16d3d41734ac0a6d6153d3be9d8a8dbf594eaf Mon Sep 17 00:00:00 2001 From: Gitouche <26656-gitouche@users.noreply.framagit.org> Date: Sun, 10 Mar 2024 18:04:00 +0100 Subject: [PATCH] gitea/forgejo : premiers tests avec bats --- podman-gitea/.gitlab-ci.yml | 2 +- podman-gitea/10_install.sh | 1 + podman-gitea/test/running.bats | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 podman-gitea/test/running.bats diff --git a/podman-gitea/.gitlab-ci.yml b/podman-gitea/.gitlab-ci.yml index 25c078a..4437312 100644 --- a/podman-gitea/.gitlab-ci.yml +++ b/podman-gitea/.gitlab-ci.yml @@ -11,7 +11,7 @@ gitea: script: - cd podman-gitea - ./ci_build-images.sh - - GARBAYE_GITEA_DOMAIN=git.garbaye.fr GARBAYE_GITEA_SMTP_FROM='git-ci@garbaye.fr' GARBAYE_GITEA_POSTGRES_PASSWORD=kejfczEAKjzkejklc GARBAYE_GITEA_ENV_WEBLISTENPORT=18088 GARBAYE_GITEA_ENV_SSHLISTENPORT=12222 ./05_freshinstall.sh + - GARBAYE_GITEA_DOMAIN=git.garbaye.fr GARBAYE_GITEA_ENV_APPNAME='La forge Garbaye' GARBAYE_GITEA_SMTP_FROM='git-ci@garbaye.fr' GARBAYE_GITEA_POSTGRES_PASSWORD=kejfczEAKjzkejklc GARBAYE_GITEA_ENV_WEBLISTENPORT=18088 GARBAYE_GITEA_ENV_SSHLISTENPORT=12222 ./05_freshinstall.sh - ./20_enable.sh - ./30_start.sh && sleep 10 - ./40_stop.sh diff --git a/podman-gitea/10_install.sh b/podman-gitea/10_install.sh index ad84e33..9929df1 100755 --- a/podman-gitea/10_install.sh +++ b/podman-gitea/10_install.sh @@ -71,6 +71,7 @@ podman unshare sed -i '/{{ctx.Locale.Tr \"startpage.platform\"}}/,${s//Quels con podman unshare sed -i '/{{ctx.Locale.Tr \"startpage.platform_desc\" | Str2html}}/,${s//La forge accueille tout type de contenu tel que code source, documentation, artistique, littéraire, etc. Un usage raisonnable en espace disque est attendu de nos utilisateurs./;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl && podman unshare sed -i '/{{ctx.Locale.Tr \"startpage.license\"}}/,${s//Licences libres/;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl && podman unshare sed -i '/{{ctx.Locale.Tr \"startpage.license_desc\" | Str2html}}/,${s//Tous les projets présents sur cette forge sont publiés sous licences libres, au sens de la Free Software Foundation<\/a>./;b};$q1' `get_podman_volume_path ${datavolume}`/gitea/templates/home.tmpl && +bats test/ && podman pod stop ${pod_name} && echo Pod built and stopped. && shred -u .env diff --git a/podman-gitea/test/running.bats b/podman-gitea/test/running.bats new file mode 100644 index 0000000..6ad7620 --- /dev/null +++ b/podman-gitea/test/running.bats @@ -0,0 +1,28 @@ +#!/usr/bin/env bats + +@test "[http] Check website is responding" { + run -0 curl -s4I "http://localhost:${weblisten_port}/user/login?redirect_to=/" + echo "${output}" | grep -q 'HTTP/1.1 200 OK' +} + +@test "[http] Check website is well configured" { + run -0 curl -s "http://localhost:${weblisten_port}/" + echo "${output}" | grep -q 'La forge Garbaye' +} + +@test "[gitea] Check gitea doctor for errors" { + skip + run -0 podman container exec --user git gitea gitea doctor check --all + # Run all test but suppress output for gc-lfs + ! echo -e "$output" | sed -e '/Garbage collect LFS/,+1d' | grep -q ERROR +} + +@test "[ssh] Check OpenSSH is working over IPv4" { + run -0 bash -c "echo '' | nc -4 localhost ${sshlisten_port}" + echo "${output}" | grep -q 'SSH-2.0-OpenSSH' +} + +@test "[ssh] Check OpenSSH is working over IPv6" { + run -0 bash -c "echo '' | nc -6 localhost ${sshlisten_port}" + echo "${output}" | grep -q 'SSH-2.0-OpenSSH' +}