Sync with 'maint'
[alt-git.git] / t / t5705-session-id-in-capabilities.sh
blobb8a722ec27e73aeeb259e938417017607f64b5ee
1 #!/bin/sh
3 test_description='session ID in capabilities'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 REPO="$(pwd)/repo"
9 LOCAL_PRISTINE="$(pwd)/local_pristine"
11 test_expect_success 'setup repos for session ID capability tests' '
12 git init "$REPO" &&
13 test_commit -C "$REPO" a &&
14 git clone "file://$REPO" "$LOCAL_PRISTINE" &&
15 test_commit -C "$REPO" b
18 for PROTO in 0 1 2
20 test_expect_success "session IDs not advertised by default (fetch v${PROTO})" '
21 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
22 cp -r "$LOCAL_PRISTINE" local &&
23 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
24 git -c protocol.version=$PROTO -C local fetch \
25 --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \
26 origin &&
27 test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" &&
28 test -z "$(grep \"key\":\"client-sid\" tr2-server-events)"
31 test_expect_success "session IDs not advertised by default (push v${PROTO})" '
32 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
33 test_when_finished "git -C local push --delete origin new-branch" &&
34 cp -r "$LOCAL_PRISTINE" local &&
35 git -C local pull --no-rebase origin &&
36 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
37 git -c protocol.version=$PROTO -C local push \
38 --receive-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-receive-pack" \
39 origin HEAD:new-branch &&
40 test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" &&
41 test -z "$(grep \"key\":\"client-sid\" tr2-server-events)"
43 done
45 test_expect_success 'enable SID advertisement' '
46 git -C "$REPO" config transfer.advertiseSID true &&
47 git -C "$LOCAL_PRISTINE" config transfer.advertiseSID true
50 for PROTO in 0 1 2
52 test_expect_success "session IDs advertised (fetch v${PROTO})" '
53 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
54 cp -r "$LOCAL_PRISTINE" local &&
55 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
56 git -c protocol.version=$PROTO -C local fetch \
57 --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \
58 origin &&
59 grep \"key\":\"server-sid\" tr2-client-events &&
60 grep \"key\":\"client-sid\" tr2-server-events
63 test_expect_success "session IDs advertised (push v${PROTO})" '
64 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
65 test_when_finished "git -C local push --delete origin new-branch" &&
66 cp -r "$LOCAL_PRISTINE" local &&
67 git -C local pull --no-rebase origin &&
68 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
69 git -c protocol.version=$PROTO -C local push \
70 --receive-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-receive-pack" \
71 origin HEAD:new-branch &&
72 grep \"key\":\"server-sid\" tr2-client-events &&
73 grep \"key\":\"client-sid\" tr2-server-events
76 test_expect_success "client & server log negotiated version (v${PROTO})" '
77 test_when_finished "rm -rf local tr2-client-events tr2-server-events" &&
78 cp -r "$LOCAL_PRISTINE" local &&
79 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
80 git -c protocol.version=$PROTO -C local fetch \
81 --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \
82 origin &&
83 grep \"key\":\"negotiated-version\",\"value\":\"$PROTO\" tr2-client-events &&
84 grep \"key\":\"negotiated-version\",\"value\":\"$PROTO\" tr2-server-events
86 done
88 test_done