Loading system_hooks.go +9 −0 Changes for system_hooks.go: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -98,7 +98,14 @@ type Hook struct { MergeRequestsEvents bool `json:"merge_requests_events"` RepositoryUpdateEvents bool `json:"repository_update_events"` EnableSSLVerification bool `json:"enable_ssl_verification"` OrganizationID int64 `json:"organization_id"` AlertStatus string `json:"alert_status"` DisabledUntil *time.Time `json:"disabled_until"` URLVariables []HookURLVariable `json:"url_variables"` PushEventsBranchFilter string `json:"push_events_branch_filter"` BranchFilterStrategy string `json:"branch_filter_strategy"` CustomWebhookTemplate string `json:"custom_webhook_template"` CustomHeaders []HookCustomHeader `json:"custom_headers"` TokenPresent bool `json:"token_present"` SigningTokenPresent bool `json:"signing_token_present"` } Loading Loading @@ -132,6 +139,7 @@ type AddHookOptions struct { PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` PushEventsBranchFilter *string `url:"push_events_branch_filter,omitempty" json:"push_events_branch_filter,omitempty"` BranchFilterStrategy *BranchFilterStrategy `url:"branch_filter_strategy,omitempty" json:"branch_filter_strategy,omitempty"` CustomWebhookTemplate *string `url:"custom_webhook_template,omitempty" json:"custom_webhook_template,omitempty"` TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` RepositoryUpdateEvents *bool `url:"repository_update_events,omitempty" json:"repository_update_events,omitempty"` Loading Loading @@ -161,6 +169,7 @@ type EditHookOptions struct { PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` PushEventsBranchFilter *string `url:"push_events_branch_filter,omitempty" json:"push_events_branch_filter,omitempty"` BranchFilterStrategy *BranchFilterStrategy `url:"branch_filter_strategy,omitempty" json:"branch_filter_strategy,omitempty"` CustomWebhookTemplate *string `url:"custom_webhook_template,omitempty" json:"custom_webhook_template,omitempty"` TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` RepositoryUpdateEvents *bool `url:"repository_update_events,omitempty" json:"repository_update_events,omitempty"` Loading system_hooks_test.go +38 −1 Changes for system_hooks_test.go: 38 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -71,7 +71,14 @@ func TestSystemHooksService_GetHook(t *testing.T) { "merge_requests_events": true, "repository_update_events": true, "enable_ssl_verification":true, "url_variables":[{"key":"abc","value":"def"}] "organization_id":1, "alert_status":"executable", "disabled_until":"2016-11-30T12:32:15.192Z", "url_variables":[{"key":"abc","value":"def"}], "push_events_branch_filter":"my-branch-*", "branch_filter_strategy":"wildcard", "custom_webhook_template":"{\"event\":\"{{object_kind}}\"}", "custom_headers":[{"key":"X-Custom-Header"}] }`) }) Loading @@ -79,6 +86,7 @@ func TestSystemHooksService_GetHook(t *testing.T) { require.NoError(t, err) createdAt := time.Date(2016, time.October, 31, 12, 32, 15, 192000000, time.UTC) disabledUntil := time.Date(2016, time.November, 30, 12, 32, 15, 192000000, time.UTC) want := &Hook{ ID: 1, URL: "https://gitlab.example.com/hook", Loading @@ -90,7 +98,16 @@ func TestSystemHooksService_GetHook(t *testing.T) { MergeRequestsEvents: true, RepositoryUpdateEvents: true, EnableSSLVerification: true, OrganizationID: 1, AlertStatus: "executable", DisabledUntil: &disabledUntil, URLVariables: []HookURLVariable{{Key: "abc", Value: "def"}}, PushEventsBranchFilter: "my-branch-*", BranchFilterStrategy: "wildcard", CustomWebhookTemplate: `{"event":"{{object_kind}}"}`, // GitLab renders custom headers through masked_custom_headers, which // sends the key alone and no value, so Value stays empty here. CustomHeaders: []HookCustomHeader{{Key: "X-Custom-Header"}}, } require.Equal(t, want, hooks) } Loading @@ -101,11 +118,18 @@ func TestSystemHooksService_AddHook(t *testing.T) { mux.HandleFunc("/api/v4/hooks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testBodyJSON(t, r, map[string]any{ "url": "https://gitlab.example.com/hook", "name": "Test Hook", "description": "A test hook", "custom_webhook_template": `{"event":"{{object_kind}}"}`, }) fmt.Fprint(w, `{ "id": 1, "url": "https://gitlab.example.com/hook", "name": "Test Hook", "description": "A test hook", "custom_webhook_template": "{\"event\":\"{{object_kind}}\"}", "url_variables": [{"key": "abc", "value": "def"}] }`) }) Loading @@ -114,6 +138,7 @@ func TestSystemHooksService_AddHook(t *testing.T) { URL: new("https://gitlab.example.com/hook"), Name: new("Test Hook"), Description: new("A test hook"), CustomWebhookTemplate: new(`{"event":"{{object_kind}}"}`), } hook, _, err := client.SystemHooks.AddHook(opt) Loading @@ -124,6 +149,7 @@ func TestSystemHooksService_AddHook(t *testing.T) { URL: "https://gitlab.example.com/hook", Name: "Test Hook", Description: "A test hook", CustomWebhookTemplate: `{"event":"{{object_kind}}"}`, URLVariables: []HookURLVariable{{Key: "abc", Value: "def"}}, } require.Equal(t, want, hook) Loading @@ -135,11 +161,20 @@ func TestSystemHooksService_EditHook(t *testing.T) { mux.HandleFunc("/api/v4/hooks/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) testBodyJSON(t, r, map[string]any{ "url": "https://gitlab.example.com/hook", "name": "Test Hook", "description": "An updated test hook", "custom_webhook_template": `{"event":"{{object_kind}}"}`, "token": "supersecret", "signing_token": "whsec_abc", }) fmt.Fprint(w, `{ "id": 1, "url": "https://gitlab.example.com/hook", "name": "Test Hook", "description": "An updated test hook", "custom_webhook_template": "{\"event\":\"{{object_kind}}\"}", "token_present": true, "signing_token_present": true, "url_variables": [{"key": "abc", "value": "def"}] Loading @@ -150,6 +185,7 @@ func TestSystemHooksService_EditHook(t *testing.T) { URL: new("https://gitlab.example.com/hook"), Name: new("Test Hook"), Description: new("An updated test hook"), CustomWebhookTemplate: new(`{"event":"{{object_kind}}"}`), Token: new("supersecret"), SigningToken: new("whsec_abc"), } Loading @@ -162,6 +198,7 @@ func TestSystemHooksService_EditHook(t *testing.T) { URL: "https://gitlab.example.com/hook", Name: "Test Hook", Description: "An updated test hook", CustomWebhookTemplate: `{"event":"{{object_kind}}"}`, TokenPresent: true, SigningTokenPresent: true, URLVariables: []HookURLVariable{{Key: "abc", Value: "def"}}, Loading Loading
system_hooks.go +9 −0 Changes for system_hooks.go: 9 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -98,7 +98,14 @@ type Hook struct { MergeRequestsEvents bool `json:"merge_requests_events"` RepositoryUpdateEvents bool `json:"repository_update_events"` EnableSSLVerification bool `json:"enable_ssl_verification"` OrganizationID int64 `json:"organization_id"` AlertStatus string `json:"alert_status"` DisabledUntil *time.Time `json:"disabled_until"` URLVariables []HookURLVariable `json:"url_variables"` PushEventsBranchFilter string `json:"push_events_branch_filter"` BranchFilterStrategy string `json:"branch_filter_strategy"` CustomWebhookTemplate string `json:"custom_webhook_template"` CustomHeaders []HookCustomHeader `json:"custom_headers"` TokenPresent bool `json:"token_present"` SigningTokenPresent bool `json:"signing_token_present"` } Loading Loading @@ -132,6 +139,7 @@ type AddHookOptions struct { PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` PushEventsBranchFilter *string `url:"push_events_branch_filter,omitempty" json:"push_events_branch_filter,omitempty"` BranchFilterStrategy *BranchFilterStrategy `url:"branch_filter_strategy,omitempty" json:"branch_filter_strategy,omitempty"` CustomWebhookTemplate *string `url:"custom_webhook_template,omitempty" json:"custom_webhook_template,omitempty"` TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` RepositoryUpdateEvents *bool `url:"repository_update_events,omitempty" json:"repository_update_events,omitempty"` Loading Loading @@ -161,6 +169,7 @@ type EditHookOptions struct { PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` PushEventsBranchFilter *string `url:"push_events_branch_filter,omitempty" json:"push_events_branch_filter,omitempty"` BranchFilterStrategy *BranchFilterStrategy `url:"branch_filter_strategy,omitempty" json:"branch_filter_strategy,omitempty"` CustomWebhookTemplate *string `url:"custom_webhook_template,omitempty" json:"custom_webhook_template,omitempty"` TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` RepositoryUpdateEvents *bool `url:"repository_update_events,omitempty" json:"repository_update_events,omitempty"` Loading
system_hooks_test.go +38 −1 Changes for system_hooks_test.go: 38 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -71,7 +71,14 @@ func TestSystemHooksService_GetHook(t *testing.T) { "merge_requests_events": true, "repository_update_events": true, "enable_ssl_verification":true, "url_variables":[{"key":"abc","value":"def"}] "organization_id":1, "alert_status":"executable", "disabled_until":"2016-11-30T12:32:15.192Z", "url_variables":[{"key":"abc","value":"def"}], "push_events_branch_filter":"my-branch-*", "branch_filter_strategy":"wildcard", "custom_webhook_template":"{\"event\":\"{{object_kind}}\"}", "custom_headers":[{"key":"X-Custom-Header"}] }`) }) Loading @@ -79,6 +86,7 @@ func TestSystemHooksService_GetHook(t *testing.T) { require.NoError(t, err) createdAt := time.Date(2016, time.October, 31, 12, 32, 15, 192000000, time.UTC) disabledUntil := time.Date(2016, time.November, 30, 12, 32, 15, 192000000, time.UTC) want := &Hook{ ID: 1, URL: "https://gitlab.example.com/hook", Loading @@ -90,7 +98,16 @@ func TestSystemHooksService_GetHook(t *testing.T) { MergeRequestsEvents: true, RepositoryUpdateEvents: true, EnableSSLVerification: true, OrganizationID: 1, AlertStatus: "executable", DisabledUntil: &disabledUntil, URLVariables: []HookURLVariable{{Key: "abc", Value: "def"}}, PushEventsBranchFilter: "my-branch-*", BranchFilterStrategy: "wildcard", CustomWebhookTemplate: `{"event":"{{object_kind}}"}`, // GitLab renders custom headers through masked_custom_headers, which // sends the key alone and no value, so Value stays empty here. CustomHeaders: []HookCustomHeader{{Key: "X-Custom-Header"}}, } require.Equal(t, want, hooks) } Loading @@ -101,11 +118,18 @@ func TestSystemHooksService_AddHook(t *testing.T) { mux.HandleFunc("/api/v4/hooks", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) testBodyJSON(t, r, map[string]any{ "url": "https://gitlab.example.com/hook", "name": "Test Hook", "description": "A test hook", "custom_webhook_template": `{"event":"{{object_kind}}"}`, }) fmt.Fprint(w, `{ "id": 1, "url": "https://gitlab.example.com/hook", "name": "Test Hook", "description": "A test hook", "custom_webhook_template": "{\"event\":\"{{object_kind}}\"}", "url_variables": [{"key": "abc", "value": "def"}] }`) }) Loading @@ -114,6 +138,7 @@ func TestSystemHooksService_AddHook(t *testing.T) { URL: new("https://gitlab.example.com/hook"), Name: new("Test Hook"), Description: new("A test hook"), CustomWebhookTemplate: new(`{"event":"{{object_kind}}"}`), } hook, _, err := client.SystemHooks.AddHook(opt) Loading @@ -124,6 +149,7 @@ func TestSystemHooksService_AddHook(t *testing.T) { URL: "https://gitlab.example.com/hook", Name: "Test Hook", Description: "A test hook", CustomWebhookTemplate: `{"event":"{{object_kind}}"}`, URLVariables: []HookURLVariable{{Key: "abc", Value: "def"}}, } require.Equal(t, want, hook) Loading @@ -135,11 +161,20 @@ func TestSystemHooksService_EditHook(t *testing.T) { mux.HandleFunc("/api/v4/hooks/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) testBodyJSON(t, r, map[string]any{ "url": "https://gitlab.example.com/hook", "name": "Test Hook", "description": "An updated test hook", "custom_webhook_template": `{"event":"{{object_kind}}"}`, "token": "supersecret", "signing_token": "whsec_abc", }) fmt.Fprint(w, `{ "id": 1, "url": "https://gitlab.example.com/hook", "name": "Test Hook", "description": "An updated test hook", "custom_webhook_template": "{\"event\":\"{{object_kind}}\"}", "token_present": true, "signing_token_present": true, "url_variables": [{"key": "abc", "value": "def"}] Loading @@ -150,6 +185,7 @@ func TestSystemHooksService_EditHook(t *testing.T) { URL: new("https://gitlab.example.com/hook"), Name: new("Test Hook"), Description: new("An updated test hook"), CustomWebhookTemplate: new(`{"event":"{{object_kind}}"}`), Token: new("supersecret"), SigningToken: new("whsec_abc"), } Loading @@ -162,6 +198,7 @@ func TestSystemHooksService_EditHook(t *testing.T) { URL: "https://gitlab.example.com/hook", Name: "Test Hook", Description: "An updated test hook", CustomWebhookTemplate: `{"event":"{{object_kind}}"}`, TokenPresent: true, SigningTokenPresent: true, URLVariables: []HookURLVariable{{Key: "abc", Value: "def"}}, Loading