add parameters to AddUserToGroups method

This commit is contained in:
Danilo Gonçalves 2020-08-07 20:15:53 -03:00
parent a1f7d4e0d6
commit 90ff150627
2 changed files with 11 additions and 5 deletions

View File

@ -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

View File

@ -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