Authorize() public method

Adds container-level permission to specified User API client. Requires Backend API key with Admin permission role.
public Authorize ( string apiClientId, Permissions permission, string projectId ) : Task
apiClientId string User API client id.
permission Permissions User API client's permission to add.
projectId string Project id defining project that permission will be added to.
return Task
コード例 #1
0
 public async Task Authorize_WithInvalidProjectId_ThrowsException(ProjectSyncanoClient client)
 {
     try
     {
         //when
         await client.Authorize(TestData.UserApiClientId, Permissions.CreateData, "abcde");
         throw new Exception("Authorize should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<SyncanoException>();
     }
 }
コード例 #2
0
        public async Task Deauthorize_WithReadDataPermissions(ProjectSyncanoClient client)
        {
            //given
            string projectName = "Deauthorize Test " + DateTime.Now.ToLongTimeString() + " " +
                                DateTime.Now.ToShortDateString();

            var project = await client.New(projectName);
            await client.Authorize(TestData.UserApiClientId, Permissions.ReadData, project.Id);

            //when
            var result = await client.Deauthorize(TestData.UserApiClientId, Permissions.ReadData, project.Id);

            //then
            result.ShouldBeTrue();

            //cleanup
            await client.Delete(project.Id);
        }
コード例 #3
0
 public async Task Authorize_WithNoUserApiKey_ThrowsException(ProjectSyncanoClient client)
 {
     try
     {
         //when
         await client.Authorize(null, Permissions.CreateData, TestData.ProjectId);
         throw new Exception("Authorize should throw an exception");
     }
     catch (Exception e)
     {
         //then
         e.ShouldBeType<ArgumentNullException>();
     }
 }