summaryrefslogtreecommitdiffstats
path: root/t/ssh-basic.t
blob: ebed2d22907c54f656d92d979777b6b87586b6b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
use strict;
use warnings;

# this is hardcoded; change it if needed
use lib "src/lib";
use Gitolite::Common;
use Gitolite::Test;

# basic tests using ssh
# ----------------------------------------------------------------------

my $bd = `gitolite query-rc -n GL_BINDIR`;
my $h  = $ENV{HOME};
my $ab = `gitolite query-rc -n GL_ADMIN_BASE`;
umask 0077;

try "
    plan 26

    # reset stuff
    rm -f $h/.ssh/authorized_keys;          ok or die 1

    cp $bd/../t/keys/u[1-6]* $h/.ssh;       ok or die 2
    cp $bd/../t/keys/admin*  $h/.ssh;       ok or die 3
    cp $bd/../t/keys/config  $h/.ssh;       ok or die 4
        cat $h/.ssh/config
        perl s/%USER/$ENV{USER}/
        put $h/.ssh/config

    mkdir                  $ab/keydir;      ok or die 5
    cp $bd/../t/keys/*.pub $ab/keydir;      ok or die 6
";

system("gitolite ../triggers/post-compile/ssh-authkeys");

# basic tests
# ----------------------------------------------------------------------

confreset; confadd '
    @g1 = u1
    @g2 = u2
    repo foo
        RW = @g1 u3
        R  = @g2 u4
';

try "ADMIN_PUSH set3; !/FATAL/" or die text();

try "
    ssh u1 info;                ok;     /R W\tfoo/
    ssh u2 info;                ok;     /R  \tfoo/
    ssh u3 info;                ok;     /R W\tfoo/
    ssh u4 info;                ok;     /R  \tfoo/
    ssh u5 info;                ok;     !/foo/
    ssh u6 info;                ok;     !/foo/
"