Repository: ctreminiom/go-atlassian
Pull request #175 (2023-03-08 00:16:51)

:bug: Fixed the user.search.check method


Patch:
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 5e633e2..617f2d9 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -35,7 +35,7 @@ jobs:
 
           # Optional: golangci-lint command line arguments.
           # args: --issues-exit-code=0
-          args: --timeout=3m
+          args: --timeout=5m
 
           # Optional: show only new issues if it's a pull request. The default value is `false`.
           # only-new-issues: true
\ No newline at end of file
diff --git a/jira/internal/user_search_impl.go b/jira/internal/user_search_impl.go
index efadd6b..b8a671f 100644
--- a/jira/internal/user_search_impl.go
+++ b/jira/internal/user_search_impl.go
@@ -81,6 +81,7 @@ func (i *internalUserSearchImpl) Check(ctx context.Context, permission string, o
 	params := url.Values{}
 	params.Add("startAt", strconv.Itoa(startAt))
 	params.Add("maxResults", strconv.Itoa(maxResults))
+	params.Add("permission", permission)
 
 	if options != nil {
 


Test patch:
diff --git a/jira/internal/audit_impl_test.go b/jira/internal/audit_impl_test.go
index cc70c62..8f872a1 100644
--- a/jira/internal/audit_impl_test.go
+++ b/jira/internal/audit_impl_test.go
@@ -40,8 +40,8 @@ func Test_internalAuditRecordImpl_Get(t *testing.T) {
 				ctx: context.Background(),
 				options: &model.AuditRecordGetOptions{
 					Filter: "summary",
-					From:   time.Now().AddDate(0, -2, 0),
-					To:     time.Now().AddDate(0, -1, 0),
+					From:   time.Date(2015, 11, 17, 20, 34, 58, 651387237, time.UTC),
+					To:     time.Date(2019, 11, 17, 20, 34, 58, 651387237, time.UTC),
 				},
 				offSet: 2000,
 				limit:  1000,
@@ -53,7 +53,7 @@ func Test_internalAuditRecordImpl_Get(t *testing.T) {
 				client.On("NewRequest",
 					context.Background(),
 					http.MethodGet,
-					"rest/api/2/auditing/record?=summary&from=2023-01-07&limit=1000&offset=2000&to=2023-02-07",
+					"rest/api/2/auditing/record?=summary&from=2015-11-17&limit=1000&offset=2000&to=2019-11-17",
 					nil).
 					Return(&http.Request{}, nil)
 
@@ -72,8 +72,8 @@ func Test_internalAuditRecordImpl_Get(t *testing.T) {
 				ctx: context.Background(),
 				options: &model.AuditRecordGetOptions{
 					Filter: "summary",
-					From:   time.Now().AddDate(0, -2, 0),
-					To:     time.Now().AddDate(0, -1, 0),
+					From:   time.Date(2015, 11, 17, 20, 34, 58, 651387237, time.UTC),
+					To:     time.Date(2019, 11, 17, 20, 34, 58, 651387237, time.UTC),
 				},
 				offSet: 2000,
 				limit:  1000,
@@ -85,7 +85,7 @@ func Test_internalAuditRecordImpl_Get(t *testing.T) {
 				client.On("NewRequest",
 					context.Background(),
 					http.MethodGet,
-					"rest/api/3/auditing/record?=summary&from=2023-01-07&limit=1000&offset=2000&to=2023-02-07",
+					"rest/api/3/auditing/record?=summary&from=2015-11-17&limit=1000&offset=2000&to=2019-11-17",
 					nil).
 					Return(&http.Request{}, nil)
 
@@ -105,8 +105,8 @@ func Test_internalAuditRecordImpl_Get(t *testing.T) {
 				ctx: context.Background(),
 				options: &model.AuditRecordGetOptions{
 					Filter: "summary",
-					From:   time.Now().AddDate(0, -2, 0),
-					To:     time.Now().AddDate(0, -1, 0),
+					From:   time.Date(2015, 11, 17, 20, 34, 58, 651387237, time.UTC),
+					To:     time.Date(2019, 11, 17, 20, 34, 58, 651387237, time.UTC),
 				},
 				offSet: 2000,
 				limit:  1000,
@@ -117,7 +117,7 @@ func Test_internalAuditRecordImpl_Get(t *testing.T) {
 				client.On("NewRequest",
 					context.Background(),
 					http.MethodGet,
-					"rest/api/2/auditing/record?=summary&from=2023-01-07&limit=1000&offset=2000&to=2023-02-07",
+					"rest/api/2/auditing/record?=summary&from=2015-11-17&limit=1000&offset=2000&to=2019-11-17",
 					nil).
 					Return(&http.Request{}, errors.New("unable to create the http request"))
 
@@ -134,8 +134,8 @@ func Test_internalAuditRecordImpl_Get(t *testing.T) {
 				ctx: context.Background(),
 				options: &model.AuditRecordGetOptions{
 					Filter: "summary",
-					From:   time.Now().AddDate(0, -2, 0),
-					To:     time.Now().AddDate(0, -1, 0),
+					From:   time.Date(2015, 11, 17, 20, 34, 58, 651387237, time.UTC),
+					To:     time.Date(2019, 11, 17, 20, 34, 58, 651387237, time.UTC),
 				},
 				offSet: 2000,
 				limit:  1000,
@@ -146,7 +146,7 @@ func Test_internalAuditRecordImpl_Get(t *testing.T) {
 				client.On("NewRequest",
 					context.Background(),
 					http.MethodGet,
-					"rest/api/2/auditing/record?=summary&from=2023-01-07&limit=1000&offset=2000&to=2023-02-07",
+					"rest/api/2/auditing/record?=summary&from=2015-11-17&limit=1000&offset=2000&to=2019-11-17",
 					nil).
 					Return(&http.Request{}, nil)
 
diff --git a/jira/internal/user_search_impl_test.go b/jira/internal/user_search_impl_test.go
index 01a60e3..e862a31 100644
--- a/jira/internal/user_search_impl_test.go
+++ b/jira/internal/user_search_impl_test.go
@@ -359,7 +359,7 @@ func Test_internalUserSearchImpl_Check(t *testing.T) {
 				client.On("NewRequest",
 					context.Background(),
 					http.MethodGet,
-					"rest/api/3/user/permission/search?accountId=uuid-sample&issueKey=DFUMM-1&maxResults=50&projectKey=DUMMY&query=project+A&startAt=100",
+					"rest/api/3/user/permission/search?accountId=uuid-sample&issueKey=DFUMM-1&maxResults=50&permission=CREATE_ISSUES&projectKey=DUMMY&query=project+A&startAt=100",
 					nil).
 					Return(&http.Request{}, nil)
 
@@ -410,7 +410,7 @@ func Test_internalUserSearchImpl_Check(t *testing.T) {
 				client.On("NewRequest",
 					context.Background(),
 					http.MethodGet,
-					"rest/api/2/user/permission/search?accountId=uuid-sample&issueKey=DFUMM-1&maxResults=50&projectKey=DUMMY&query=project+A&startAt=100",
+					"rest/api/2/user/permission/search?accountId=uuid-sample&issueKey=DFUMM-1&maxResults=50&permission=CREATE_ISSUES&projectKey=DUMMY&query=project+A&startAt=100",
 					nil).
 					Return(&http.Request{}, nil)
 
@@ -447,7 +447,7 @@ func Test_internalUserSearchImpl_Check(t *testing.T) {
 				client.On("NewRequest",
 					context.Background(),
 					http.MethodGet,
-					"rest/api/3/user/permission/search?accountId=uuid-sample&issueKey=DFUMM-1&maxResults=50&projectKey=DUMMY&query=project+A&startAt=100",
+					"rest/api/3/user/permission/search?accountId=uuid-sample&issueKey=DFUMM-1&maxResults=50&permission=CREATE_ISSUES&projectKey=DUMMY&query=project+A&startAt=100",
 					nil).
 					Return(&http.Request{}, errors.New("error, unable to create the http request"))