diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2020-04-17 16:23:12 +1000 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2020-04-17 16:23:33 +1000 |
commit | 4f4acf4a1e523678355b06234016fa632bae282e (patch) | |
tree | 17f7c90485d0a339e5ecb14fb6131a4c2636903d /internal/gitlabnet/accessverifier/client_test.go | |
parent | 118143ba6c49573d1437f99cf2b44168bd09b8d1 (diff) | |
download | gitlab-shell-4f4acf4a1e523678355b06234016fa632bae282e.tar.gz |
Geo Pull custom action support
Diffstat (limited to 'internal/gitlabnet/accessverifier/client_test.go')
-rw-r--r-- | internal/gitlabnet/accessverifier/client_test.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/internal/gitlabnet/accessverifier/client_test.go b/internal/gitlabnet/accessverifier/client_test.go index 888ea1c..009dcc0 100644 --- a/internal/gitlabnet/accessverifier/client_test.go +++ b/internal/gitlabnet/accessverifier/client_test.go @@ -20,6 +20,7 @@ import ( var ( repo = "group/private" receivePackAction = commandargs.ReceivePack + uploadPackAction = commandargs.UploadPack ) func buildExpectedResponse(who string) *Response { @@ -94,7 +95,30 @@ func TestGeoPushGetCustomAction(t *testing.T) { response.Payload = CustomPayload{ Action: "geo_proxy_to_primary", Data: CustomPayloadData{ - ApiEndpoints: []string{"geo/proxy_git_push_ssh/info_refs", "geo/proxy_git_push_ssh/push"}, + ApiEndpoints: []string{"geo/proxy_git_ssh/info_refs_receive_pack", "geo/proxy_git_ssh/receive_pack"}, + Username: "custom", + PrimaryRepo: "https://repo/path", + }, + } + response.StatusCode = 300 + + require.True(t, response.IsCustomAction()) + require.Equal(t, response, result) +} + +func TestGeoPullGetCustomAction(t *testing.T) { + client, cleanup := setup(t, "responses/allowed_with_pull_payload.json") + defer cleanup() + + args := &commandargs.Shell{GitlabUsername: "custom"} + result, err := client.Verify(args, uploadPackAction, repo) + require.NoError(t, err) + + response := buildExpectedResponse("user-1") + response.Payload = CustomPayload{ + Action: "geo_proxy_to_primary", + Data: CustomPayloadData{ + ApiEndpoints: []string{"geo/proxy_git_ssh/info_refs_upload_pack", "geo/proxy_git_ssh/upload_pack"}, Username: "custom", PrimaryRepo: "https://repo/path", }, |