/// <summary>
        /// Test ID 024
        /// Sample permissions for administrative statuses
        /// </summary>
        /// <param name="dataset"></param>
        public static void AssignPermissions(PhysicalInstance dataset)
        {
            // Get the Repository API
            var api = GetRepositoryApiWindows();

            // create a new item permission for the survey
            var permission = new ItemPermission();

            permission.Permission = PermissionType.ExclusiveWrite;
            permission.RoleName   = "*****@*****.**";
            //permission.RoleName = "yourdomain\\username";
            permission.Identifier = dataset.Identifier;
            permission.AgencyId   = dataset.AgencyId;

            // apply the permission on the Repository
            var roles = new RepositorySecurityContext();

            roles.IdentifierPermissions.Add(permission);
            api.AddPermissions(roles);
        }
Exemplo n.º 2
0
        public void ApiV1PermissionCreateAndDeletePost()
        {
            configuration  = GetClientConfig();
            permissionTest = new PermissionApi(configuration);
            RepositorySecurityContext addPermissionRequest = new RepositorySecurityContext();
            ItemTypePermission        permission           = new ItemTypePermission
            {
                ItemType   = Guid.NewGuid(),
                Permission = ItemTypePermission.PermissionEnum.DeniedWrite,
                RoleName   = "Can't Write"
            };

            addPermissionRequest.TypePermissions = new List <ItemTypePermission>
            {
                new ItemTypePermission(01L, "Can't Write", ItemTypePermission.PermissionEnum.DeniedWrite),
                permission
            };

            ApiResponse <object> responsePost = permissionTest.ApiV1PermissionPostWithHttpInfo(addPermissionRequest);
            //GET PermissionTest
            GetPermissionsRequest requestGet = new GetPermissionsRequest
            {
                ItemTypes = new List <Guid?>
                {
                    permission.ItemType
                }
            };


            List <long?> idDelete = new List <long?>
            {
                1L
            };
            RemovePermissionsRequest requestDelete = new RemovePermissionsRequest(idDelete);
            ApiResponse <object>     response      = permissionTest.ApiV1PermissionDeletePostWithHttpInfo(requestDelete);


            Assert.Equal(200, response.StatusCode);
            Assert.Equal(200, responsePost.StatusCode);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the specified permissions to the repository.
        /// </summary>
        /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="request"> (optional)</param>
        /// <returns>Task of ApiResponse</returns>
        public async System.Threading.Tasks.Task <ApiResponse <Object> > ApiV1PermissionPostAsyncWithHttpInfo(RepositorySecurityContext request = null)
        {
            var    localVarPath         = "/api/v1/permission";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new Dictionary <String, String>();
            var    localVarHeaderParams = new Dictionary <String, String>(Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json",
                "text/json",
                "application/json-patch+json"
            };
            String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
            };
            String localVarHttpHeaderAccept    = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            localVarPathParams.Add("format", "json");
            if (request != null && request.GetType() != typeof(byte[]))
            {
                localVarPostBody = Configuration.ApiClient.Serialize(request); // http body (model) parameter
            }
            else
            {
                localVarPostBody = request; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                       Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                       localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("ApiV1PermissionPost", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }


            return(new ApiResponse <Object>(localVarStatusCode,
                                            localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                            null));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Adds the specified permissions to the repository.
 /// </summary>
 /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="request"> (optional)</param>
 /// <returns>Task of void</returns>
 public async System.Threading.Tasks.Task ApiV1PermissionPostAsync(RepositorySecurityContext request = null)
 {
     await ApiV1PermissionPostAsyncWithHttpInfo(request);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds the specified permissions to the repository.
 /// </summary>
 /// <exception cref="Colectica.RestClientV1.Client.ApiException">Thrown when fails to make API call</exception>
 /// <param name="request"> (optional)</param>
 /// <returns></returns>
 public void ApiV1PermissionPost(RepositorySecurityContext request = null)
 {
     ApiV1PermissionPostWithHttpInfo(request);
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='request'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task ApiV1PermissionPostAsync(this IColecticaRepositoryRESTAPI operations, RepositorySecurityContext request = default(RepositorySecurityContext), CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.ApiV1PermissionPostWithHttpMessagesAsync(request, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='request'>
 /// </param>
 public static void ApiV1PermissionPost(this IColecticaRepositoryRESTAPI operations, RepositorySecurityContext request = default(RepositorySecurityContext))
 {
     operations.ApiV1PermissionPostAsync(request).GetAwaiter().GetResult();
 }