transport: log received server session ID
[git] / t / t5705-session-id-in-capabilities.sh
1 #!/bin/sh
2
3 test_description='session ID in capabilities'
4
5 . ./test-lib.sh
6
7 REPO="$(pwd)/repo"
8 LOCAL_PRISTINE="$(pwd)/local_pristine"
9
10 test_expect_success 'setup repos for session ID capability tests' '
11         git init "$REPO" &&
12         test_commit -C "$REPO" a &&
13         git clone "file://$REPO" "$LOCAL_PRISTINE" &&
14         test_commit -C "$REPO" b
15 '
16
17 for PROTO in 0 1 2
18 do
19         test_expect_success "session IDs not advertised by default (fetch v${PROTO})" '
20                 test_when_finished "rm -rf local tr2-client-events" &&
21                 cp -r "$LOCAL_PRISTINE" local &&
22                 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
23                 git -c protocol.version=$PROTO -C local fetch origin &&
24                 test -z "$(grep \"key\":\"server-sid\" tr2-client-events)"
25         '
26
27         test_expect_success "session IDs not advertised by default (push v${PROTO})" '
28                 test_when_finished "rm -rf local tr2-client-events" &&
29                 cp -r "$LOCAL_PRISTINE" local &&
30                 git -C local pull --no-rebase origin &&
31                 GIT_TRACE2_EVENT_NESTING=5 \
32                 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
33                 git -c protocol.version=$PROTO -C local push origin &&
34                 test -z "$(grep \"key\":\"server-sid\" tr2-client-events)"
35         '
36 done
37
38 test_expect_success 'enable SID advertisement' '
39         git -C "$REPO" config transfer.advertiseSID true &&
40         git -C "$LOCAL_PRISTINE" config transfer.advertiseSID true
41 '
42
43 for PROTO in 0 1 2
44 do
45         test_expect_success "session IDs advertised (fetch v${PROTO})" '
46                 test_when_finished "rm -rf local tr2-client-events" &&
47                 cp -r "$LOCAL_PRISTINE" local &&
48                 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
49                 git -c protocol.version=$PROTO -C local fetch origin &&
50                 grep \"key\":\"server-sid\" tr2-client-events
51         '
52
53         test_expect_success "session IDs advertised (push v${PROTO})" '
54                 test_when_finished "rm -rf local tr2-client-events" &&
55                 cp -r "$LOCAL_PRISTINE" local &&
56                 git -C local pull --no-rebase origin &&
57                 GIT_TRACE2_EVENT_NESTING=5 \
58                 GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \
59                 git -c protocol.version=$PROTO -C local push origin &&
60                 grep \"key\":\"server-sid\" tr2-client-events
61         '
62 done
63
64 test_done