3 test_description
='session ID in capabilities'
5 TEST_PASSES_SANITIZE_LEAK
=true
9 LOCAL_PRISTINE
="$(pwd)/local_pristine"
11 test_expect_success
'setup repos for session ID capability tests' '
13 test_commit -C "$REPO" a &&
14 git clone "file://$REPO" "$LOCAL_PRISTINE" &&
15 test_commit -C "$REPO" b
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" \
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)"
45 test_expect_success
'enable SID advertisement' '
46 git -C "$REPO" config transfer.advertiseSID true &&
47 git -C "$LOCAL_PRISTINE" config transfer.advertiseSID true
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" \
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" \
83 grep \"key\":\"negotiated-version\",\"value\":\"$PROTO\" tr2-client-events &&
84 grep \"key\":\"negotiated-version\",\"value\":\"$PROTO\" tr2-server-events