Authorize() public method

Adds container-level permission to specified User API client. Requires Backend API key with Admin permission role. The collection_id/collection_key parameter means that one can use either one of them - collection_id or collection_key.
public Authorize ( string apiClientId, Permissions permission, string projectId, string folderName, string collectionId = null, string collectionKey = null ) : Task
apiClientId string User API client id.
permission Permissions User API client's permission to add.
projectId string Project containing specified container.
folderName string Folder name defining folder that permission will be added to.
collectionId string Collection containing specified container.
collectionKey string Collection containing specified container.
return Task
コード例 #1
0
 public async Task Authorize_WithInvalidApiClientId_ThrowsException(FolderSyncanoClient client)
 {
     try
     {
         //when
         await client.Authorize("abcde", Permissions.DeleteData, TestData.ProjectId,
                 TestData.FolderName, TestData.CollectionId);
         throw new Exception("Authorize should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<SyncanoException>();
     }
 }
コード例 #2
0
        public async Task Deauthorize_ByCollectionKey(FolderSyncanoClient client)
        {
            //given
            string folderName = "Authorize Test " + DateTime.Now.ToLongTimeString() + " " +
                                DateTime.Now.ToShortDateString();

            await client.New(TestData.ProjectId, folderName, collectionKey: TestData.CollectionKey);
            await client.Authorize(TestData.UserApiClientId, Permissions.CreateData, TestData.ProjectId,
                        TestData.FolderName, collectionKey: TestData.CollectionKey);

            //when
            var result = await client.Deauthorize(TestData.UserApiClientId, Permissions.CreateData, TestData.ProjectId,
                        TestData.FolderName, collectionKey: TestData.CollectionKey);

            //then
            result.ShouldBeTrue();

            //cleanup
            await client.Delete(TestData.ProjectId, folderName, collectionKey: TestData.CollectionKey);
        }
コード例 #3
0
 public async Task Authorize_WithNullFolderName_ThrowsException(FolderSyncanoClient client)
 {
     try
     {
         //when
         await client.Authorize(TestData.UserApiClientId, Permissions.DeleteData, TestData.ProjectId,
                 null, TestData.CollectionId);
         throw new Exception("Authorize should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<ArgumentNullException>();
     }
 }