diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:17:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 14:17:27 +0000 |
commit | aae1a14ea756102251351d96e2567b4986d30e2b (patch) | |
tree | a1af617672e26aee4c1031a3aa83e8ff08f6a0a5 /t/smart-http | |
parent | Initial commit. (diff) | |
download | gitolite3-aae1a14ea756102251351d96e2567b4986d30e2b.tar.xz gitolite3-aae1a14ea756102251351d96e2567b4986d30e2b.zip |
Adding upstream version 3.6.12.upstream/3.6.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | t/smart-http | 90 | ||||
-rwxr-xr-x | t/smart-http.root-setup | 105 |
2 files changed, 195 insertions, 0 deletions
diff --git a/t/smart-http b/t/smart-http new file mode 100755 index 0000000..3ac910b --- /dev/null +++ b/t/smart-http @@ -0,0 +1,90 @@ +#!/bin/bash + +die() { echo "$@"; exit 1; } + +# git clone `url u1 r1` +url() { + echo http://$1:$1@localhost/git/$2.git +} + +# `cmd sitaram info` +cmd() { + c="curl http://$1:$1@localhost/git" + shift + c="$c/$1" + shift + + if [ -n "$1" ] + then + c="$c?$1" + shift + fi + while [ -n "$1" ] + do + c="$c+$1" + shift + done + + echo $c +} + +export tmp=$(mktemp -d); +trap "rm -rf $tmp" 0; +cd $tmp + +tsh "plan 28" + +tsh " + ## ls-remote admin admin + git ls-remote `url admin gitolite-admin` + ok + /HEAD/ + /refs.heads.master/ + ## clone + git clone `url admin gitolite-admin` + ok + /Cloning into/ + ls -al gitolite-admin/conf + /gitolite.conf/ +" || die "step 1" + +cd gitolite-admin +echo repo t2 >> conf/gitolite.conf +echo 'RW+ = u1 u2' >> conf/gitolite.conf + +tsh " + ## add, commit, push + git add conf/gitolite.conf + ok + !/./ + git commit -m t2 + ok + /1 file.*changed/ + git push + ok + /Initialized.*gitolite-home.repositories.t2.git/ + /To http:..localhost.git.gitolite-admin.git/ + /master -. master/ + ## various ls-remotes + git ls-remote `url u1 gitolite-admin` + !ok + /FATAL: R any gitolite-admin u1 DENIED by fallthru/ + git ls-remote `url u1 t2` + ok + !/./ + git ls-remote `url u2 t2` + ok + !/./ + git ls-remote `url u3 t2` + !ok + /FATAL: R any t2 u3 DENIED by fallthru/ + ## push to u1:t2 + git push `url u1 t2` master:master + ok + /To http:..localhost.git.t2.git/ + /master -. master/ + git ls-remote `url u2 t2` + ok + /HEAD/ + /refs.heads.master/ +" || die "step 2" diff --git a/t/smart-http.root-setup b/t/smart-http.root-setup new file mode 100755 index 0000000..f22dcb5 --- /dev/null +++ b/t/smart-http.root-setup @@ -0,0 +1,105 @@ +#!/bin/bash + +# ---------------------------------------------------------------------- +# please do not even LOOK at this file without reading doc/http.mkd +# ---------------------------------------------------------------------- + +die() { echo "$@"; exit 1; } + +# scare the sh*t out of people who run it blindly +[ -f /tmp/gitolite-smart-http-test-OK ] || { + # scary message + echo '+ rm -rf /' + # lots of disk activity + find / >/dev/null 2>/dev/null + # and it he's still clueless, God bless! + echo 'root file system erased successfully. Goodbye and God bless!' + exit 1 +} + +# ---------------------------------------------------------------------- +# are we *BSD or Linux? +uname_s=`uname -s` # could be Linux or FreeBSD or some other BSD +if [ "$uname_s" = "Linux" ] +then + bsd=: +else + lnx=: +fi + +# ---------------------------------------------------------------------- +# main + +[ $EUID = 0 ] || die "you must run this as root" + +# delete any existing apache conf for gitolite +$lnx rm /etc/httpd/conf.d/gitolite.conf +$bsd rm /usr/local/etc/apache24/Includes/gitolite.conf + +# build your "home within a home" +$lnx cd ~apache +$bsd rm -rf /tmp/usr.share.httpd +$bsd mkdir -p /tmp/usr.share.httpd +$bsd chown www:www /tmp/usr.share.httpd +$bsd cd /tmp/usr.share.httpd + +rm -rf gitolite-home +mkdir gitolite-home +export GITOLITE_HTTP_HOME=$PWD/gitolite-home + +# get the gitolite sources +cd gitolite-home +git clone /tmp/gitolite.git gitolite-source +# NOTE: I use a bare repo in /tmp for convenience; you'd use +# 'https://github.com/sitaramc/gitolite' + +# make the bin directory, and add it to PATH +cd gitolite-source +mkdir $GITOLITE_HTTP_HOME/bin +./install -ln $GITOLITE_HTTP_HOME/bin +export PATH=$PATH:$GITOLITE_HTTP_HOME/bin + +# come back to base, then run setup. Notice that you have to point HOME to +# the right place, even if it is just for this command +cd $GITOLITE_HTTP_HOME +HOME=$GITOLITE_HTTP_HOME gitolite setup -a admin + +# insert some essential lines at the beginning of the rc file +echo '$ENV{PATH} .= ":$ENV{GITOLITE_HTTP_HOME}/bin";' >> 1 +echo >> 1 +cat .gitolite.rc >> 1 +\mv 1 .gitolite.rc + +# fix up ownership +$lnx chown -R apache:apache $GITOLITE_HTTP_HOME +$bsd chown -R www:www $GITOLITE_HTTP_HOME + +# create the apache config. Note the trailing slashes on the 2 ScriptAlias +# lines. (The second one is optional for most sites). NOTE: you also need to +# give the AuthUserFile a better name/location than what I have below. +cat <<EOF1 > 1 +SetEnv GIT_PROJECT_ROOT $GITOLITE_HTTP_HOME/repositories +ScriptAlias /git/ $GITOLITE_HTTP_HOME/gitolite-source/src/gitolite-shell/ +ScriptAlias /gitmob/ $GITOLITE_HTTP_HOME/gitolite-source/src/gitolite-shell/ +SetEnv GITOLITE_HTTP_HOME $GITOLITE_HTTP_HOME +SetEnv GIT_HTTP_EXPORT_ALL + +<Location /git> + AuthType Basic + AuthName "Private Git Access" + Require valid-user + AuthUserFile $GITOLITE_HTTP_HOME/gitolite-http-authuserfile +</Location> +EOF1 +$lnx mv 1 /etc/httpd/conf.d/gitolite.conf +$bsd mv 1 /usr/local/etc/apache24/Includes/gitolite.conf + +# NOTE: this is for testing only +htpasswd -bc $GITOLITE_HTTP_HOME/gitolite-http-authuserfile admin admin +map "htpasswd -b $GITOLITE_HTTP_HOME/gitolite-http-authuserfile % %" u{1..6} +$lnx chown apache:apache $GITOLITE_HTTP_HOME/gitolite-http-authuserfile +$bsd chown www:www $GITOLITE_HTTP_HOME/gitolite-http-authuserfile + +# restart httpd to make it pick up all the new stuff +$lnx service httpd restart +$bsd /usr/local/etc/rc.d/apache24 restart |