Skip to content

Commit

Permalink
Merge pull request #175 from ctreminiom/feature/jira-user-search-perm…
Browse files Browse the repository at this point in the history
…ission-project-error

🐛 Fixed the user.search.check method
  • Loading branch information
ctreminiom authored Mar 9, 2023
2 parents 6fce77e + 045d55c commit f2c043a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 12 additions & 12 deletions jira/internal/audit_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

Expand All @@ -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,
Expand All @@ -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)

Expand All @@ -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,
Expand All @@ -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"))

Expand All @@ -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,
Expand All @@ -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)

Expand Down
1 change: 1 addition & 0 deletions jira/internal/user_search_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
6 changes: 3 additions & 3 deletions jira/internal/user_search_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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"))

Expand Down

0 comments on commit f2c043a

Please sign in to comment.