aboutsummaryrefslogtreecommitdiff
blob: f6dc9499437a6f6a4b6148c64fead2d3cd185fba (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# vim: syn=sh:
for gcw in 0
do
    cd $TESTDIR
    $TESTDIR/rollback || die "rollback failed"

    name INTERNAL
    editrc GL_WILDREPOS 1

    # ----------

    name "fail to set foo.bar"
    echo "
        @leads = u1 u2
        @devs = u1 u2 u3 u4

        repo    bar/CREATOR/..*
            C               =   @leads
            RW+             =   CREATOR
            RW              =   @leads
            config foo.bar  =   baz
    " | ugc
    expect "remote:         git config foo.bar not allowed"

    name "update rc file to allow foo.*"
    catrc
    cp ~/1 ~/junk
    perl -pi -e 's/GL_GITCONFIG_KEYS = ""/GL_GITCONFIG_KEYS = "foo\\\\..*"/' ~/junk
    cat ~/junk | runremote dd of=.gitolite.rc
    catrc
    expect "GL_GITCONFIG_KEYS.*foo"

    name "ok to set foo.bar"
    echo "
        @leads = u1 u2
        @devs = u1 u2 u3 u4

        repo    bar/CREATOR/..*
            C               =   @leads
            RW+             =   CREATOR
            RW              =   @leads
            config foo.bar  =   baz
    " | ugc -r
    notexpect "git config.*not allowed"
    expect_push_ok "master -> master"

    [ "$gcw" = "0" ] && continue    # the rest of these tests don't make sense now

    name "fail to set foobar.baz"
    echo "
        @leads = u1 u2
        @devs = u1 u2 u3 u4

        repo    bar/CREATOR/..*
            C               =   @leads
            RW+             =   CREATOR
            RW              =   @leads
            config foo.bar  =   baz
            config foobar.baz  =   ooka
    " | ugc -r
    expect "remote:         git config foobar.baz not allowed"

    name "u1 create bar/u1/try1"
    runlocal git ls-remote u1:bar/u1/try1
    expect "Initialized empty Git repository in $TEST_BASE_FULL/bar/u1/try1.git/"

    name "check u1 has foo.bar"
    runremote cat $TEST_BASE/bar/u1/try1.git/config
    expect '^.foo'
    expect 'bar = baz'

    name "delete foo.bar"
    echo "
        @leads = u1 u2
        @devs = u1 u2 u3 u4

        repo    bar/CREATOR/..*
            C               =   @leads
            RW+             =   CREATOR
            RW              =   @leads
            config foo.bar  =   
    " | ugc -r
    expect_push_ok "master -> master"

    name "check u1 doesnt have foo.bar"
    runremote cat $TEST_BASE/bar/u1/try1.git/config
    expect '^.foo'      # git leaves the section header behind
    notexpect 'bar = baz'

    name "u2 create bar/u2/try2"
    runlocal git ls-remote u2:bar/u2/try2
    expect "Initialized empty Git repository in $TEST_BASE_FULL/bar/u2/try2.git/"

    name "check u2 doesnt have foo.bar"
    runremote cat $TEST_BASE/bar/u2/try2.git/config
    notexpect '^.foo'   # but not here, since this repo never had the key at all
    notexpect 'bar = baz'

    name "add foo.frob retroactively"
    echo "
        @leads = u1 u2
        @devs = u1 u2 u3 u4

        repo    bar/CREATOR/..*
            C               =   @leads
            RW+             =   CREATOR
            RW              =   @leads
            config foo.frob =   nitz
    " | ugc -r
    expect_push_ok "master -> master"

    name "check u1 has foo.frob"
    runremote cat $TEST_BASE/bar/u1/try1.git/config
    expect '^.foo'
    expect 'frob = nitz'

    name "check u2 has foo.frob"
    runremote cat $TEST_BASE/bar/u2/try2.git/config
    expect '^.foo'
    expect 'frob = nitz'

    name INTERNAL
done