public Authorize ( string apiClientId, Permissions permission, string projectId, string collectionId = null, string collectionKey = null ) : Task |
||
apiClientId | string | User API client id. |
permission | Permissions | User API client's permission to add. |
projectId | string | Defines project containing specified container. |
collectionId | string | Collection id defining collection that permission will be added to. |
collectionKey | string | Collection key defining collection that permission will be added to. |
return | Task |
public async Task Authorize_WithNullIdAndKey_ThrowsException(CollectionSyncanoClient client) { try { //when await client.Authorize(TestData.UserApiClientId, Permissions.DeleteOwnData, TestData.ProjectId); throw new Exception("Authorize should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<ArgumentNullException>(); } }
public async Task Authorize_WithInvalidCollectionKey_ThrowsException(CollectionSyncanoClient client) { try { //when await client.Authorize(TestData.UserApiClientId, Permissions.DeleteOwnData, TestData.ProjectId, collectionKey: "abcde"); throw new Exception("Authorize should throw an exception"); } catch (Exception e) { //then e.ShouldBeType<SyncanoException>(); } }
public async Task Authorize_ByCollectionKey(CollectionSyncanoClient client) { //given string collectionName = "NewCollection test " + DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToShortDateString(); string collectionKey = "qwert"; var collection = await client.New(TestData.ProjectId, collectionName, collectionKey); await client.Activate(TestData.ProjectId, collection.Id, true); //when var result = await client.Authorize(TestData.UserApiClientId, Permissions.UpdateOwnData, TestData.ProjectId, collectionKey: collectionKey); //then result.ShouldBeTrue(); //cleanup await client.Deauthorize(TestData.UserApiClientId, Permissions.UpdateOwnData, TestData.ProjectId, collection.Id); await client.Delete(TestData.ProjectId, collection.Id); }