From 90ff150627e1f4fe9f34d0788b30564180926c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danilo=20Gon=C3=A7alves?= Date: Fri, 7 Aug 2020 20:15:53 -0300 Subject: [PATCH] add parameters to `AddUserToGroups` method --- default_api.go | 9 +++++++-- default_api_test.go | 7 ++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/default_api.go b/default_api.go index 2c574f1..0183218 100644 --- a/default_api.go +++ b/default_api.go @@ -128,7 +128,7 @@ func (a *DefaultApiService) AddUserToGroup() (*APIResponse, error) { Add a user to one or more groups. <p> The authenticated user must have the <strong>ADMIN</strong> permission to call this resource. @return */ -func (a *DefaultApiService) AddUserToGroups() (*APIResponse, error) { +func (a *DefaultApiService) AddUserToGroups(name string, groups []string) (*APIResponse, error) { var ( localVarHTTPMethod = strings.ToUpper("Post") localVarPostBody interface{} @@ -136,6 +136,11 @@ func (a *DefaultApiService) AddUserToGroups() (*APIResponse, error) { localVarFileBytes []byte ) + localVarPostBody = map[string]interface{}{ + "user": name, + "groups": groups, + } + // create path and map variables localVarPath := a.client.cfg.BasePath + "/api/1.0/admin/users/add-groups" @@ -175,7 +180,7 @@ func (a *DefaultApiService) AddUserToGroups() (*APIResponse, error) { return NewAPIResponseWithError(localVarHTTPResponse, bodyBytes, reportError("Status: %v, Body: %s", localVarHTTPResponse.Status, bodyBytes)) } - return NewBitbucketAPIResponse(localVarHTTPResponse) + return NewAPIResponse(localVarHTTPResponse), nil } /* DefaultApiService diff --git a/default_api_test.go b/default_api_test.go index c1c2d49..cb118d8 100644 --- a/default_api_test.go +++ b/default_api_test.go @@ -124,7 +124,8 @@ func TestDefaultApiService_AddUserToGroups(t *testing.T) { client *APIClient } type args struct { - ctx context.Context + name string + groups []string } tests := []struct { name string @@ -133,7 +134,7 @@ func TestDefaultApiService_AddUserToGroups(t *testing.T) { want *APIResponse wantErr, integrationTest bool }{ - {"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{ctx: context.Background()}, &APIResponse{Message: "Post https://stash.domain.com/rest/api/1.0/admin/users/add-groups: context canceled"}, true, false}, + {"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{name: "user", groups: []string{"group"}}, &APIResponse{Message: "Post https://stash.domain.com/rest/api/1.0/admin/users/add-groups: context canceled"}, true, false}, } for _, tt := range tests { if tt.integrationTest != runIntegrationTests { @@ -143,7 +144,7 @@ func TestDefaultApiService_AddUserToGroups(t *testing.T) { a := &DefaultApiService{ client: tt.fields.client, } - got, err := a.AddUserToGroups() + got, err := a.AddUserToGroups(tt.args.name, tt.args.groups) if (err != nil) != tt.wantErr { t.Errorf("DefaultApiService.AddUserToGroups() error = %v, wantErr %v", err, tt.wantErr) return