diff --git a/services.go b/services.go index 0b874ebfb..a7eeb72d3 100644 --- a/services.go +++ b/services.go @@ -1182,7 +1182,7 @@ type SetJiraServiceOptions struct { JiraAuthType *int `url:"jira_auth_type,omitempty" json:"jira_auth_type,omitempty"` JiraIssuePrefix *string `url:"jira_issue_prefix,omitempty" json:"jira_issue_prefix,omitempty"` JiraIssueRegex *string `url:"jira_issue_regex,omitempty" json:"jira_issue_regex,omitempty"` - JiraIssueTransitionAutomatic *string `url:"jira_issue_transition_automatic,omitempty" json:"jira_issue_transition_automatic,omitempty"` + JiraIssueTransitionAutomatic *bool `url:"jira_issue_transition_automatic,omitempty" json:"jira_issue_transition_automatic,omitempty"` JiraIssueTransitionID *string `url:"jira_issue_transition_id,omitempty" json:"jira_issue_transition_id,omitempty"` CommitEvents *bool `url:"commit_events,omitempty" json:"commit_events,omitempty"` MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` diff --git a/services_test.go b/services_test.go index be9c2f913..69d2bfcdd 100644 --- a/services_test.go +++ b/services_test.go @@ -441,16 +441,21 @@ func TestSetJiraService(t *testing.T) { }) opt := &SetJiraServiceOptions{ - URL: Ptr("asd"), - APIURL: Ptr("asd"), - ProjectKey: Ptr("as"), - Username: Ptr("aas"), - Password: Ptr("asd"), - Active: Ptr(true), - JiraIssueTransitionID: Ptr("2,3"), - CommitEvents: Ptr(true), - CommentOnEventEnabled: Ptr(true), - MergeRequestsEvents: Ptr(true), + URL: Ptr("asd"), + APIURL: Ptr("asd"), + ProjectKey: Ptr("as"), + Username: Ptr("aas"), + Password: Ptr("asd"), + Active: Ptr(true), + JiraIssuePrefix: Ptr("ASD"), + JiraIssueRegex: Ptr("ASD"), + JiraIssueTransitionAutomatic: Ptr(true), + JiraIssueTransitionID: Ptr("2,3"), + CommitEvents: Ptr(true), + MergeRequestsEvents: Ptr(true), + CommentOnEventEnabled: Ptr(true), + IssuesEnabled: Ptr(true), + UseInheritedSettings: Ptr(true), } _, err := client.Services.SetJiraService(1, opt) @@ -467,16 +472,60 @@ func TestSetJiraServiceProjecKeys(t *testing.T) { }) opt := &SetJiraServiceOptions{ - URL: Ptr("asd"), - APIURL: Ptr("asd"), - ProjectKeys: Ptr([]string{"as"}), - Username: Ptr("aas"), - Password: Ptr("asd"), - Active: Ptr(true), - JiraIssueTransitionID: Ptr("2,3"), - CommitEvents: Ptr(true), - CommentOnEventEnabled: Ptr(true), - MergeRequestsEvents: Ptr(true), + URL: Ptr("asd"), + APIURL: Ptr("asd"), + Username: Ptr("aas"), + Password: Ptr("asd"), + Active: Ptr(true), + JiraIssuePrefix: Ptr("ASD"), + JiraIssueRegex: Ptr("ASD"), + JiraIssueTransitionAutomatic: Ptr(true), + JiraIssueTransitionID: Ptr("2,3"), + CommitEvents: Ptr(true), + MergeRequestsEvents: Ptr(true), + CommentOnEventEnabled: Ptr(true), + IssuesEnabled: Ptr(true), + ProjectKeys: Ptr([]string{"as"}), + UseInheritedSettings: Ptr(true), + } + + _, err := client.Services.SetJiraService(1, opt) + if err != nil { + t.Fatalf("Services.SetJiraService returns an error: %v", err) + } +} + +func TestSetJiraServiceAuthTypeBasicAuth(t *testing.T) { + mux, client := setup(t) + + mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, http.MethodPut) + }) + + opt := &SetJiraServiceOptions{ + URL: Ptr("asd"), + Username: Ptr("aas"), + Password: Ptr("asd"), + JiraAuthType: Ptr(0), + } + + _, err := client.Services.SetJiraService(1, opt) + if err != nil { + t.Fatalf("Services.SetJiraService returns an error: %v", err) + } +} + +func TestSetJiraServiceAuthTypeTokenAuth(t *testing.T) { + mux, client := setup(t) + + mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, http.MethodPut) + }) + + opt := &SetJiraServiceOptions{ + URL: Ptr("asd"), + Password: Ptr("asd"), + JiraAuthType: Ptr(1), } _, err := client.Services.SetJiraService(1, opt)