aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSitaram Chamarty <sitaram@atc.tcs.com>2012-03-08 13:30:13 +0530
committerSitaram Chamarty <sitaram@atc.tcs.com>2012-03-24 10:30:37 +0530
commit60e190215e5e6defe593df8b3eb2e7d3bd409f46 (patch)
tree593a96ec2c5f361c33b0417865ddadc5363ebff9 /t
parentempty (diff)
downloadgitolite-gentoo-60e190215e5e6defe593df8b3eb2e7d3bd409f46.tar.gz
gitolite-gentoo-60e190215e5e6defe593df8b3eb2e7d3bd409f46.tar.bz2
gitolite-gentoo-60e190215e5e6defe593df8b3eb2e7d3bd409f46.zip
very basic, usable, first cut done
- sausage making hidden - lots of important features missing
Diffstat (limited to 't')
-rwxr-xr-xt/gitolite-receive-pack12
-rwxr-xr-xt/gitolite-upload-pack12
-rwxr-xr-xt/glt28
-rwxr-xr-xt/t01-basic110
4 files changed, 162 insertions, 0 deletions
diff --git a/t/gitolite-receive-pack b/t/gitolite-receive-pack
new file mode 100755
index 0000000..48c7428
--- /dev/null
+++ b/t/gitolite-receive-pack
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+print STDERR "TRACE: grp(", join( ")(", @ARGV ), ")\n";
+
+my $repo = shift;
+$repo =~ s/\.git$//;
+my $user = $ENV{G3T_USER} || 'no-such-user';
+
+$ENV{SSH_ORIGINAL_COMMAND} = "git-receive-pack '$repo'";
+exec( "$ENV{HOME}/bin/gitolite-shell", $user );
diff --git a/t/gitolite-upload-pack b/t/gitolite-upload-pack
new file mode 100755
index 0000000..8888abb
--- /dev/null
+++ b/t/gitolite-upload-pack
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+print STDERR "TRACE: gup(", join( ")(", @ARGV ), ")\n";
+
+my $repo = shift;
+$repo =~ s/\.git$//;
+my $user = $ENV{G3T_USER} || 'no-such-user';
+
+$ENV{SSH_ORIGINAL_COMMAND} = "git-upload-pack '$repo'";
+exec( "$ENV{HOME}/bin/gitolite-shell", $user );
diff --git a/t/glt b/t/glt
new file mode 100755
index 0000000..b5704f5
--- /dev/null
+++ b/t/glt
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+print STDERR "TRACE: glt(", join( ")(", @ARGV ), ")\n";
+
+my $cmd = shift or die "need command";
+my $user = shift or die "need user";
+my $rc;
+
+$ENV{G3T_USER} = $user;
+if ( $cmd eq 'push' ) {
+ $rc = system( "git", $cmd, "--receive-pack=$ENV{HOME}/bin/gitolite-receive-pack", @ARGV );
+} else {
+ $rc = system( "git", $cmd, "--upload-pack=$ENV{HOME}/bin/gitolite-upload-pack", @ARGV );
+}
+
+if ( $? == -1 ) {
+ die "F: failed to execute: $!\n";
+} elsif ( $? & 127 ) {
+ printf STDERR "E: child died with signal %d\n", ( $? & 127 );
+ exit 1;
+} else {
+ printf STDERR "W: child exited with value %d\n", $? >> 8 if $? >> 8;
+ exit( $? >> 8 );
+}
+
+exit 0;
diff --git a/t/t01-basic b/t/t01-basic
new file mode 100755
index 0000000..3970308
--- /dev/null
+++ b/t/t01-basic
@@ -0,0 +1,110 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+# this is hardcoded; change it if needed
+use lib "$ENV{HOME}/bin";
+use Gitolite::Test;
+
+# basic tests
+# ----------------------------------------------------------------------
+
+try "
+ plan 74
+
+ ## clone
+ glt clone dev2 file://gitolite-admin
+ !ok; gsh
+ /FATAL: DENIED: R access to gitolite-admin by dev2 .fallthru./
+ /fatal: The remote end hung up unexpectedly/
+ glt clone admin --progress file://gitolite-admin
+ ok; gsh
+ /Counting/; /Compressing/; /Total/
+ cd gitolite-admin; ok
+ ";
+
+put "conf/gitolite.conf", "
+ \@admins = admin dev1
+ repo gitolite-admin
+ - mm = \@admins
+ RW = \@admins
+ RW+ = admin
+
+ repo testing
+ RW+ = \@all
+";
+
+try "
+ ## push
+ git add conf; ok
+ git status -s; ok; /M conf/gitolite.conf/
+ git commit -m t01a; ok; /master.*t01a/
+ glt push dev2 origin; !ok; gsh
+ /FATAL: DENIED: W access to gitolite-admin by dev2 .fallthru./
+ /fatal: The remote end hung up unexpectedly/
+ glt push admin origin; ok; /master -. master/
+ tsh empty; ok;
+ glt push admin origin master:mm
+ !ok; gsh
+ /FATAL: DENIED: W access to gitolite-admin by admin .rule: refs/heads/mm./
+ /remote: error: hook declined to update refs/heads/mm/
+ /To file://gitolite-admin/
+ /remote rejected. master -. mm .hook declined./
+ /error: failed to push some refs to 'file://gitolite-admin'/
+
+ ";
+
+put "conf/gitolite.conf", "
+ \@admins = admin dev1
+ repo gitolite-admin
+ RW+ = admin
+
+ repo testing
+ RW+ = \@all
+
+ repo t1
+ R = u2
+ RW = u3
+ RW+ = u4
+";
+
+try "
+ ## push 2
+ git add conf; ok
+ git status -s; ok; /M conf/gitolite.conf/
+ git commit -m t01b; ok; /master.*t01b/
+ glt push admin origin; ok; gsh
+ /master -. master/
+
+ ## clone
+ cd ..; ok;
+ glt clone u1 file://t1; !ok; gsh
+ /FATAL: DENIED: R access to t1 by u1 .fallthru./
+ /fatal: The remote end hung up unexpectedly/
+ glt clone u2 file://t1; ok; gsh
+ /warning: You appear to have cloned an empty repository./
+ ls -al t1; ok; /$ENV{USER}.*$ENV{USER}.*\.git/
+ cd t1; ok;
+
+ ## push
+ test-commit tc1 tc2 tc2; ok; /f7153e3/
+ glt push u2 origin; !ok; gsh
+ /FATAL: DENIED: W access to t1 by u2 .fallthru./
+ /fatal: The remote end hung up unexpectedly/
+ glt push u3 origin master; ok; gsh
+ /master -. master/
+
+ ## rewind
+ reset-h HEAD^; ok; /HEAD is now at 537f964 tc2/
+ test-tick; test-commit tc3; ok; /a691552/
+ glt push u3 origin; !ok; gsh
+ /rejected.*master -. master.*non-fast-forward./
+ glt push u3 -f origin; !ok; gsh
+ /FATAL: DENIED: \\+ access to t1 by u3 .fallthru./
+ /remote: error: hook declined to update refs/heads/master/
+ /To file://t1/
+ /remote rejected. master -. master .hook declined./
+ /error: failed to push some refs to 'file://t1'/
+ glt push u4 origin +master; ok; gsh
+ / \\+ f7153e3...a691552 master -. master.*forced update./
+"