From 36dabd454bf137f74ab7c3e372b060a4ded7f284 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 14 Oct 2026 15:59:48 +0500 Subject: t/i/docker: move SSH setup to git_server --- test/integration/docker/git_server/setup.sh | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 test/integration/docker/git_server/setup.sh (limited to 'test/integration/docker/git_server/setup.sh') diff --git a/test/integration/docker/git_server/setup.sh b/test/integration/docker/git_server/setup.sh new file mode 100755 index 0000000..f2572ff --- /dev/null +++ b/test/integration/docker/git_server/setup.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail +shopt -s inherit_errexit lastpipe + +readonly ssh_dir=/ssh +readonly ssh_client_password='password' + +configure_git() { + echo + echo ---------------------------------------------------------------------- + echo Configuring git + echo ---------------------------------------------------------------------- + + git config --global user.name 'John Doe' + git config --global user.email 'John.Doe@example.com' + git config --global init.defaultBranch main +} + +generate_ssh_keys() { + echo + echo ---------------------------------------------------------------------- + echo Generating SSH keys + echo ---------------------------------------------------------------------- + + mkdir -p -- "$ssh_dir" + + ssh-keygen -t rsa -b 4096 -f "$ssh_dir/client_key" -N "$ssh_client_password" + ssh-keygen -t rsa -b 4096 -f "$ssh_dir/server_key" -N '' + + mkdir ~/.ssh + + cp "$ssh_dir/server_key" /etc/ssh/ssh_host_ed25519_key + cp "$ssh_dir/server_key.pub" /etc/ssh/ssh_host_ed25519_key.pub + cp "$ssh_dir/client_key.pub" ~/.ssh/authorized_keys + + chmod 0600 -- /etc/ssh/ssh_host_ed25519_key + chmod 0700 -- ~/.ssh/ + chmod 0600 -- ~/.ssh/authorized_keys +} + +readonly repo_path="$HOME/test_repo" + +create_repo() { + echo + echo ---------------------------------------------------------------------- + echo Setting up upstream repository + echo ---------------------------------------------------------------------- + + mkdir -p -- "$repo_path" + pushd -- "$repo_path" > /dev/null + git init + echo '1' > 1.txt + git add . + git commit -m 'first commit' + echo '2' > 2.txt + git add . + git commit -m 'second commit' + popd > /dev/null +} + +main() { + configure_git + generate_ssh_keys + create_repo +} + +main -- cgit v1.3