Merge pull request #37 from yareda/setpermissionforuser

Fix for missing project and repositorySlug on SetPermissionForUser function
This commit is contained in:
George Fleury 2019-12-31 11:10:31 +01:00 committed by GitHub
commit 0c2de535d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -9699,11 +9699,13 @@ func (a *DefaultApiService) SetPermissionForGroups_32(localVarOptionals map[stri
/* DefaultApiService /* DefaultApiService
Promote or demote a user's permission level for the specified repository. Available repository permissions are: <ul> <li>REPO_READ</li> <li>REPO_WRITE</li> <li>REPO_ADMIN</li> </ul> See the <a href=\"https://confluence.atlassian.com/display/BitbucketServer/Using+repository+permissions\">Bitbucket Server documentation</a> for a detailed explanation of what each permission entails. <p> The authenticated user must have <strong>REPO_ADMIN</strong> permission for the specified repository or a higher project or global permission to call this resource. In addition, a user may not reduce their own permission level unless they have a project or global permission that already implies that permission. Promote or demote a user's permission level for the specified repository. Available repository permissions are: <ul> <li>REPO_READ</li> <li>REPO_WRITE</li> <li>REPO_ADMIN</li> </ul> See the <a href=\"https://confluence.atlassian.com/display/BitbucketServer/Using+repository+permissions\">Bitbucket Server documentation</a> for a detailed explanation of what each permission entails. <p> The authenticated user must have <strong>REPO_ADMIN</strong> permission for the specified repository or a higher project or global permission to call this resource. In addition, a user may not reduce their own permission level unless they have a project or global permission that already implies that permission.
* @param ctx context.Context for authentication, logging, tracing, etc. * @param ctx context.Context for authentication, logging, tracing, etc.
@param "projectKey" (string) name of the project to grant permission to
@param "repositorySlug" (string) repository slug
@param optional (nil or map[string]interface{}) with one or more of: @param optional (nil or map[string]interface{}) with one or more of:
@param "name" (string) the names of the users @param "name" (string) the names of the users
@param "permission" (string) the permission to grant @param "permission" (string) the permission to grant
@return */ @return */
func (a *DefaultApiService) SetPermissionForUser(localVarOptionals map[string]interface{}) (*APIResponse, error) { func (a *DefaultApiService) SetPermissionForUser(projectKey string, repositorySlug string, localVarOptionals map[string]interface{}) (*APIResponse, error) {
var ( var (
localVarHTTPMethod = strings.ToUpper("Put") localVarHTTPMethod = strings.ToUpper("Put")
localVarPostBody interface{} localVarPostBody interface{}
@ -9713,6 +9715,8 @@ func (a *DefaultApiService) SetPermissionForUser(localVarOptionals map[string]in
// create path and map variables // create path and map variables
localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/users" localVarPath := a.client.cfg.BasePath + "/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/users"
localVarPath = strings.Replace(localVarPath, "{"+"projectKey"+"}", fmt.Sprintf("%v", projectKey), -1)
localVarPath = strings.Replace(localVarPath, "{"+"repositorySlug"+"}", fmt.Sprintf("%v", repositorySlug), -1)
localVarHeaderParams := make(map[string]string) localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{} localVarQueryParams := url.Values{}
@ -9763,7 +9767,7 @@ func (a *DefaultApiService) SetPermissionForUser(localVarOptionals map[string]in
return NewAPIResponseWithError(localVarHTTPResponse, reportError("Status: %v, Body: %s", localVarHTTPResponse.Status, bodyBytes)) return NewAPIResponseWithError(localVarHTTPResponse, reportError("Status: %v, Body: %s", localVarHTTPResponse.Status, bodyBytes))
} }
return NewBitbucketAPIResponse(localVarHTTPResponse) return NewAPIResponse(localVarHTTPResponse), nil
} }
/* DefaultApiService /* DefaultApiService

View File

@ -5267,6 +5267,8 @@ func TestDefaultApiService_SetPermissionForUser(t *testing.T) {
client *APIClient client *APIClient
} }
type args struct { type args struct {
projectKey string
repositorySlug string
localVarOptionals map[string]interface{} localVarOptionals map[string]interface{}
} }
tests := []struct { tests := []struct {
@ -5276,14 +5278,14 @@ func TestDefaultApiService_SetPermissionForUser(t *testing.T) {
want *APIResponse want *APIResponse
wantErr bool wantErr bool
}{ }{
{"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{}, &APIResponse{Message: "Put https://stash.domain.com/rest/api/1.0/projects/%7BprojectKey%7D/repos/%7BrepositorySlug%7D/permissions/users: context canceled"}, true}, {"networkErrorContextExceeded", fields{client: generateConfigFake()}, args{}, &APIResponse{Message: "Put https://stash.domain.com/rest/api/1.0/projects//repos//permissions/users: context canceled"}, true},
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
a := &DefaultApiService{ a := &DefaultApiService{
client: tt.fields.client, client: tt.fields.client,
} }
got, err := a.SetPermissionForUser(tt.args.localVarOptionals) got, err := a.SetPermissionForUser(tt.args.projectKey, tt.args.repositorySlug, tt.args.localVarOptionals)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("DefaultApiService.SetPermissionForUser() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("DefaultApiService.SetPermissionForUser() error = %v, wantErr %v", err, tt.wantErr)
return return