aboutsummaryrefslogtreecommitdiff
blob: 314cd6c9b632666ab57ad64f88a3c8f339523b93 (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
# vim: syn=sh:
for wr in 0 1
do
    for bc in 0 1
    do
        cd $TESTDIR
        $TESTDIR/rollback || die "rollback failed"
        editrc GL_WILDREPOS $wr
        editrc GL_BIG_CONFIG $bc

        # ----------

        name "INTERNAL"
        echo "
            @staff = u1 u2 u3 u4 u5 u6
            @gfoo = foo
            repo  @gfoo
                  RW+                       = u1 u2
                  RW+   personal/USER/      = u3 u4
                  RW    temp                = u5 u6
        " | ugc

        cd ~/td
        runlocal git clone u1:foo

        cd foo
        mdc; mdc; mdc; mdc; mdc

        name "u1 and u2 can push"
        runlocal git push origin master
        expect_push_ok "master -> master"
        runlocal git push u2:foo master:personal/u1/foo
        expect_push_ok "master -> personal/u1/foo"
        runlocal git push origin master:personal/u2/foo
        expect_push_ok "master -> personal/u2/foo"
        runlocal git push u1:foo master:personal/u3/foo
        expect_push_ok "master -> personal/u3/foo"

        mdc;
        name "u3 cant push u1/u4 personal branches"
        runlocal git push u3:foo master:personal/u1/foo
        expect "remote: W refs/heads/personal/u1/foo foo u3 DENIED by fallthru"
        expect "\[remote rejected\] master -> personal/u1/foo (hook declined)"
        expect "failed to push"
        runlocal git push u3:foo master:personal/u4/foo
        expect "remote: W refs/heads/personal/u4/foo foo u3 DENIED by fallthru"
        expect "\[remote rejected\] master -> personal/u4/foo (hook declined)"
        expect "failed to push"
        name "u4 can push u4 personal branch"
        runlocal git push u4:foo master:personal/u4/foo
        expect_push_ok "master -> personal/u4/foo"
        name "u5 push temp"
        runlocal git push u5:foo master:temp
        expect_push_ok "master -> temp"

        runlocal git reset --hard HEAD^^^

        name "u1 and u2 can rewind"
        runlocal git push -f origin master
        expect "master -> master (forced update)"
        runlocal git push -f u2:foo master:personal/u1/foo
        expect "master -> personal/u1/foo (forced update)"
        runlocal git push -f origin master:personal/u2/foo
        expect "master -> personal/u2/foo (forced update)"
        runlocal git push -f u1:foo master:personal/u3/foo
        expect "master -> personal/u3/foo (forced update)"

        name "u3 cant rewind u1/u4 personal branches"
        runlocal git reset --hard HEAD^; mdc
        runlocal git push -f u3:foo master:personal/u1/foo
        expect "remote: + refs/heads/personal/u1/foo foo u3 DENIED by fallthru"
        expect "\[remote rejected\] master -> personal/u1/foo (hook declined)"
        expect "failed to push"
        runlocal git push -f u3:foo master:personal/u4/foo
        expect "remote: + refs/heads/personal/u4/foo foo u3 DENIED by fallthru"
        expect "\[remote rejected\] master -> personal/u4/foo (hook declined)"
        expect "failed to push"
        name "u4 can rewind u4 personal branch"
        runlocal git push -f u4:foo master:personal/u4/foo
        expect "master -> personal/u4/foo (forced update)"
        name "u5 cant rewind temp"
        runlocal git push -f u5:foo master:temp
        expect "remote: + refs/heads/temp foo u5 DENIED by fallthru"
        expect "\[remote rejected\] master -> temp (hook declined)"
        expect "failed to push"

        name INTERNAL
    done
done