tests - copy local files for Linux tests
This commit is contained in:
parent
458ebe07ff
commit
a0948923ec
|
@ -14,4 +14,5 @@ mkdir /etc/authelia
|
|||
cp ./authelia/* /etc/authelia
|
||||
sed -i "s@/config/@/etc/authelia/@g" /etc/authelia/configuration.yml
|
||||
systemctl daemon-reload
|
||||
systemctl start authelia
|
||||
systemctl start authelia
|
||||
cp variables.env /opt/bunkerweb/variables.env
|
|
@ -0,0 +1,32 @@
|
|||
HTTP_PORT=80
|
||||
HTTPS_PORT=443
|
||||
DNS_RESOLVERS=8.8.8.8 8.8.4.4
|
||||
MULTISITE=yes
|
||||
SERVER_NAME=auth.example.com app1.example.com app2.example.com # replace with your domains
|
||||
SERVE_FILES=no
|
||||
DISABLE_DEFAULT_SERVER=yes
|
||||
AUTO_LETS_ENCRYPT=yes
|
||||
USE_CLIENT_CACHE=yes
|
||||
USE_GZIP=yes
|
||||
USE_REVERSE_PROXY=yes
|
||||
# Proxy to auth_request URI
|
||||
REVERSE_PROXY_URL_999=/authelia
|
||||
REVERSE_PROXY_HOST_999=http://127.0.0.1:9091/api/verify
|
||||
REVERSE_PROXY_HEADERS_999=X-Original-URL $$scheme://$$http_host$$request_uri;Content-Length ""
|
||||
# Authelia
|
||||
auth.example.com_REVERSE_PROXY_URL=/
|
||||
auth.example.com_REVERSE_PROXY_HOST=http://127.0.0.1:9091
|
||||
auth.example.com_REVERSE_PROXY_INTERCEPT_ERRORS=no
|
||||
# Applications
|
||||
app1.example.com_REVERSE_PROXY_URL=/
|
||||
app1.example.com_REVERSE_PROXY_HOST=http://app1.example.com
|
||||
app1.example.com_REVERSE_PROXY_AUTH_REQUEST=/authelia
|
||||
app1.example.com_REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL=https://auth.example.com/?rd=$$scheme%3A%2F%2F$$host$$request_uri
|
||||
app1.example.com_REVERSE_PROXY_AUTH_REQUEST_SET=$$user $$upstream_http_remote_user;$$groups $$upstream_http_remote_groups;$$name $$upstream_http_remote_name;$$email $$upstream_http_remote_email
|
||||
app1.example.com_REVERSE_PROXY_HEADERS=Remote-User $$user;Remote-Groups $$groups;Remote-Name $$name;Remote-Email $$email
|
||||
app2.example.com_REVERSE_PROXY_URL=/
|
||||
app2.example.com_REVERSE_PROXY_HOST=http://app2.example.com
|
||||
app2.example.com_REVERSE_PROXY_AUTH_REQUEST=/authelia
|
||||
app2.example.com_REVERSE_PROXY_AUTH_REQUEST_SIGNIN_URL=https://auth.example.com/?rd=$$scheme%3A%2F%2F$$host$$request_uri
|
||||
app2.example.com_REVERSE_PROXY_AUTH_REQUEST_SET=$$user $$upstream_http_remote_user;$$groups $$upstream_http_remote_groups;$$name $$upstream_http_remote_name;$$email $$upstream_http_remote_email
|
||||
app2.example.com_REVERSE_PROXY_HEADERS=Remote-User $$user;Remote-Groups $$groups;Remote-Name $$name;Remote-Email $$email
|
|
@ -34,21 +34,31 @@ class LinuxTest(Test) :
|
|||
rmtree("/tmp/linux")
|
||||
mkdir("/tmp/linux")
|
||||
chmod("/tmp/linux", 0o0777)
|
||||
cmd = "docker run -v /tmp/bw-data/letsencrypt:/etc/letsencrypt -v /tmp/bw-data/cache:/opt/bunkerweb/cache -v /tmp/bw-data/configs:/opt/bunkerweb/configs -v /tmp/bw-data/www:/opt/bunkerweb/www -v /tmp/linux/variables.env:/opt/bunkerweb/variables.env -p 80:80 -p 443:443 --rm --name linux-" + distro + " -d --tmpfs /tmp --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro bw-" + distro
|
||||
cmd = "docker run -p 80:80 -p 443:443 --rm --name linux-" + distro + " -d --tmpfs /tmp --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro bw-" + distro
|
||||
proc = run(cmd, shell=True)
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("docker run failed (linux stack)"))
|
||||
cmd = "docker exec linux-" + distro + " "
|
||||
if distro in ["ubuntu", "debian"] :
|
||||
cmd += " apt install -y /opt/\\$(ls /opt | grep deb)"
|
||||
cmd = "apt install -y /opt/\$(ls /opt | grep deb)"
|
||||
elif distro in ["centos", "fedora"] :
|
||||
cmd += " dnf install -y /opt/\\$(ls /opt | grep rpm)"
|
||||
proc = run(cmd, shell=True)
|
||||
cmd = "dnf install -y /opt/\$(ls /opt | grep rpm)"
|
||||
proc = TestLinux.docker_exec(distro, cmd)
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("docker exec apt install failed (linux stack)"))
|
||||
proc = LinuxTest.docker_exec(distro, "systemctl start bunkerweb", shell=True)
|
||||
proc = LinuxTest.docker_exec(distro, "systemctl start bunkerweb")
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("docker exec systemctl start failed (linux stack)"))
|
||||
cp_dirs = {
|
||||
"/tmp/bw-data/letsencrypt": "/etc/letsencrypt",
|
||||
"/tmp/bw-data/cache": "/opt/bunkerweb/cache"
|
||||
}
|
||||
for src, dst in cp_dirs.items() :
|
||||
proc = LinuxTest.docker_cp(distro, src, dst)
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("docker cp failed for " + src + " (linux stack)"))
|
||||
proc = LinuxTest.docker_exec(distro, "chown -R nginx:nginx " + dst + "/*")
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("docker exec failed for directory " + src + " (linux stack)"))
|
||||
except :
|
||||
log("LINUX", "❌", "exception while running LinuxTest.init()\n" + format_exc())
|
||||
return False
|
||||
|
@ -78,10 +88,10 @@ class LinuxTest(Test) :
|
|||
Test.replace_in_files(test, "example.com", getenv("ROOT_DOMAIN"))
|
||||
setup = test + "/setup-linux.sh"
|
||||
if isfile(setup) :
|
||||
proc = run("docker cp /tmp/" + self._name + " linux-" + self.__distro + ":/opt/tests", cwd=test, shell=True)
|
||||
proc = LinuxTest.docker_cp(self.__distro, "/tmp/" + self._name, "/opt/tests")
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("docker cp failed (linux stack)"))
|
||||
proc = LinuxTest.docker_exec(self.__distro, "/opt/tests/" + self._name + "/setup-linux.sh")
|
||||
proc = LinuxTest.docker_exec(self.__distro, "cd /opt/tests/" + self._name + " && ./setup-linux.sh")
|
||||
if proc.returncode != 0 :
|
||||
raise(Exception("docker exec setup failed (linux stack)"))
|
||||
if isdir(example_data) :
|
||||
|
@ -106,7 +116,10 @@ class LinuxTest(Test) :
|
|||
# return True
|
||||
|
||||
def _debug_fail(self) :
|
||||
LinuxTestdocker_exec(self.__distro, "cat /var/log/nginx/access.log ; cat /var/log/nginx/error.log ; journalctl -u bunkerweb --no-pager")
|
||||
LinuxTest.docker_exec(self.__distro, "cat /var/log/nginx/access.log ; cat /var/log/nginx/error.log ; journalctl -u bunkerweb --no-pager")
|
||||
|
||||
def docker_exec(distro, cmd_linux) :
|
||||
return run("docker exec linux-" + distro + " /bin/bash -c \"" + cmd_linux + "\"", shell=True)
|
||||
return run("docker exec linux-" + distro + " /bin/bash -c \"" + cmd_linux + "\"", shell=True)
|
||||
|
||||
def docker_cp(distro, src, dst) :
|
||||
return run("docker cp " + src + " linux-" + distro + ":" + dst)
|
Loading…
Reference in New Issue