public void RemoveSet() { using (TransactionScope ts = new TransactionScope()) { BlobShareDataStoreEntities context = BlobShareDataStoreEntities.CreateInstance(); BlobSet set = CreateBlobSetForTest("Test List", context); Blob blob = BlobServicesTests.CreateBlobForTest("Test Resource", context); BlobSetService service = new BlobSetService(context); service.AddBlobToSet(set.BlobSetId, blob.BlobId); BlobSet newList = service.GetBlobSetById(set.BlobSetId); Assert.IsNotNull(newList); Assert.AreEqual(1, newList.Blobs.Count); service.DeleteBlobSet(set.BlobSetId); BlobSet deletedList = service.GetBlobSetById(set.BlobSetId); Assert.IsNull(deletedList); BlobService bservices = new BlobService(context, CloudStorageAccount.DevelopmentStorageAccount, TestContainerName); Blob newResource = bservices.GetBlobById(blob.BlobId); Assert.IsNotNull(newResource); Assert.AreEqual(0, newResource.BlobSets.Count); } }
public void AddUserToBlob() { using (TransactionScope ts = new TransactionScope()) { BlobShareDataStoreEntities context = BlobShareDataStoreEntities.CreateInstance(); Blob blob = BlobServicesTests.CreateBlobForTest("Test Resource", context); User user = CreateUserForTest("testuser1", context); PermissionService service = new PermissionService(context); Permission permission = service.GrantPermissionToUserBlob(Privilege.Read, user, blob, DateTime.UtcNow.AddDays(1)); Assert.IsNotNull(permission); Assert.AreEqual(user, permission.Users.First()); Assert.AreEqual(blob, permission.Blob); Assert.AreEqual((int)Privilege.Read, permission.Privilege); IEnumerable <Blob> resources = service.GetBlobsByUser(user); Assert.IsNotNull(resources); Assert.AreEqual(1, resources.Count()); Assert.AreEqual(blob.BlobId, resources.First().BlobId); Assert.IsTrue(service.CheckPermissionToBlob(user.NameIdentifier, user.IdentityProvider, blob.BlobId)); BlobService blobService = new BlobService(context, CloudStorageAccount.DevelopmentStorageAccount, TestContainerName); CloudBlob cloudBlob = blobService.GetBlob(blob); cloudBlob.Delete(); } }
public void AddRoleToBlob() { using (TransactionScope ts = new TransactionScope()) { BlobShareDataStoreEntities context = BlobShareDataStoreEntities.CreateInstance(); Blob blob = BlobServicesTests.CreateBlobForTest("Test Resource", context); Role role = CreateRoleForTest("testrole1", context); PermissionService service = new PermissionService(context); Permission permission = service.GrantPermissionToRoleBlob(Privilege.Read, role, blob, DateTime.UtcNow.AddDays(1)); Assert.IsNotNull(permission); Assert.AreEqual(role, permission.Roles.First()); Assert.AreEqual(blob, permission.Blob); Assert.AreEqual((int)Privilege.Read, permission.Privilege); IEnumerable <Blob> resources = service.GetBlobsByRole(role); Assert.IsNotNull(resources); Assert.AreEqual(1, resources.Count()); Assert.AreEqual(blob.BlobId, resources.First().BlobId); } }
public void UpdateExistingList() { using (TransactionScope ts = new TransactionScope()) { BlobShareDataStoreEntities context = BlobShareDataStoreEntities.CreateInstance(); BlobSet set = CreateBlobSetForTest("Test List", context); Blob blob = BlobServicesTests.CreateBlobForTest("Test Resource", context); BlobSetService service = new BlobSetService(context); service.AddBlobToSet(set.Name, blob.BlobId); set.Name = "updated test list"; set.Description = "updated test description"; service.UpdateBlobSet(set); BlobSet newSet = service.GetBlobSetById(set.BlobSetId); Assert.IsNotNull(newSet); Assert.AreEqual(1, newSet.Blobs.Count); Assert.AreEqual(set.Name, newSet.Name); Assert.AreEqual(set.Description, newSet.Description); } }