From 23bf486acae1a15bb214ab2004876533f6c73f96 Mon Sep 17 00:00:00 2001 From: Josh Steadmon Date: Wed, 11 Nov 2020 15:29:30 -0800 Subject: transport: log received server session ID When a client receives a session-id capability from a protocol v0, v1, or v2 server, log the received session ID via a trace2 data event. Signed-off-by: Josh Steadmon Signed-off-by: Junio C Hamano --- t/t5705-session-id-in-capabilities.sh | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 t/t5705-session-id-in-capabilities.sh (limited to 't') diff --git a/t/t5705-session-id-in-capabilities.sh b/t/t5705-session-id-in-capabilities.sh new file mode 100755 index 0000000000..9e782f4413 --- /dev/null +++ b/t/t5705-session-id-in-capabilities.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +test_description='session ID in capabilities' + +. ./test-lib.sh + +REPO="$(pwd)/repo" +LOCAL_PRISTINE="$(pwd)/local_pristine" + +test_expect_success 'setup repos for session ID capability tests' ' + git init "$REPO" && + test_commit -C "$REPO" a && + git clone "file://$REPO" "$LOCAL_PRISTINE" && + test_commit -C "$REPO" b +' + +for PROTO in 0 1 2 +do + test_expect_success "session IDs not advertised by default (fetch v${PROTO})" ' + test_when_finished "rm -rf local tr2-client-events" && + cp -r "$LOCAL_PRISTINE" local && + GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ + git -c protocol.version=$PROTO -C local fetch origin && + test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" + ' + + test_expect_success "session IDs not advertised by default (push v${PROTO})" ' + test_when_finished "rm -rf local tr2-client-events" && + cp -r "$LOCAL_PRISTINE" local && + git -C local pull --no-rebase origin && + GIT_TRACE2_EVENT_NESTING=5 \ + GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ + git -c protocol.version=$PROTO -C local push origin && + test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" + ' +done + +test_expect_success 'enable SID advertisement' ' + git -C "$REPO" config transfer.advertiseSID true && + git -C "$LOCAL_PRISTINE" config transfer.advertiseSID true +' + +for PROTO in 0 1 2 +do + test_expect_success "session IDs advertised (fetch v${PROTO})" ' + test_when_finished "rm -rf local tr2-client-events" && + cp -r "$LOCAL_PRISTINE" local && + GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ + git -c protocol.version=$PROTO -C local fetch origin && + grep \"key\":\"server-sid\" tr2-client-events + ' + + test_expect_success "session IDs advertised (push v${PROTO})" ' + test_when_finished "rm -rf local tr2-client-events" && + cp -r "$LOCAL_PRISTINE" local && + git -C local pull --no-rebase origin && + GIT_TRACE2_EVENT_NESTING=5 \ + GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ + git -c protocol.version=$PROTO -C local push origin && + grep \"key\":\"server-sid\" tr2-client-events + ' +done + +test_done -- cgit v1.2.3 From 829594677c3cd02f7d88b3cd3c72ad06f68faa14 Mon Sep 17 00:00:00 2001 From: Josh Steadmon Date: Wed, 11 Nov 2020 15:29:32 -0800 Subject: upload-pack, serve: log received client session ID When upload-pack (protocol v0/v1) or a protocol v2 server receives a session-id capability from a client, log the received session ID via a trace2 data event. Signed-off-by: Josh Steadmon Signed-off-by: Junio C Hamano --- t/t5705-session-id-in-capabilities.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 't') diff --git a/t/t5705-session-id-in-capabilities.sh b/t/t5705-session-id-in-capabilities.sh index 9e782f4413..afa2159657 100755 --- a/t/t5705-session-id-in-capabilities.sh +++ b/t/t5705-session-id-in-capabilities.sh @@ -17,11 +17,14 @@ test_expect_success 'setup repos for session ID capability tests' ' for PROTO in 0 1 2 do test_expect_success "session IDs not advertised by default (fetch v${PROTO})" ' - test_when_finished "rm -rf local tr2-client-events" && + test_when_finished "rm -rf local tr2-client-events tr2-server-events" && cp -r "$LOCAL_PRISTINE" local && GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ - git -c protocol.version=$PROTO -C local fetch origin && - test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" + git -c protocol.version=$PROTO -C local fetch \ + --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \ + origin && + test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" && + test -z "$(grep \"key\":\"client-sid\" tr2-server-events)" ' test_expect_success "session IDs not advertised by default (push v${PROTO})" ' @@ -43,11 +46,14 @@ test_expect_success 'enable SID advertisement' ' for PROTO in 0 1 2 do test_expect_success "session IDs advertised (fetch v${PROTO})" ' - test_when_finished "rm -rf local tr2-client-events" && + test_when_finished "rm -rf local tr2-client-events tr2-server-events" && cp -r "$LOCAL_PRISTINE" local && GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ - git -c protocol.version=$PROTO -C local fetch origin && - grep \"key\":\"server-sid\" tr2-client-events + git -c protocol.version=$PROTO -C local fetch \ + --upload-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-upload-pack" \ + origin && + grep \"key\":\"server-sid\" tr2-client-events && + grep \"key\":\"client-sid\" tr2-server-events ' test_expect_success "session IDs advertised (push v${PROTO})" ' -- cgit v1.2.3 From a2a066d96aeaa13fe9124b84978d333243aa17c9 Mon Sep 17 00:00:00 2001 From: Josh Steadmon Date: Wed, 11 Nov 2020 15:29:34 -0800 Subject: receive-pack: log received client session ID When receive-pack receives a session-id capability from the client, log the received session ID via a trace2 data event. Signed-off-by: Josh Steadmon Signed-off-by: Junio C Hamano --- t/t5705-session-id-in-capabilities.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 't') diff --git a/t/t5705-session-id-in-capabilities.sh b/t/t5705-session-id-in-capabilities.sh index afa2159657..f1d189d5bc 100755 --- a/t/t5705-session-id-in-capabilities.sh +++ b/t/t5705-session-id-in-capabilities.sh @@ -28,13 +28,17 @@ do ' test_expect_success "session IDs not advertised by default (push v${PROTO})" ' - test_when_finished "rm -rf local tr2-client-events" && + test_when_finished "rm -rf local tr2-client-events tr2-server-events" && + test_when_finished "git -C local push --delete origin new-branch" && cp -r "$LOCAL_PRISTINE" local && git -C local pull --no-rebase origin && GIT_TRACE2_EVENT_NESTING=5 \ GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ - git -c protocol.version=$PROTO -C local push origin && - test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" + git -c protocol.version=$PROTO -C local push \ + --receive-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-receive-pack" \ + origin HEAD:new-branch && + test -z "$(grep \"key\":\"server-sid\" tr2-client-events)" && + test -z "$(grep \"key\":\"client-sid\" tr2-server-events)" ' done @@ -57,13 +61,17 @@ do ' test_expect_success "session IDs advertised (push v${PROTO})" ' - test_when_finished "rm -rf local tr2-client-events" && + test_when_finished "rm -rf local tr2-client-events tr2-server-events" && + test_when_finished "git -C local push --delete origin new-branch" && cp -r "$LOCAL_PRISTINE" local && git -C local pull --no-rebase origin && GIT_TRACE2_EVENT_NESTING=5 \ GIT_TRACE2_EVENT="$(pwd)/tr2-client-events" \ - git -c protocol.version=$PROTO -C local push origin && - grep \"key\":\"server-sid\" tr2-client-events + git -c protocol.version=$PROTO -C local push \ + --receive-pack "GIT_TRACE2_EVENT=\"$(pwd)/tr2-server-events\" git-receive-pack" \ + origin HEAD:new-branch && + grep \"key\":\"server-sid\" tr2-client-events && + grep \"key\":\"client-sid\" tr2-server-events ' done -- cgit v1.2.3