mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-07-01 00:25:00 +02:00
fix: removing the use of username field in searching for users (#297)
This commit is contained in:
24
user_test.go
24
user_test.go
@ -11,7 +11,7 @@ func TestUserService_Get_Success(t *testing.T) {
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/user", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testRequestURL(t, r, "/rest/api/2/user?username=fred")
|
||||
testRequestURL(t, r, "/rest/api/2/user?accountId=000000000000000000000000")
|
||||
|
||||
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","key":"fred",
|
||||
"name":"fred","emailAddress":"fred@example.com","avatarUrls":{"48x48":"http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred",
|
||||
@ -22,7 +22,7 @@ func TestUserService_Get_Success(t *testing.T) {
|
||||
}]},"applicationRoles":{"size":1,"items":[]},"expand":"groups,applicationRoles"}`)
|
||||
})
|
||||
|
||||
if user, _, err := testClient.User.Get("fred"); err != nil {
|
||||
if user, _, err := testClient.User.Get("000000000000000000000000"); err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
} else if user == nil {
|
||||
t.Error("Expected user. User is nil")
|
||||
@ -84,12 +84,12 @@ func TestUserService_Delete(t *testing.T) {
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/user", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "DELETE")
|
||||
testRequestURL(t, r, "/rest/api/2/user?username=fred")
|
||||
testRequestURL(t, r, "/rest/api/2/user?accountId=000000000000000000000000")
|
||||
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
})
|
||||
|
||||
resp, err := testClient.User.Delete("fred")
|
||||
resp, err := testClient.User.Delete("000000000000000000000000")
|
||||
if err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
}
|
||||
@ -104,13 +104,13 @@ func TestUserService_GetGroups(t *testing.T) {
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/user/groups", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testRequestURL(t, r, "/rest/api/2/user/groups?username=fred")
|
||||
testRequestURL(t, r, "/rest/api/2/user/groups?accountId=000000000000000000000000")
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
fmt.Fprint(w, `[{"name":"jira-software-users","self":"http://www.example.com/jira/rest/api/2/user?username=fred"}]`)
|
||||
fmt.Fprint(w, `[{"name":"jira-software-users","self":"http://www.example.com/jira/rest/api/2/user?accountId=000000000000000000000000"}]`)
|
||||
})
|
||||
|
||||
if groups, _, err := testClient.User.GetGroups("fred"); err != nil {
|
||||
if groups, _, err := testClient.User.GetGroups("000000000000000000000000"); err != nil {
|
||||
t.Errorf("Error given: %s", err)
|
||||
} else if groups == nil {
|
||||
t.Error("Expected user groups. []UserGroup is nil")
|
||||
@ -125,7 +125,7 @@ func TestUserService_GetSelf(t *testing.T) {
|
||||
testRequestURL(t, r, "/rest/api/2/myself")
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","key":"fred",
|
||||
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/user?accountId=000000000000000000000000","key":"fred",
|
||||
"name":"fred","emailAddress":"fred@example.com","avatarUrls":{"48x48":"http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred",
|
||||
"24x24":"http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","16x16":"http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
|
||||
"32x32":"http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred"},"displayName":"Fred F. User","active":true,"timeZone":"Australia/Sydney","groups":{"size":3,"items":[
|
||||
@ -150,9 +150,9 @@ func TestUserService_Find_Success(t *testing.T) {
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/user/search", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testRequestURL(t, r, "/rest/api/2/user/search?username=fred@example.com")
|
||||
testRequestURL(t, r, "/rest/api/2/user/search?query=fred@example.com")
|
||||
|
||||
fmt.Fprint(w, `[{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","key":"fred",
|
||||
fmt.Fprint(w, `[{"self":"http://www.example.com/jira/rest/api/2/user?accountId=000000000000000000000000","key":"fred",
|
||||
"name":"fred","emailAddress":"fred@example.com","avatarUrls":{"48x48":"http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred",
|
||||
"24x24":"http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","16x16":"http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
|
||||
"32x32":"http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred"},"displayName":"Fred F. User","active":true,"timeZone":"Australia/Sydney","groups":{"size":3,"items":[
|
||||
@ -173,9 +173,9 @@ func TestUserService_Find_SuccessParams(t *testing.T) {
|
||||
defer teardown()
|
||||
testMux.HandleFunc("/rest/api/2/user/search", func(w http.ResponseWriter, r *http.Request) {
|
||||
testMethod(t, r, "GET")
|
||||
testRequestURL(t, r, "/rest/api/2/user/search?username=fred@example.com&startAt=100&maxResults=1000")
|
||||
testRequestURL(t, r, "/rest/api/2/user/search?query=fred@example.com&startAt=100&maxResults=1000")
|
||||
|
||||
fmt.Fprint(w, `[{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","key":"fred",
|
||||
fmt.Fprint(w, `[{"self":"http://www.example.com/jira/rest/api/2/user?query=fred","key":"fred",
|
||||
"name":"fred","emailAddress":"fred@example.com","avatarUrls":{"48x48":"http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred",
|
||||
"24x24":"http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","16x16":"http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
|
||||
"32x32":"http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred"},"displayName":"Fred F. User","active":true,"timeZone":"Australia/Sydney","groups":{"size":3,"items":[
|
||||
|
Reference in New Issue
Block a user