From 978d119b611d16f8e92cd1da8571250e3778499b Mon Sep 17 00:00:00 2001 From: mwoda Date: Wed, 16 Feb 2022 20:47:13 +0100 Subject: [PATCH 01/17] test: rewrite appveyor tests to the nwe framework --- .../Box.V2.Test.IntegrationNew.csproj | 1 + ...borationWhitelistManagerIntegrationTest.cs | 22 ++ .../BoxEventsManagerIntegrationTest.cs | 1 + .../BoxFilesManagerIntegrationTest.cs | 118 ++++++++++ .../BoxFolderManagerIntegrationTest.cs | 201 ++++++++++++++++++ .../BoxMetadataManagerIntegrationTest.cs | 32 +++ .../BoxRecentItemsManagerIntegrationTest.cs | 18 ++ .../BoxSearchManagerIntegrationTest.cs | 22 ++ .../BoxSharedItemsManagerIntegrationTest.cs | 29 +++ .../BoxUsersManagerIntegrationTest.cs | 73 +++++++ .../BoxWebLinkManagerIntegrationTest.cs | 65 ++++++ .../CleanupCommands/DeleteFolderCommand.cs | 21 ++ .../AddCollaborationExemptCommand.cs | 33 +++ .../CreateEnterpriseUserCommand.cs | 41 ++++ .../CreateMetadataTemplateCommand.cs | 2 + .../CreateWebLinkCommand.cs | 43 ++++ .../Configuration/IntegrationTestBase.cs | 70 +++++- 17 files changed, 785 insertions(+), 7 deletions(-) create mode 100644 Box.V2.Test.IntegrationNew/BoxCollaborationWhitelistManagerIntegrationTest.cs create mode 100644 Box.V2.Test.IntegrationNew/BoxFolderManagerIntegrationTest.cs create mode 100644 Box.V2.Test.IntegrationNew/BoxRecentItemsManagerIntegrationTest.cs create mode 100644 Box.V2.Test.IntegrationNew/BoxSearchManagerIntegrationTest.cs create mode 100644 Box.V2.Test.IntegrationNew/BoxSharedItemsManagerIntegrationTest.cs create mode 100644 Box.V2.Test.IntegrationNew/BoxUsersManagerIntegrationTest.cs create mode 100644 Box.V2.Test.IntegrationNew/BoxWebLinkManagerIntegrationTest.cs create mode 100644 Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs create mode 100644 Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs create mode 100644 Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs create mode 100644 Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs diff --git a/Box.V2.Test.IntegrationNew/Box.V2.Test.IntegrationNew.csproj b/Box.V2.Test.IntegrationNew/Box.V2.Test.IntegrationNew.csproj index 5d027ddc6..658406ca7 100644 --- a/Box.V2.Test.IntegrationNew/Box.V2.Test.IntegrationNew.csproj +++ b/Box.V2.Test.IntegrationNew/Box.V2.Test.IntegrationNew.csproj @@ -8,6 +8,7 @@ + diff --git a/Box.V2.Test.IntegrationNew/BoxCollaborationWhitelistManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxCollaborationWhitelistManagerIntegrationTest.cs new file mode 100644 index 000000000..ae5801867 --- /dev/null +++ b/Box.V2.Test.IntegrationNew/BoxCollaborationWhitelistManagerIntegrationTest.cs @@ -0,0 +1,22 @@ +using System.Linq; +using System.Threading.Tasks; +using Box.V2.Test.IntegrationNew.Configuration; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Box.V2.Test.IntegrationNew +{ + [TestClass] + public class BoxCollaborationWhitelistManagerIntegrationTest : TestInFolder + { + [TestMethod] + public async Task GetAllCollaborationWhitelistExemptUsersAsync_ForExistingCollaborator_ShouldReturnWhitelistCollaborator() + { + var user = await CreateEnterpriseUser(); + var collaborationExempt = await AddCollaborationExempt(user.Id); + + var allUserWhitelistItems = await AdminClient.CollaborationWhitelistManager.GetAllCollaborationWhitelistExemptUsersAsync(10); + + Assert.IsTrue(allUserWhitelistItems.Entries.Any(x => x.Id == collaborationExempt.Id)); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/BoxEventsManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxEventsManagerIntegrationTest.cs index 5b0deece3..f530224f4 100644 --- a/Box.V2.Test.IntegrationNew/BoxEventsManagerIntegrationTest.cs +++ b/Box.V2.Test.IntegrationNew/BoxEventsManagerIntegrationTest.cs @@ -10,6 +10,7 @@ namespace Box.V2.Test.IntegrationNew [TestClass] public class BoxEventsManagerIntegrationTest : TestInFolder { + //flaky test (sometimes too fast events fetch) [TestMethod] public async Task EnterpriseEventsStreamingAsync_ForNewFile_ShouldReturnUploadFileEvent() { diff --git a/Box.V2.Test.IntegrationNew/BoxFilesManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxFilesManagerIntegrationTest.cs index 079617adc..bc3e88a1a 100644 --- a/Box.V2.Test.IntegrationNew/BoxFilesManagerIntegrationTest.cs +++ b/Box.V2.Test.IntegrationNew/BoxFilesManagerIntegrationTest.cs @@ -154,6 +154,7 @@ public async Task UploadNewVersionAsync_ForNewFileVersion_ShouldReturnDifferentF } } + //flaky test (too fast update(?)) [TestMethod] public async Task UpdateFileInformation_ForNewDispositionDate_ShouldBeAbleToUpdateIt() { @@ -174,5 +175,122 @@ public async Task UpdateFileInformation_ForNewDispositionDate_ShouldBeAbleToUpda Assert.IsTrue(newDispositionDate.IsEqualUpToSeconds(response.DispositionAt.Value)); } + + [TestMethod] + [ExpectedException(typeof(TimeoutException))] + public async Task DownloadStreamAsync_ForTimeoutShorterThanDownloadTime_ShouldAbortDownload() + { + var uploadedFile = await CreateSmallFile(FolderId); + var timeout = new TimeSpan(0, 0, 0, 0, 1); + + await UserClient.FilesManager.DownloadStreamAsync(uploadedFile.Id, timeout: timeout); + } + + [TestMethod] + public async Task UploadBigFileInSession_ShouldUploadTheFile_OnlyIfCommitIsCalled() + { + long fileSize = 50000000; + MemoryStream fileInMemoryStream = CreateFileInMemoryStream(fileSize); + var remoteFileName = GetUniqueName("UploadSession"); + + var boxFileUploadSessionRequest = new BoxFileUploadSessionRequest() + { + FolderId = FolderId, + FileName = remoteFileName, + FileSize = fileSize + }; + + BoxFileUploadSession boxFileUploadSession = await UserClient.FilesManager.CreateUploadSessionAsync(boxFileUploadSessionRequest); + BoxSessionEndpoint boxSessionEndpoint = boxFileUploadSession.SessionEndpoints; + var uploadPartUri = new Uri(boxSessionEndpoint.UploadPart); + var commitUri = new Uri(boxSessionEndpoint.Commit); + var listPartsUri = new Uri(boxSessionEndpoint.ListParts); + var partSize = boxFileUploadSession.PartSize; + long.TryParse(partSize, out var partSizeLong); + var numberOfParts = GetNumberOfParts(fileSize, partSizeLong); + + await UploadPartsInSessionAsync(uploadPartUri, numberOfParts, partSizeLong, fileInMemoryStream, fileSize); + + // Assert file is not committed/uploaded to box yet + Assert.IsFalse(await DoesFileExistInFolder(UserClient, FolderId, remoteFileName)); + + var allSessionParts = new List(); + + var boxSessionParts = await UserClient.FilesManager.GetSessionUploadedPartsAsync(listPartsUri, null, null, true); + + foreach (var sessionPart in boxSessionParts.Entries) + { + allSessionParts.Add(sessionPart); + } + var sessionPartsForCommit = new BoxSessionParts() { Parts = allSessionParts }; + + var uploadedFile = await UserClient.FilesManager.CommitSessionAsync(commitUri, Helper.GetSha1Hash(fileInMemoryStream), sessionPartsForCommit); + + // Assert file is committed/uploaded to box after commit + Assert.IsTrue(await DoesFileExistInFolder(UserClient, FolderId, remoteFileName)); + + await DeleteFile(uploadedFile.Id); + } + + private int GetNumberOfParts(long totalSize, long partSize) + { + if (partSize == 0) + { + throw new Exception("Part Size cannot be 0"); + } + + var numberOfParts = Convert.ToInt32(totalSize / partSize); + if (totalSize % partSize != 0) + { + numberOfParts++; + } + return numberOfParts; + } + + private async Task UploadPartsInSessionAsync(Uri uploadPartsUri, int numberOfParts, long partSize, Stream stream, + long fileSize) + { + for (var i = 0; i < numberOfParts; i++) + { + var partOffset = partSize * i; + Stream partFileStream = GetFilePart(stream, partSize, partOffset); + var sha = Helper.GetSha1Hash(partFileStream); + partFileStream.Position = 0; + await UserClient.FilesManager.UploadPartAsync(uploadPartsUri, sha, partOffset, fileSize, partFileStream); + } + } + + private Stream GetFilePart(Stream stream, long partSize, long partOffset) + { + const int BufferSize = 4096; + + var buffer = new byte[BufferSize]; + stream.Position = partOffset; + var partStream = new MemoryStream(); + int bytesRead; + do + { + bytesRead = stream.Read(buffer, 0, 4096); + if (bytesRead > 0) + { + long bytesToWrite = bytesRead; + var shouldBreak = false; + if (partStream.Length + bytesRead >= partSize) + { + bytesToWrite = partSize - partStream.Length; + shouldBreak = true; + } + + partStream.Write(buffer, 0, Convert.ToInt32(bytesToWrite)); + + if (shouldBreak) + { + break; + } + } + } while (bytesRead > 0); + + return partStream; + } } } diff --git a/Box.V2.Test.IntegrationNew/BoxFolderManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxFolderManagerIntegrationTest.cs new file mode 100644 index 000000000..586538514 --- /dev/null +++ b/Box.V2.Test.IntegrationNew/BoxFolderManagerIntegrationTest.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Box.V2.Models; +using Box.V2.Test.IntegrationNew.Configuration; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Box.V2.Test.IntegrationNew +{ + [TestClass] + public class BoxFolderManagerIntegrationTest : TestInFolder + { + [TestMethod] + [ExpectedException(typeof(TimeoutException))] + public async Task UpdateFolderInformationAsync_ValidRequest_Timeout() + { + var folderReq = new BoxFolderRequest() + { + Id = FolderId + }; + var timeout = new TimeSpan(0, 0, 0, 0, 1); // 1ms timeout, should always cancel the request + _ = await UserClient.FoldersManager.UpdateInformationAsync(folderRequest: folderReq, timeout: timeout); + } + + [TestMethod] + public async Task GetTrashItemsAsync_ForTrashedFolder_ShouldReturnTrashedFolder() + { + var createFolderRequest = new BoxFolderRequest + { + Name = GetUniqueName("folder"), + Parent = new BoxRequestEntity { Id = FolderId } + }; + var newFolder = await UserClient.FoldersManager.CreateAsync(createFolderRequest); + await UserClient.FoldersManager.DeleteAsync(newFolder.Id, true); + + var response = await UserClient.FoldersManager.GetTrashItemsAsync(100); + + var trashedFolderFound = false; + foreach (var item in response.Entries) + { + if (item is BoxFolder folder) + { + if (item.Id == newFolder.Id) + trashedFolderFound = true; + } + } + + Assert.IsTrue(trashedFolderFound); + + await UserClient.FoldersManager.PurgeTrashedFolderAsync(newFolder.Id); + } + + [TestMethod] + public async Task CreateAsync_ForCorrectBoxFolderRequest_ShouldCreateNewFolder() + { + var folderName = GetUniqueName("Folder"); + var folderReq = new BoxFolderRequest() + { + Name = folderName, + Parent = new BoxRequestEntity() { Id = FolderId } + }; + + BoxFolder folder = await UserClient.FoldersManager.CreateAsync(folderReq); + + Assert.AreEqual(folder.Name, folderName); + } + + [TestMethod] + public async Task GetInformationAsync_ForExistingFolder_ShouldReturnInformationRelatedToThisFolder() + { + var createdFolder = await CreateFolder(FolderId); + + BoxFolder folder = await UserClient.FoldersManager.GetInformationAsync(createdFolder.Id); + + Assert.AreEqual(folder.Id, createdFolder.Id); + } + + [TestMethod] + public async Task CreateSharedLinkAsync_ForExistingFolder_ShouldCreateSharedLinkToThatFolder() + { + var createdFolder = await CreateFolder(FolderId); + + var sharedLinkReq = new BoxSharedLinkRequest() + { + Access = BoxSharedLinkAccessType.open + }; + + BoxFolder folder = await UserClient.FoldersManager.CreateSharedLinkAsync(createdFolder.Id, sharedLinkReq); + + Assert.AreEqual(BoxSharedLinkAccessType.open, folder.SharedLink.Access); + } + + [TestMethod] + public async Task DeleteSharedLinkAsync_ForExistingSharedLink_ShouldDeleteThisSharedLink() + { + var createdFolder = await CreateFolder(FolderId); + var sharedLinkReq = new BoxSharedLinkRequest() + { + Access = BoxSharedLinkAccessType.open + }; + await UserClient.FoldersManager.CreateSharedLinkAsync(createdFolder.Id, sharedLinkReq); + + var sharedLink = await UserClient.FoldersManager.DeleteSharedLinkAsync(createdFolder.Id); + + Assert.IsNull(sharedLink.SharedLink); + } + + [TestMethod] + public async Task UpdateInformationAsync_ForExistingFolder_ShouldCorrectlyUpdateThisFolderName() + { + var createdFolder = await CreateFolder(FolderId); + + var newFolderName = GetUniqueName("new_folder_name"); + var updateRequest = new BoxFolderRequest() + { + Id = createdFolder.Id, + Name = newFolderName, + }; + + BoxFolder folder = await UserClient.FoldersManager.UpdateInformationAsync(updateRequest); + + Assert.AreEqual(folder.Name, newFolderName); + } + + [TestMethod] + public async Task CopyAsync_ForExistingFolder_ShouldCopyThisFolder() + { + var createdFolder = await CreateFolder(FolderId); + + var copiedFolderName = GetUniqueName("copied_folder"); + var copyRequest = new BoxFolderRequest() + { + Id = createdFolder.Id, + Parent = new BoxRequestEntity() { Id = "0" }, + Name = copiedFolderName + }; + + BoxFolder copiedFolder = await UserClient.FoldersManager.CopyAsync(copyRequest); + + Assert.AreEqual(copiedFolder.Name, copiedFolderName); + Assert.AreNotEqual(copiedFolder.Id, createdFolder.Id); + + await DeleteFolder(copiedFolder.Id); + } + + [TestMethod] + public async Task DeleteAsync_ForExistingFolder_ShouldDeleteThisFolder() + { + var createFolderRequest = new BoxFolderRequest + { + Name = GetUniqueName("folder"), + Parent = new BoxRequestEntity { Id = FolderId } + }; + var newFolder = await UserClient.FoldersManager.CreateAsync(createFolderRequest); + + await UserClient.FoldersManager.DeleteAsync(newFolder.Id, true); + + var folderItems = await UserClient.FoldersManager.GetFolderItemsAsync(FolderId, 100); + + Assert.IsFalse(folderItems.Entries.Any(x => x.Id == newFolder.Id)); + + await UserClient.FoldersManager.PurgeTrashedFolderAsync(newFolder.Id); + } + + [TestMethod] + public async Task ApplyWatermark_ForExistingFolder_ShouldCorrectlyApplyWatermarkOnFolder() + { + var folder = await CreateFolder(FolderId); + + await UserClient.FoldersManager.ApplyWatermarkAsync(folder.Id); + + var fieldList = new List(new string[] { "watermark_info" }); + var folderInfo = await UserClient.FoldersManager.GetInformationAsync(folder.Id, fieldList); + + Assert.IsTrue(folderInfo.WatermarkInfo.IsWatermarked); + } + + [TestMethod] + public async Task GetWatermarkAsync_ForExistingFolder_ShouldCorrectlyApplyWatermarkOnFolder() + { + var folder = await CreateFolder(FolderId); + await UserClient.FoldersManager.ApplyWatermarkAsync(folder.Id); + + var watermark = await UserClient.FoldersManager.GetWatermarkAsync(folder.Id); + + Assert.IsNotNull(watermark); + } + + [TestMethod] + public async Task RemoveWatermarkAsync_ForExistingFolder_ShouldCorrectlyRemoveWatermarkFromFolder() + { + var folder = await CreateFolder(FolderId); + await UserClient.FoldersManager.ApplyWatermarkAsync(folder.Id); + + var result = await UserClient.FoldersManager.RemoveWatermarkAsync(folder.Id); + + Assert.IsTrue(result); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/BoxMetadataManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxMetadataManagerIntegrationTest.cs index a348c3abe..93f7340f2 100644 --- a/Box.V2.Test.IntegrationNew/BoxMetadataManagerIntegrationTest.cs +++ b/Box.V2.Test.IntegrationNew/BoxMetadataManagerIntegrationTest.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Box.V2.Models; using Box.V2.Models.Request; @@ -33,5 +34,36 @@ public async Task ExecuteMetadataQuery_ForSmallFile_ShouldBeAbleToFindThisFileBy Assert.AreEqual(response.Entries.Count, 1); Assert.AreEqual(((BoxFile)response.Entries[0]).Metadata[$"enterprise_{EnterpriseId}"][templateKey]["status"].Value, "active"); } + + [TestMethod] + public async Task GetEnterpriseMetadataAsync_ForExistingMetadataTemplate_ShouldReturnThisMetadataTemplate() + { + var metadataTemplate = await CreateMetadataTemplate(); + + var templates = await AdminClient.MetadataManager.GetEnterpriseMetadataAsync(); + + Assert.IsTrue(templates.Entries.Any(x => x.TemplateKey == metadataTemplate.TemplateKey)); + } + + [TestMethod] + public async Task GetMetadataTemplate_ForExistingMetadataTemplate_ShouldReturnThisMetadataTemplate() + { + var metadataTemplate = await CreateMetadataTemplate(); + + var template = await AdminClient.MetadataManager.GetMetadataTemplate("enterprise", metadataTemplate.TemplateKey); + + Assert.AreEqual(template.TemplateKey, metadataTemplate.TemplateKey); + } + + + [TestMethod] + public async Task GetMetadataTemplateById_ForExistingMetadataTemplate_ShouldReturnThisMetadataTemplate() + { + var metadataTemplate = await CreateMetadataTemplate(); + + var fetchedMetadataTemplate = await AdminClient.MetadataManager.GetMetadataTemplateById(metadataTemplate.Id); + + Assert.AreEqual(fetchedMetadataTemplate.TemplateKey, metadataTemplate.TemplateKey); + } } } diff --git a/Box.V2.Test.IntegrationNew/BoxRecentItemsManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxRecentItemsManagerIntegrationTest.cs new file mode 100644 index 000000000..6314f8fac --- /dev/null +++ b/Box.V2.Test.IntegrationNew/BoxRecentItemsManagerIntegrationTest.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Box.V2.Test.IntegrationNew.Configuration; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Box.V2.Test.IntegrationNew +{ + [TestClass] + public class BoxRecentItemsManagerIntegrationTest : TestInFolder + { + [TestMethod] + public async Task GetRecentItemsAsync_ForExistingItems_ShouldReturnItems() + { + var recentItems = await UserClient.RecentItemsManager.GetRecentItemsAsync(10); + + Assert.AreNotEqual(recentItems.Entries, 0); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/BoxSearchManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxSearchManagerIntegrationTest.cs new file mode 100644 index 000000000..86dc6f46b --- /dev/null +++ b/Box.V2.Test.IntegrationNew/BoxSearchManagerIntegrationTest.cs @@ -0,0 +1,22 @@ +using System.Threading.Tasks; +using Box.V2.Models; +using Box.V2.Test.IntegrationNew.Configuration; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Box.V2.Test.IntegrationNew +{ + [TestClass] + public class BoxSearchManagerIntegrationTest : TestInFolder + { + [TestMethod] + public async Task SearchAsync_ForNonExistentKeyword_ShouldReturnNoResults() + { + const string Keyword = "NonExistentKeyWord"; + + BoxCollection results = await UserClient.SearchManager.SearchAsync(Keyword, 200); + + Assert.IsNotNull(results); + Assert.AreEqual(0, results.Entries.Count); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/BoxSharedItemsManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxSharedItemsManagerIntegrationTest.cs new file mode 100644 index 000000000..6242412e8 --- /dev/null +++ b/Box.V2.Test.IntegrationNew/BoxSharedItemsManagerIntegrationTest.cs @@ -0,0 +1,29 @@ +using System.Threading.Tasks; +using Box.V2.Models; +using Box.V2.Test.IntegrationNew.Configuration; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Box.V2.Test.IntegrationNew +{ + [TestClass] + public class BoxSharedItemsManagerIntegrationTest : TestInFolder + { + [TestMethod] + public async Task SharedItemsAsync_ForSharedFolder_ShouldReturnSharedFolder() + { + var folder = await CreateFolder(); + var password = "secret"; + var sharedLinkReq = new BoxSharedLinkRequest() + { + Access = BoxSharedLinkAccessType.open, + Password = password + }; + var folderWithLink = await UserClient.FoldersManager.CreateSharedLinkAsync(folder.Id, sharedLinkReq); + + var sharedItem = await UserClient.SharedItemsManager.SharedItemsAsync(folderWithLink.SharedLink.Url, password); + + Assert.AreEqual(folderWithLink.Id, sharedItem.Id); + } + } +} + diff --git a/Box.V2.Test.IntegrationNew/BoxUsersManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxUsersManagerIntegrationTest.cs new file mode 100644 index 000000000..db23266b6 --- /dev/null +++ b/Box.V2.Test.IntegrationNew/BoxUsersManagerIntegrationTest.cs @@ -0,0 +1,73 @@ +using System.Linq; +using System.Threading.Tasks; +using Box.V2.Models; +using Box.V2.Test.IntegrationNew.Configuration; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Box.V2.Test.IntegrationNew +{ + [TestClass] + public class BoxUsersManagerIntegrationTest : TestInFolder + { + [TestMethod] + public async Task CreateEnterpriseUserAsync_ForCorrectUserRequest_ShouldCreateNewApplicationUser() + { + var name = GetUniqueName("user"); + var userRequest = new BoxUserRequest + { + Name = name, + IsPlatformAccessOnly = true, + ExternalAppUserId = GetUniqueName("user-id") + }; + + var newUser = await AdminClient.UsersManager.CreateEnterpriseUserAsync(userRequest); + + Assert.AreEqual(newUser.Name, name); + + await AdminClient.UsersManager.DeleteEnterpriseUserAsync(newUser.Id, false, true); + } + + [TestMethod] + public async Task UpdateUserInformationAsync_ForNewExternalAppId_ShouldUpdateExistingUser() + { + var user = await CreateEnterpriseUser(); + var newName = GetUniqueName("username"); + var updateUserRequest = new BoxUserRequest + { + Id = user.Id, + Name = newName + }; + + var updatedUser = await AdminClient.UsersManager.UpdateUserInformationAsync(updateUserRequest); + + Assert.AreEqual(updatedUser.Name, newName); + } + + [TestMethod] + public async Task GetEnterpriseUsersAsync_ForNewExternalAppId_ShouldUpdateExistingUser() + { + var user = await CreateEnterpriseUser(); + + var appUsers = await AdminClient.UsersManager.GetEnterpriseUsersAsync(); + + Assert.IsTrue(appUsers.Entries.Any(x => x.Id == user.Id)); + } + + [TestMethod] + public async Task DeleteEnterpriseUserAsync_ForExistingUser_ShouldDeleteThisUserFromBox() + { + var userRequest = new BoxUserRequest + { + Name = GetUniqueName("user"), + IsPlatformAccessOnly = true, + ExternalAppUserId = GetUniqueName("user-id") + }; + var newUser = await AdminClient.UsersManager.CreateEnterpriseUserAsync(userRequest); + + await AdminClient.UsersManager.DeleteEnterpriseUserAsync(newUser.Id, false, true); + + var appUsers = await AdminClient.UsersManager.GetEnterpriseUsersAsync(); + Assert.IsFalse(appUsers.Entries.Any(item => item.Id == newUser.Id)); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/BoxWebLinkManagerIntegrationTest.cs b/Box.V2.Test.IntegrationNew/BoxWebLinkManagerIntegrationTest.cs new file mode 100644 index 000000000..db48f815a --- /dev/null +++ b/Box.V2.Test.IntegrationNew/BoxWebLinkManagerIntegrationTest.cs @@ -0,0 +1,65 @@ +using System; +using System.Threading.Tasks; +using Box.V2.Models; +using Box.V2.Test.IntegrationNew.Configuration; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Box.V2.Test.IntegrationNew +{ + [TestClass] + public class BoxWebLinkManagerIntegrationTest : TestInFolder + { + [TestMethod] + public async Task CreateWebLinkAsync_ForCorrectWeblinkRequest_ShouldCreateNewWeblink() + { + var url = new Uri("http://www.box.com"); + const string Description = "A weblink to Box.com"; + const string Name = "Box.com website"; + var webLinkRequest = new BoxWebLinkRequest() { Url = url, Name = Name, Description = Description, Parent = new BoxRequestEntity() { Id = "0" } }; + + var weblink = await UserClient.WebLinksManager.CreateWebLinkAsync(webLinkRequest); + + Assert.AreEqual(Name, weblink.Name); + Assert.AreEqual(url, weblink.Url); + + await UserClient.WebLinksManager.DeleteWebLinkAsync(weblink.Id); + } + + [TestMethod] + public async Task GetWebLinkAsync_ForExistingWebLink_ShouldReturnWebLink() + { + var webLink = await CreateWebLink(GetUniqueName("weblink"), FolderId); + + var fetchedWeblink = await UserClient.WebLinksManager.GetWebLinkAsync(webLink.Id); + + Assert.AreEqual(webLink.Id, fetchedWeblink.Id); + } + + [TestMethod] + public async Task UpdateWebLinkAsync_ForExistingWebLink_ShouldUpdateWebLink() + { + var webLink = await CreateWebLink(GetUniqueName("weblink"), FolderId); + + var newUrl = new Uri("http://www.box.com/v2"); + var updateWebLinkRequest = new BoxWebLinkRequest() { Url = newUrl }; + + var updatedWeblink = await UserClient.WebLinksManager.UpdateWebLinkAsync(webLink.Id, updateWebLinkRequest); + + Assert.AreEqual(updatedWeblink.Url, newUrl); + } + + [TestMethod] + public async Task DeleteWebLinkAsync_ForExistingWebLink_ShouldDeleteWebLink() + { + var url = new Uri("http://www.box.com"); + const string Description = "A weblink to Box.com"; + const string Name = "Box.com website"; + var webLinkRequest = new BoxWebLinkRequest() { Url = url, Name = Name, Description = Description, Parent = new BoxRequestEntity() { Id = FolderId } }; + var weblink = await UserClient.WebLinksManager.CreateWebLinkAsync(webLinkRequest); + + var result = await UserClient.WebLinksManager.DeleteWebLinkAsync(weblink.Id); + + Assert.IsTrue(result); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs b/Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs new file mode 100644 index 000000000..040ff39dc --- /dev/null +++ b/Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs @@ -0,0 +1,21 @@ +using System.Threading.Tasks; + +namespace Box.V2.Test.IntegrationNew.Configuration.Commands.CleanupCommands +{ + public class DeleteFolderCommand : CommandBase, ICleanupCommand + { + private readonly string _folderId; + + public DeleteFolderCommand(string folderId, CommandScope scope = CommandScope.Test) : base(scope) + { + _folderId = folderId; + } + + public async Task Execute(IBoxClient client) + { + await client.FoldersManager.DeleteAsync(_folderId); + + await client.FoldersManager.PurgeTrashedFolderAsync(_folderId); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs b/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs new file mode 100644 index 000000000..1d7cf7d9e --- /dev/null +++ b/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs @@ -0,0 +1,33 @@ +using System.Threading.Tasks; +using Box.V2.Models; + +namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +{ + public class AddCollaborationExemptCommand : CommandBase, IDisposableCommand + { + private readonly string _userId; + + public BoxCollaborationWhitelistTargetEntry WhitelistTargetEntry; + + public AddCollaborationExemptCommand(string userId, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) + : base(scope, accessLevel) + { + _userId = userId; + } + + public async Task Execute(IBoxClient client) + { + var whitelistTargetEntry = await client.CollaborationWhitelistManager.AddCollaborationWhitelistExemptUserAsync(_userId); + + WhitelistTargetEntry = whitelistTargetEntry; + + return WhitelistTargetEntry.Id; + } + + public async Task Dispose(IBoxClient client) + { + await client.CollaborationWhitelistManager.DeleteCollaborationWhitelistExemptUserAsync(WhitelistTargetEntry.Id); + } + } +} + diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs b/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs new file mode 100644 index 000000000..433ae8327 --- /dev/null +++ b/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs @@ -0,0 +1,41 @@ +using System.Threading.Tasks; +using Box.V2.Models; + +namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +{ + public class CreateEnterpriseUserCommand : CommandBase, IDisposableCommand + { + private string _id; + private readonly string _name; + private readonly string _externalAppUserId; + + public BoxUser BoxUser; + + public CreateEnterpriseUserCommand(string name, string externalAppUserId, + CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) : base(scope, accessLevel) + { + _name = name; + _externalAppUserId = externalAppUserId; + } + + public async Task Execute(IBoxClient client) + { + var userRequest = new BoxUserRequest + { + Name = _name, + IsPlatformAccessOnly = true, + ExternalAppUserId = _externalAppUserId + }; + + BoxUser = await client.UsersManager.CreateEnterpriseUserAsync(userRequest); + _id = BoxUser.Id; + + return BoxUser.Id; + } + + public async Task Dispose(IBoxClient client) + { + await client.UsersManager.DeleteEnterpriseUserAsync(_id, false, true); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs b/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs index ba070fe5e..93421187a 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs +++ b/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs @@ -9,6 +9,7 @@ public class CreateMetadataTemplateCommand : CommandBase, IDisposableCommand private readonly List _metadataFields; public string TemplateKey; + public BoxMetadataTemplate MetadataTemplate; public CreateMetadataTemplateCommand(string templateKey, List metadataFields, CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) : base(scope, accessLevel) @@ -28,6 +29,7 @@ public async Task Execute(IBoxClient client) }; var response = await client.MetadataManager.CreateMetadataTemplate(metadataTemplate); + MetadataTemplate = response; return response.Id; } diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs b/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs new file mode 100644 index 000000000..1bc4bab5d --- /dev/null +++ b/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs @@ -0,0 +1,43 @@ +using System; +using System.Threading.Tasks; +using Box.V2.Models; + +namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +{ + public class CreateWebLinkCommand : CommandBase, IDisposableCommand + { + private readonly string _name; + private readonly string _parentFolderId; + + private string _webLinkId; + public BoxWebLink WebLink; + + public CreateWebLinkCommand(string name, string parentFolderId, + CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) : base(scope, accessLevel) + { + _name = name; + _parentFolderId = parentFolderId; + } + + public async Task Execute(IBoxClient client) + { + var webLinkRequest = new BoxWebLinkRequest() + { + Url = new Uri("http://www.box.com"), + Name = _name, + Description = "A weblink to Box.com", + Parent = new BoxRequestEntity() { Id = _parentFolderId } + }; + + WebLink = await client.WebLinksManager.CreateWebLinkAsync(webLinkRequest); + _webLinkId = WebLink.Id; + + return _webLinkId; + } + + public async Task Dispose(IBoxClient client) + { + await client.WebLinksManager.DeleteWebLinkAsync(_webLinkId); + } + } +} diff --git a/Box.V2.Test.IntegrationNew/Configuration/IntegrationTestBase.cs b/Box.V2.Test.IntegrationNew/Configuration/IntegrationTestBase.cs index 82d437dd6..278861015 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/IntegrationTestBase.cs +++ b/Box.V2.Test.IntegrationNew/Configuration/IntegrationTestBase.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; using Box.V2.Config; @@ -215,6 +216,11 @@ public static async Task DeleteFile(string fileId) await ExecuteCommand(new DeleteFileCommand(fileId)); } + public static async Task DeleteFolder(string folderId) + { + await ExecuteCommand(new DeleteFolderCommand(folderId)); + } + public static async Task CreateFolder(string parentId = "0", CommandScope commandScope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) { var createFolderCommand = new CreateFolderCommand(GetUniqueName("folder"), parentId, commandScope, accessLevel); @@ -227,7 +233,7 @@ public static async Task CreateFolderAsAdmin(string parentId) return await CreateFolder(parentId, CommandScope.Test, CommandAccessLevel.Admin); } - public MemoryStream CreateBigFileInMemoryStream(long fileSize) + public static MemoryStream CreateFileInMemoryStream(long fileSize) { var dataArray = new byte[fileSize]; new Random().NextBytes(dataArray); @@ -235,6 +241,11 @@ public MemoryStream CreateBigFileInMemoryStream(long fileSize) return memoryStream; } + public static MemoryStream CreateBigFileInMemoryStream() + { + return CreateFileInMemoryStream(50000000); + } + public static async Task CreateRetentionPolicy(string folderId = "0", CommandScope commandScope = CommandScope.Test) { var createRetentionPolicyCommand = new CreateRetentionPolicyCommand(folderId, GetUniqueName("policy"), commandScope); @@ -242,6 +253,15 @@ public static async Task CreateRetentionPolicy(string folder return createRetentionPolicyCommand.Policy; } + public static async Task CreateMetadataTemplate(Dictionary metadata = null, + CommandScope commandScope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) + { + var createMetadataTemplateCommand = new CreateMetadataTemplateCommand(GetUniqueName("template_key", false), ToStringMetadataFields(metadata), commandScope, accessLevel); + await ExecuteCommand(createMetadataTemplateCommand); + + return createMetadataTemplateCommand.MetadataTemplate; + } + public static async Task> CreateSmallFileWithMetadata (string parentId = "0", Dictionary metadata = null, CommandScope commandScope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.Admin) @@ -262,17 +282,53 @@ private static List ToStringMetadataFields(Dictionary< { var mappedFields = new List(); - foreach (var field in metadataFields) + if (metadataFields != null) { - mappedFields.Add(new BoxMetadataTemplateField() + foreach (var field in metadataFields) { - Type = "string", - Key = field.Key, - DisplayName = field.Key - }); + mappedFields.Add(new BoxMetadataTemplateField() + { + Type = "string", + Key = field.Key, + DisplayName = field.Key + }); + } } return mappedFields; } + + public static async Task DoesFileExistInFolder(IBoxClient client, string folderId, string fileName) + { + // TODO: Paging + BoxCollection boxCollection = await client.FoldersManager.GetFolderItemsAsync(folderId, 1000); + return boxCollection.Entries.Any(item => item.Name == fileName); + } + + public static async Task CreateEnterpriseUser() + { + return await CreateEnterpriseUser(GetUniqueName("user"), GetUniqueName("user-id")); + } + + public static async Task CreateEnterpriseUser(string name, string externalUserAppId) + { + var createEnterpriseUserCommand = new CreateEnterpriseUserCommand(name, externalUserAppId); + await ExecuteCommand(createEnterpriseUserCommand); + return createEnterpriseUserCommand.BoxUser; + } + + public static async Task CreateWebLink(string name, string parentFolderId) + { + var createWebLinkCommand = new CreateWebLinkCommand(name, parentFolderId); + await ExecuteCommand(createWebLinkCommand); + return createWebLinkCommand.WebLink; + } + + public static async Task AddCollaborationExempt(string userId) + { + var addCollaborationExemptCommand = new AddCollaborationExemptCommand(userId); + await ExecuteCommand(addCollaborationExemptCommand); + return addCollaborationExemptCommand.WhitelistTargetEntry; + } } } From abd346c3a4101d2ea81b09cf331e5abf16592b54 Mon Sep 17 00:00:00 2001 From: mwoda Date: Wed, 16 Feb 2022 21:01:35 +0100 Subject: [PATCH 02/17] Remove old integration test project Rename new integration test project --- .github/workflows/integration_tests.yml | 2 +- .../Box.V2.Test.Integration.csproj | 154 +---- .../BoxAuthTestIntegration.cs | 28 - ...borationWhitelistManagerIntegrationTest.cs | 4 +- ...borationWhitelistManagerTestIntegration.cs | 82 --- ...BoxCollaborationsManagerTestIntegration.cs | 158 ----- .../BoxCollectionsManagerTestIntegration.cs | 38 -- .../BoxCommentsManagerTestIntegration.cs | 80 --- .../BoxDevicePinManagerTestIntegration.cs | 28 - .../BoxEventsManagerIntegrationTest.cs | 4 +- .../BoxEventsManagerTestIntegration.cs | 131 ---- .../BoxFilesManagerIntegrationTest.cs | 6 +- .../BoxFilesManagerTestIntegration.cs | 624 ------------------ .../BoxFolderManagerIntegrationTest.cs | 4 +- .../BoxFoldersManagerTestIntegration.cs | 284 -------- .../BoxGroupsManagerTestIntegration.cs | 167 ----- ...LegalHoldPoliciesManagerTestIntegration.cs | 128 ---- .../BoxMetadataManagerIntegrationTest.cs | 4 +- .../BoxMetadataManagerTestIntegration.cs | 432 ------------ .../BoxRecentItemsManagerIntegrationTest.cs | 4 +- .../BoxRecentItemsManagerTestIntegration.cs | 30 - .../BoxResourceManagerTestIntegration.cs | 132 ---- ...RetentionPoliciesManagerTestIntegration.cs | 82 --- .../BoxSearchManagerIntegrationTest.cs | 4 +- .../BoxSearchManagerTestIntegration.cs | 157 ----- .../BoxSharedItemsManagerIntegrationTest.cs | 4 +- .../BoxSharedItemsManagerTestIntegration.cs | 22 - ...oxStoragePoliciesManagerTestIntegration.cs | 15 - .../BoxTasksManagerTestIntegration.cs | 76 --- ...oxTermsOfServicesManagerTestIntegration.cs | 75 --- .../BoxTokenExchangeTestIntegration.cs | 69 -- .../BoxUsersManagerIntegrationTest.cs | 4 +- .../BoxUsersManagerTestIntegration.cs | 97 --- .../BoxWebLinkManagerIntegrationTest.cs | 4 +- .../BoxWebLinkManagerTestIntegration.cs | 47 -- .../BoxWebhooksManagerTestIntegration.cs | 53 -- .../CleanupCommands/DeleteFileCommand.cs | 2 +- .../CleanupCommands/DeleteFolderCommand.cs | 2 +- .../Commands/CommandAccessLevel.cs | 2 +- .../Configuration/Commands/CommandBase.cs | 2 +- .../Configuration/Commands/CommandScope.cs | 2 +- .../AddCollaborationExemptCommand.cs | 2 +- .../ApplyMetadataCommand.cs | 2 +- .../CreateEnterpriseUserCommand.cs | 2 +- .../DisposableCommands/CreateFileCommand.cs | 2 +- .../DisposableCommands/CreateFolderCommand.cs | 2 +- .../CreateMetadataTemplateCommand.cs | 2 +- .../CreateRetentionPolicyCommand.cs | 2 +- .../CreateWebLinkCommand.cs | 2 +- .../Configuration/Commands/ICommand.cs | 2 +- .../Extensions/DateTimeExtensions.cs | 2 +- .../Configuration/IntegrationTestBase.cs | 6 +- .../Configuration/TestInFolder.cs | 4 +- .../Properties/AssemblyInfo.cs | 35 - .../Properties/smalltestpdf.Designer.cs | 73 -- .../Properties/smalltestpdf.resx | 124 ---- .../TestData/smalltestV2.pdf | Bin Box.V2.Test.Integration/app.config | 19 - .../Box.V2.Test.IntegrationNew.csproj | 37 -- .../TestData/smalltest.pdf | Bin 2526 -> 0 bytes Box.V2.Test.IntegrationNew/config.json | 13 - Box.V2.sln | 15 +- 62 files changed, 72 insertions(+), 3517 deletions(-) delete mode 100644 Box.V2.Test.Integration/BoxAuthTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxCollaborationWhitelistManagerIntegrationTest.cs (89%) delete mode 100644 Box.V2.Test.Integration/BoxCollaborationWhitelistManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxCollaborationsManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxCollectionsManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxCommentsManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxDevicePinManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxEventsManagerIntegrationTest.cs (93%) delete mode 100644 Box.V2.Test.Integration/BoxEventsManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxFilesManagerIntegrationTest.cs (98%) delete mode 100644 Box.V2.Test.Integration/BoxFilesManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxFolderManagerIntegrationTest.cs (98%) delete mode 100644 Box.V2.Test.Integration/BoxFoldersManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxGroupsManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxLegalHoldPoliciesManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxMetadataManagerIntegrationTest.cs (97%) delete mode 100644 Box.V2.Test.Integration/BoxMetadataManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxRecentItemsManagerIntegrationTest.cs (84%) delete mode 100644 Box.V2.Test.Integration/BoxRecentItemsManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxResourceManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxRetentionPoliciesManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxSearchManagerIntegrationTest.cs (87%) delete mode 100644 Box.V2.Test.Integration/BoxSearchManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxSharedItemsManagerIntegrationTest.cs (91%) delete mode 100644 Box.V2.Test.Integration/BoxSharedItemsManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxStoragePoliciesManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxTasksManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxTermsOfServicesManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxTokenExchangeTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxUsersManagerIntegrationTest.cs (96%) delete mode 100644 Box.V2.Test.Integration/BoxUsersManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/BoxWebLinkManagerIntegrationTest.cs (96%) delete mode 100644 Box.V2.Test.Integration/BoxWebLinkManagerTestIntegration.cs delete mode 100644 Box.V2.Test.Integration/BoxWebhooksManagerTestIntegration.cs rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/CleanupCommands/DeleteFileCommand.cs (86%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs (87%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/CommandAccessLevel.cs (56%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/CommandBase.cs (86%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/CommandScope.cs (60%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs (92%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/DisposableCommands/ApplyMetadataCommand.cs (93%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs (93%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/DisposableCommands/CreateFileCommand.cs (95%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs (94%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs (94%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/DisposableCommands/CreateRetentionPolicyCommand.cs (96%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs (94%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Commands/ICommand.cs (87%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/Extensions/DateTimeExtensions.cs (85%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/IntegrationTestBase.cs (98%) rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/Configuration/TestInFolder.cs (85%) delete mode 100644 Box.V2.Test.Integration/Properties/AssemblyInfo.cs delete mode 100644 Box.V2.Test.Integration/Properties/smalltestpdf.Designer.cs delete mode 100644 Box.V2.Test.Integration/Properties/smalltestpdf.resx rename {Box.V2.Test.IntegrationNew => Box.V2.Test.Integration}/TestData/smalltestV2.pdf (100%) delete mode 100644 Box.V2.Test.Integration/app.config delete mode 100644 Box.V2.Test.IntegrationNew/Box.V2.Test.IntegrationNew.csproj delete mode 100644 Box.V2.Test.IntegrationNew/TestData/smalltest.pdf delete mode 100644 Box.V2.Test.IntegrationNew/config.json diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 7f03ba500..d336d74d1 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -18,4 +18,4 @@ jobs: - name: Test env: INTEGRATION_TESTING_CONFIG: ${{ secrets.INTEGRATION_TESTING_CONFIG }} - run: dotnet test .\Box.V2.Test.IntegrationNew -f netcoreapp2.0 \ No newline at end of file + run: dotnet test .\Box.V2.Test.Integration -f netcoreapp2.0 \ No newline at end of file diff --git a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj index 4cb387780..658406ca7 100644 --- a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj +++ b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj @@ -1,133 +1,37 @@ - - + + - Debug - AnyCPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F} - Library - Properties - Box.V2.Test.Integration - Box.V2.Test.Integration - v4.5 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - + netcoreapp2.0;net45 + + false + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - smalltestpdf.resx - + + + + + + - - - {602ff1b8-df8b-4cff-88c6-8b34468c45ad} - Box.V2 - + + + - - - + + - - - ResXFileCodeGenerator - smalltestpdf.Designer.cs - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + - - - - - False - - - False - - - False - - - False - - - - - - - - \ No newline at end of file + + diff --git a/Box.V2.Test.Integration/BoxAuthTestIntegration.cs b/Box.V2.Test.Integration/BoxAuthTestIntegration.cs deleted file mode 100644 index 66730ebbc..000000000 --- a/Box.V2.Test.Integration/BoxAuthTestIntegration.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Threading.Tasks; -using Box.V2.Config; -using Box.V2.JWTAuth; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxAuthTestIntegration : BoxResourceManagerTestIntegration - { - public new const string ClientId = "YOUR_CLIENT_ID"; - public new const string ClientSecret = "YOUR_CLIENT_SECRET"; - public const string EnterpriseId = "YOUR_ENTERPRISE_ID"; - public const string PublicKeyID = "YOUR_PUBLIC_KEY_ID"; - public const string PrivateKey = "-----BEGIN ENCRYPTED PRIVATE KEY-----\nYOUR_PRIVATE_KEY\n-----END ENCRYPTED PRIVATE KEY-----\n"; - public const string Passphrase = "YOUR_PASSPHRASE"; - - [TestMethod] - public async Task RetriesWithNewJWTAssertionOnErrorResponseAndSucceeds() - { - var config = new BoxConfigBuilder(ClientId, ClientSecret, EnterpriseId, PrivateKey, Passphrase, PublicKeyID) - .Build(); - var session = new BoxJWTAuth(config); - var adminToken = await session.AdminTokenAsync(); - AdminClient = session.AdminClient(adminToken); - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxCollaborationWhitelistManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxCollaborationWhitelistManagerIntegrationTest.cs similarity index 89% rename from Box.V2.Test.IntegrationNew/BoxCollaborationWhitelistManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxCollaborationWhitelistManagerIntegrationTest.cs index ae5801867..2084837fc 100644 --- a/Box.V2.Test.IntegrationNew/BoxCollaborationWhitelistManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxCollaborationWhitelistManagerIntegrationTest.cs @@ -1,9 +1,9 @@ using System.Linq; using System.Threading.Tasks; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxCollaborationWhitelistManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxCollaborationWhitelistManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxCollaborationWhitelistManagerTestIntegration.cs deleted file mode 100644 index b58951326..000000000 --- a/Box.V2.Test.Integration/BoxCollaborationWhitelistManagerTestIntegration.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Box.V2.Config; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxCollaborationWhitelistManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task GetAllUserWhitelist_LiveSession_ValidResponse() - { - var allUserWhitelistItems = await Client.CollaborationWhitelistManager.GetAllCollaborationWhitelistExemptUsersAsync(3, null, true); - List allUserCollabWhitelist = allUserWhitelistItems.Entries; - - foreach (BoxCollaborationWhitelistTargetEntry userWhitelist in allUserCollabWhitelist) - { - Assert.AreEqual("collaboration_whitelist_exempt_target", userWhitelist.Type); - Assert.IsNotNull(userWhitelist, "collab whitelist was not retrieved"); - Assert.IsNotNull(userWhitelist.Id, "collaboration whitelist id does not exist"); - } - } - - [TestMethod] - public async Task GetAllDomainWhitelist_LiveSession_ValidResponse() - { - var allCollabWhitelistItems = await Client.CollaborationWhitelistManager.GetAllCollaborationWhitelistEntriesAsync(4, null, true); - List allCollabWhitelist = allCollabWhitelistItems.Entries; - - foreach (BoxCollaborationWhitelistEntry whitelist in allCollabWhitelist) - { - Assert.AreEqual("collaboration_whitelist_entry", whitelist.Type); - Assert.IsNotNull(whitelist, "collaboration whitelist was not retrieved"); - Assert.IsNotNull(whitelist.Id, "collaboration whitelist ID was not retrieved"); - } - } - - [TestMethod] - public async Task UserWhitelist_LiveSession_ValidResponse() - { - var userID = "286842893"; - - var userWhitelist = await Client.CollaborationWhitelistManager.AddCollaborationWhitelistExemptUserAsync(userID); - var retrievedUserWhitelist = await Client.CollaborationWhitelistManager.GetCollaborationWhitelistExemptUserAsync(userWhitelist.Id); - var deletedUserWhitelist = await Client.CollaborationWhitelistManager.DeleteCollaborationWhitelistExemptUserAsync(userWhitelist.Id); - - Assert.IsNotNull(userWhitelist, "Was not able to whitelist user"); - Assert.AreEqual("collaboration_whitelist_exempt_target", userWhitelist.Type); - Assert.AreEqual(userID, userWhitelist.User.Id); - - Assert.IsNotNull(retrievedUserWhitelist, "Was not able to retrieve whitelist for user"); - Assert.AreEqual(userWhitelist.Id, retrievedUserWhitelist.Id); - Assert.AreEqual("collaboration_whitelist_exempt_target", retrievedUserWhitelist.Id); - - Assert.IsTrue(deletedUserWhitelist, "User collab whitelist was unable to be deleted"); - } - - [TestMethod] - public async Task DomainWhitelist_LiveSession_ValidResponse() - { - var domain = "test6.com"; - - var whiteList = await Client.CollaborationWhitelistManager.AddCollaborationWhitelistEntryAsync(domain, Constants.WhitelistDirections.Both); - var retrievedWhiteList = await Client.CollaborationWhitelistManager.GetCollaborationWhitelistEntryAsync(whiteList.Id); - var deletedWhiteList = await Client.CollaborationWhitelistManager.DeleteCollaborationWhitelistEntryAsync(whiteList.Id); - - Assert.IsNotNull(whiteList, "Was not able to create collab whitelist for domain"); - Assert.AreEqual("collaboration_whitelist_entry", whiteList.Id); - Assert.AreEqual(domain, whiteList.Domain); - Assert.AreEqual("both", whiteList.Direction); - - Assert.IsNotNull(retrievedWhiteList, "Was not able to retrieve collab whitelist by ID"); - Assert.AreEqual(retrievedWhiteList.Id, whiteList.Id); - Assert.AreEqual("collaboration_whitelist_entry", retrievedWhiteList.Type); - - Assert.IsTrue(deletedWhiteList, "Collab whitelist was unable to be deleted"); - } - } -} diff --git a/Box.V2.Test.Integration/BoxCollaborationsManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxCollaborationsManagerTestIntegration.cs deleted file mode 100644 index b708f855f..000000000 --- a/Box.V2.Test.Integration/BoxCollaborationsManagerTestIntegration.cs +++ /dev/null @@ -1,158 +0,0 @@ -using System.Collections.Generic; -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxCollaborationsManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task CollaborationsOnFolderWorkflow_LiveSession_ValidResponse() - { - const string FolderId = "1927307787"; - - // Add Collaboration - var addRequest = new BoxCollaborationRequest() - { - Item = new BoxRequestEntity() - { - Id = FolderId, - Type = BoxType.folder - }, - AccessibleBy = new BoxCollaborationUserRequest() - { - Login = "BoxWinUser@box.com" - }, - Role = "viewer" - }; - - BoxCollaboration collab = await Client.CollaborationsManager.AddCollaborationAsync(addRequest, notify: false); - - Assert.AreEqual(FolderId, collab.Item.Id, "Folder and collaboration folder id do not match"); - Assert.AreEqual(BoxCollaborationRoles.Viewer, collab.Role, "Incorrect collaboration role"); - - // Edit Collaboration - var editRequest = new BoxCollaborationRequest() - { - Id = collab.Id, - Role = BoxCollaborationRoles.Editor, - CanViewPath = true - }; - - BoxCollaboration editCollab = await Client.CollaborationsManager.EditCollaborationAsync(editRequest); - - Assert.AreEqual(collab.Id, editCollab.Id, "Id of original collaboration and updated collaboration do not match"); - Assert.AreEqual(BoxCollaborationRoles.Editor, editCollab.Role, "Incorrect updated role"); - - // get existing collaboration - var existingCollab = await Client.CollaborationsManager.GetCollaborationAsync(collab.Id, fields: new List() { "can_view_path" }); - Assert.IsTrue(existingCollab.CanViewPath.Value, "failed to retrieve existing collab with specific fields"); - - // test getting list of collaborations on folder - var collabs = await Client.FoldersManager.GetCollaborationsAsync(FolderId); - Assert.AreEqual(4, collabs.Entries.Count, "Failed to get correct number of folder collabs."); - - // Test Remove Collaboration - var success = await Client.CollaborationsManager.RemoveCollaborationAsync(collab.Id); - - Assert.IsTrue(success, "Collaboration deletion was unsucessful"); - } - - // Test to add collaboration by Box User ID and Box Group ID. - [TestMethod] - public async Task AddGroupCollaboration_File_Fields_ValidResponse() - { - const string FileId = "238288183114"; - const string GroupId = "176708848"; - const string UserId = "349294186"; - - // Add Group Collaboration - var addGroupRequest = new BoxCollaborationRequest() - { - Item = new BoxRequestEntity() - { - Id = FileId, - Type = BoxType.file - }, - AccessibleBy = new BoxCollaborationUserRequest() - { - Type = BoxType.group, - Id = GroupId - }, - Role = "viewer" - }; - - //Add User Collaboration - var addUserRequest = new BoxCollaborationRequest() - { - Item = new BoxRequestEntity() - { - Id = FileId, - Type = BoxType.file - }, - AccessibleBy = new BoxCollaborationUserRequest() - { - Type = BoxType.user, - Id = UserId - }, - Role = "editor" - }; - _ = await Client.CollaborationsManager.AddCollaborationAsync(addGroupRequest, notify: false); - _ = await Client.CollaborationsManager.AddCollaborationAsync(addUserRequest, notify: false); - } - - [TestMethod] - public async Task CollaborationsOnFileWorkflow_LiveSession_ValidResponse() - { - const string FileId = "100699285359"; - - // Add Collaboration - var addRequest = new BoxCollaborationRequest() - { - Item = new BoxRequestEntity() - { - Id = FileId, - Type = BoxType.file - }, - AccessibleBy = new BoxCollaborationUserRequest() - { - Login = "BoxWinUser@box.com" - }, - Role = "viewer" - }; - - BoxCollaboration collab = await Client.CollaborationsManager.AddCollaborationAsync(addRequest, notify: false); - - Assert.AreEqual(FileId, collab.Item.Id, "File and collaboration file id do not match"); - Assert.AreEqual(BoxCollaborationRoles.Viewer, collab.Role, "Incorrect collaboration role"); - - - // TODO: Edit Collaboration - var editRequest = new BoxCollaborationRequest() - { - Id = collab.Id, - Role = BoxCollaborationRoles.Editor - }; - - BoxCollaboration editCollab = await Client.CollaborationsManager.EditCollaborationAsync(editRequest); - - Assert.AreEqual(collab.Id, editCollab.Id, "Id of original collaboration and updated collaboration do not match"); - Assert.AreEqual(BoxCollaborationRoles.Editor, editCollab.Role, "Incorrect updated role"); - - // get existing collaboration - var existingCollab = await Client.CollaborationsManager.GetCollaborationAsync(collab.Id); - Assert.IsTrue(existingCollab.Item.Id == FileId, "failed to retrieve existing collab"); - - // test getting list of collaborations on file - var collabs = await Client.FilesManager.GetCollaborationsAsync(FileId); - Assert.AreEqual(4, collabs.Entries.Count, "Failed to get correct number of file collabs."); - - // Test Remove Collaboration - var success = await Client.CollaborationsManager.RemoveCollaborationAsync(collab.Id); - - Assert.IsTrue(success, "Collaboration deletion was unsucessful"); - } - } -} diff --git a/Box.V2.Test.Integration/BoxCollectionsManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxCollectionsManagerTestIntegration.cs deleted file mode 100644 index 2289b3ee2..000000000 --- a/Box.V2.Test.Integration/BoxCollectionsManagerTestIntegration.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxCollectionsManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task Collections_LiveSession() - { - var collections = await Client.CollectionsManager.GetCollectionsAsync(); - var favorites = collections.Entries.FirstOrDefault(c => c.CollectionType == "favorites"); - Assert.IsNotNull(favorites, "Could not find 'favorites' collection"); - - //add a file to favorites - const string FileId = "16894944949"; - var bcr = new BoxCollectionsRequest() { Collections = new List() { new BoxRequestEntity() { Id = favorites.Id } } }; - var updatedFile = await Client.CollectionsManager.CreateOrDeleteCollectionsForFileAsync(FileId, bcr); - Assert.AreEqual(updatedFile.Id, FileId, "Could not add item to favorites collection"); - - //get list of collection items - var items = await Client.CollectionsManager.GetCollectionItemsAsync(favorites.Id); - Assert.AreEqual(1, items.Entries.Count, "Wrong number of items in favorites collection"); - Assert.AreEqual(items.Entries[0].Id, FileId, "Incorrect file in favorites collection"); - - //clear out favorites - bcr = new BoxCollectionsRequest() { Collections = new List() }; - updatedFile = await Client.CollectionsManager.CreateOrDeleteCollectionsForFileAsync(FileId, bcr); - Assert.AreEqual(updatedFile.Id, FileId, "Could not remove item from favorites collection"); - items = await Client.CollectionsManager.GetCollectionItemsAsync(favorites.Id); - Assert.AreEqual(0, items.Entries.Count, "Wrong number of items in favorites collection"); - } - } -} diff --git a/Box.V2.Test.Integration/BoxCommentsManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxCommentsManagerTestIntegration.cs deleted file mode 100644 index 496be2597..000000000 --- a/Box.V2.Test.Integration/BoxCommentsManagerTestIntegration.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxCommentsManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task CommentsWorkflow_LiveSession_ValidResponse() - { - const string FileId = "16894947279"; - const string Message = "this is a test Comment"; - - // Create a comment with message - var addReq = new BoxCommentRequest() - { - Message = Message, - Item = new BoxRequestEntity() - { - Id = FileId, - Type = BoxType.file - } - }; - - BoxComment c = await Client.CommentsManager.AddCommentAsync(addReq); - - Assert.AreEqual(FileId, c.Item.Id, "Comment was added to incorrect file"); - Assert.AreEqual(BoxType.file.ToString(), c.Item.Type, "Comment was not added to a file"); - Assert.AreEqual(BoxType.comment.ToString(), c.Type, "Returned object is not a comment"); - Assert.AreEqual(Message, c.Message, "Wrong comment added to file"); - - // Create a comment with tagged message - var messageWithTag = "this is an tagged @[215917383:DisplayName] test comment"; - - var addReqWithTag = new BoxCommentRequest() - { - Message = messageWithTag, - Item = new BoxRequestEntity() - { - Id = FileId, - Type = BoxType.file - } - }; - - BoxComment cWithTag = await Client.CommentsManager.AddCommentAsync(addReqWithTag); - - Assert.AreEqual(FileId, cWithTag.Item.Id, "Comment was added to incorrect file"); - Assert.AreEqual(BoxType.file.ToString(), cWithTag.Item.Type, "Comment was not added to a file"); - Assert.AreEqual(BoxType.comment.ToString(), cWithTag.Type, "Returned object is not a comment"); - Assert.AreEqual(messageWithTag, cWithTag.Message, "Wrong comment added to file"); - - // Get comment details - BoxComment cInfo = await Client.CommentsManager.GetInformationAsync(c.Id); - - Assert.AreEqual(c.Id, cInfo.Id, "two comment objects have different ids"); - Assert.AreEqual(BoxType.comment.ToString(), cInfo.Type, "returned object is not a comment"); - - // Update the comment - const string UpdateMessage = "this is an updated test comment"; - - var updateReq = new BoxCommentRequest() - { - Message = UpdateMessage - }; - - BoxComment cUpdate = await Client.CommentsManager.UpdateAsync(c.Id, updateReq); - - Assert.AreEqual(c.Id, cUpdate.Id, "Wrong comment was updated"); - Assert.AreEqual(BoxType.comment.ToString(), cUpdate.Type, "returned type of update is not a comment"); - Assert.AreEqual(UpdateMessage, cUpdate.Message, "Comment was not updated with correct string"); - - // Deleting a comment - var success = await Client.CommentsManager.DeleteAsync(c.Id); - - Assert.AreEqual(true, success, "Unsuccessful comment delete"); - } - } -} diff --git a/Box.V2.Test.Integration/BoxDevicePinManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxDevicePinManagerTestIntegration.cs deleted file mode 100644 index 5f19c74b6..000000000 --- a/Box.V2.Test.Integration/BoxDevicePinManagerTestIntegration.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxDevicePinManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task EnterpriseDevicePins_LiveSession() - { - const string EnterpriseId = "440385"; - - //get enterprise device pins - var pins = await Client.DevicePinManager.GetEnterpriseDevicePinsAsync(EnterpriseId, autoPaginate: true); - Assert.IsTrue(pins.Entries.Count == 1, "Failed to get enterprise device pins."); - - //get device pin by id - var devicePin = await Client.DevicePinManager.GetDevicePin(pins.Entries[0].Id); - Assert.AreEqual(pins.Entries[0].Id, devicePin.Id, "Failed to get device pin by id."); - - // This test code is disabled because the device pins need to be created manually and we don't want to delete our test device pin. - //delete device pin - //var result = await _client.DevicePinManager.DeleteDevicePin(devicePin.Id); - //Assert.IsTrue(result, "Failed to delete device pin"); - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxEventsManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxEventsManagerIntegrationTest.cs similarity index 93% rename from Box.V2.Test.IntegrationNew/BoxEventsManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxEventsManagerIntegrationTest.cs index f530224f4..4960272c5 100644 --- a/Box.V2.Test.IntegrationNew/BoxEventsManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxEventsManagerIntegrationTest.cs @@ -2,10 +2,10 @@ using System.Linq; using System.Threading.Tasks; using Box.V2.Models; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxEventsManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxEventsManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxEventsManagerTestIntegration.cs deleted file mode 100644 index 390490d05..000000000 --- a/Box.V2.Test.Integration/BoxEventsManagerTestIntegration.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxEventsManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task EnterpriseEvents_LiveSession() - { - var startDate = Convert.ToDateTime("9/18/2017 11:51:12 PM"); - var endDate = Convert.ToDateTime("9/24/2017 11:51:12 PM"); - var expectedChunkSize = 107; - - var events = await Client.EventsManager.EnterpriseEventsAsync(createdAfter: startDate, createdBefore: endDate); - var eventsMissingOneParam = await Client.EventsManager.EnterpriseEventsAsync(createdAfter: startDate, createdBefore: null); - var eventsMissingBothParam = await Client.EventsManager.EnterpriseEventsAsync(createdAfter: null, createdBefore: null); - - Assert.IsNotNull(events, "Failed to retrieve enterprise events"); - Assert.AreEqual(events.ChunkSize, expectedChunkSize); - Assert.IsTrue(events.Entries.Count > 0, "Failed to retrieve enterprise events"); - - Assert.IsNotNull(eventsMissingOneParam, "Failed to retrieve enterprise events for missing createdBefore param"); - Assert.IsTrue(eventsMissingOneParam.Entries.Count > 0, "Failed to retrieve enterprise events with missing createdBefore param"); - - Assert.IsNotNull(eventsMissingBothParam, "Failed to retrieve enterprise events for missing all params"); - Assert.IsTrue(eventsMissingBothParam.Entries.Count > 0, "Failed to retrieve enterprise events with missing all params"); - } - - [TestMethod] - public async Task UserEvents_LiveSession() - { - const string FileId = "16894943599"; - - var events = await Client.EventsManager.UserEventsAsync(); - Assert.IsNotNull(events.NextStreamPosition, "Failed to retrieve user next_stream_position"); - - var fileLock = await Client.FilesManager.LockAsync(new BoxFileLockRequest() { Lock = new BoxFileLock() { IsDownloadPrevented = false } }, FileId); - var result = await Client.FilesManager.UnLock(FileId); - - BoxEventCollection newEvents = null; - var keepChecking = true; - var maxTimesToCheck = 10; - while (keepChecking && maxTimesToCheck > 0) - { - newEvents = await Client.EventsManager.UserEventsAsync(streamPosition: events.NextStreamPosition); - if (newEvents.Entries.Count > 0) - { - keepChecking = false; - } - else - { - maxTimesToCheck--; - Thread.Sleep(1000); - } - } - - var commentEvent = newEvents.Entries.SingleOrDefault(e => e.EventType == "LOCK_CREATE"); - Assert.IsNotNull(commentEvent, "Failed to retrieve user events"); - } - - [TestMethod] - public async Task LongPollUserEvents_LiveSession() - { - const string FileId = "16894943599"; - - var incomingEvents = new ConcurrentBag(); - - //first we need to get the latest stream position - var events = await Client.EventsManager.UserEventsAsync(); - - var cancelSource = new CancellationTokenSource(TimeSpan.FromSeconds(15)); - var t = await Task.Factory.StartNew(async (opts) => - { - await Client.EventsManager.LongPollUserEvents(events.NextStreamPosition, - (newEvents) => - { - //do something with incoming new events - //Debug.WriteLine("Received {0} new event(s)", newEvents.Entries.Count); - newEvents.Entries.ForEach(e => incomingEvents.Add(e)); - }, cancelSource.Token, retryTimeoutOverride: 5); - }, - TaskCreationOptions.LongRunning, - cancelSource.Token); - - var tasks = new ConcurrentBag - { - t - }; - - Thread.Sleep(1000); - - //make some events - var fileLock = await Client.FilesManager.LockAsync(new BoxFileLockRequest() { Lock = new BoxFileLock() { IsDownloadPrevented = false } }, FileId); - var result = await Client.FilesManager.UnLock(FileId); - - try - { - Task.WaitAll(tasks.ToArray()); - } - catch (AggregateException e) - { - //Console.WriteLine("\nAggregateException thrown with the following inner exceptions:"); - foreach (var v in e.InnerExceptions) - { - if (v is TaskCanceledException) - { - //Console.WriteLine(" TaskCanceledException: Task {0}", ((TaskCanceledException)v).Task.Id); - var num = incomingEvents.Count; - Assert.IsTrue(num >= 2, "Failed to get correct event count using long polling."); - } - else - { - //Console.WriteLine(" Exception: {0}", v.GetType().Name); - Assert.Fail("Failed to get events using long polling."); - } - } - } - finally - { - cancelSource.Dispose(); - } - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxFilesManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs similarity index 98% rename from Box.V2.Test.IntegrationNew/BoxFilesManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs index bc3e88a1a..99972e32d 100644 --- a/Box.V2.Test.IntegrationNew/BoxFilesManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs @@ -3,12 +3,12 @@ using System.IO; using System.Threading.Tasks; using Box.V2.Models; -using Box.V2.Test.IntegrationNew.Configuration; -using Box.V2.Test.IntegrationNew.Configuration.Extensions; +using Box.V2.Test.Integration.Configuration; +using Box.V2.Test.Integration.Configuration.Extensions; using Box.V2.Utility; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxFilesManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxFilesManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxFilesManagerTestIntegration.cs deleted file mode 100644 index 9905d957e..000000000 --- a/Box.V2.Test.Integration/BoxFilesManagerTestIntegration.cs +++ /dev/null @@ -1,624 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Box.V2.Config; -using Box.V2.Models; -using Box.V2.Utility; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxFilesManagerTestIntegration : BoxResourceManagerTestIntegration - { - //[TestMethod] - //public async Task GetStreamResponse() - //{ - // const string pdfFileId = "16894929979"; - // const int totalPages = 227; - // var filePreview = await _client.FilesManager.GetFilePreviewAsync(pdfFileId, 1); - - // Assert.AreEqual(1, filePreview.CurrentPage, "Invalid current page"); - // Assert.AreEqual(totalPages, filePreview.TotalPages, "Invalid total pages"); - // Assert.AreEqual(HttpStatusCode.OK, filePreview.ReturnedStatusCode, "Invalid status code"); - //} - - [TestMethod] - public async Task RestoreFile_Valid_Response() - { - const string FileId = "238288183114"; - var fileRequest = new BoxFileRequest() - { - Id = FileId - }; - _ = await Client.FilesManager.RestoreTrashedAsync(fileRequest); - } - - [TestMethod] - public async Task GetInformation_Fields_ValidResponse() - { - const string FileId = "16894947279"; - var file = await Client.FilesManager.GetInformationAsync(FileId, new List { BoxFile.FieldName, BoxFile.FieldModifiedAt, BoxFile.FieldOwnedBy }); - - Assert.AreEqual(FileId, file.Id, "Incorrect file id"); - Assert.IsNotNull(file.Name, "File Name is null"); - Assert.IsNotNull(file.ModifiedAt, "ModifiedAt field is null"); - Assert.IsNotNull(file.OwnedBy, "OwnedBy field is null"); - } - - [TestMethod] - public async Task GetInformation_Fields_Metadata_ValidResponse() - { - const string FileId = "97274928659"; - var file = await Client.FilesManager.GetInformationAsync(FileId, fields: new List { "metadata.enterprise_440385.testtemplate" }); - - Assert.AreEqual(FileId, file.Id, "Incorrect file id"); - Assert.IsNotNull(file.Metadata, "Metadata is null"); - Assert.IsNotNull(file.Metadata["enterprise_440385"], "Scope could not be found"); - - file = await Client.FilesManager.GetInformationAsync(FileId, fields: new List { "metadata.enterprise.testtemplate" }); - - Assert.AreEqual(FileId, file.Id, "Incorrect file id"); - Assert.IsNotNull(file.Metadata, "Metadata is null"); - Assert.IsNotNull(file.Metadata["enterprise"], "Scope could not be found"); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - [ExpectedException(typeof(TimeoutException))] - public async Task Download_ValidRequest_Timeout() - { - var timeout = new TimeSpan(0, 0, 0, 0, 1); // 1ms timeout, should always cancel the request - const string FileId = "16894947279"; - _ = await Client.FilesManager.DownloadStreamAsync(FileId, timeout: timeout); - } - - [TestMethod] - public async Task Download_ValidRequest_ValidStream() - { - const string FileId = "16894947279"; - var responseStream = await Client.FilesManager.DownloadStreamAsync(FileId); - Assert.IsNotNull(responseStream, "Response stream is null"); - } - - [TestMethod] - public async Task Download_ValidRequest_ValidStreamWithRange() - { - const string FileId = "16894947279"; - var responseStream = await Client.FilesManager.DownloadStreamAsync(FileId, null, null, 10, 20); - Assert.IsNotNull(responseStream, "Response stream is null"); - - using (var reader = new StreamReader(responseStream)) - { - var value = reader.ReadToEnd(); - - // Make sure it's the parts range - Assert.AreEqual(11, value.Length); - } - } - - [TestMethod] - public async Task GetThumbnail_ValidRequest_ValidThumbnail() - { - const string FileId = "102438629524"; - - using (Stream stream = await Client.FilesManager.GetThumbnailAsync(FileId, 256, 256)) - using (var fs = new FileStream(string.Format(GetSaveFolderPath(), "thumb.png"), FileMode.OpenOrCreate)) - { - Assert.IsNotNull(stream, "Stream is Null"); - - await stream.CopyToAsync(fs); - - Assert.IsNotNull(fs, "FileStream is null"); - } - } - - [TestMethod] - public async Task GetSharedLink_ValidRequest_ValidSharedLink() - { - var imageFileId1 = "16894947279"; - - var linkReq = new BoxSharedLinkRequest() - { - Access = BoxSharedLinkAccessType.open - }; - - BoxFile fileLink = await Client.FilesManager.CreateSharedLinkAsync(imageFileId1, linkReq); - Assert.AreEqual(BoxSharedLinkAccessType.open, fileLink.SharedLink.Access); - } - - [TestMethod] - public async Task GetRepresentations_ValidRequest_ValidRepresentation() - { - var representationsMissingHeader = await Client.FilesManager.GetRepresentationsAsync(new BoxRepresentationRequest() - { - FileId = "16894927933", - }); - - var representationsAllHeaders = await Client.FilesManager.GetRepresentationsAsync(new BoxRepresentationRequest() - { - FileId = "16894927933", - XRepHints = Constants.RepresentationTypes.Pdf, - SetContentDispositionFilename = "New Name", - SetContentDispositionType = Constants.ContentDispositionTypes.Inline, - HandleRetry = true - }); - - var representationsMultipleXRepHints = await Client.FilesManager.GetRepresentationsAsync(new BoxRepresentationRequest() - { - FileId = "16894927933", - XRepHints = Constants.RepresentationTypes.ImageMedium - }); - - Assert.IsNotNull(representationsMissingHeader.Entries, "Failed to generate a representation for file"); - Assert.AreEqual("pdf", representationsAllHeaders.Entries[0].Representation); - Assert.IsNotNull(representationsMultipleXRepHints.Entries[1], "Failed to generate second representation for file"); - } - - [TestMethod] - public async Task Watermark_Files_CRUD() - { - const string FileId = "16894944949"; - - var mylist = new List(new string[] { "watermark_info" }); - var file = await Client.FilesManager.GetInformationAsync(FileId, mylist); - Assert.IsFalse(file.WatermarkInfo.IsWatermarked); - - var watermark = await Client.FilesManager.ApplyWatermarkAsync(FileId); - Assert.IsNotNull(watermark, "Failed to apply watermark to file"); - - file = await Client.FilesManager.GetInformationAsync(FileId, mylist); - Assert.IsTrue(file.WatermarkInfo.IsWatermarked); - - var fetchedWatermark = await Client.FilesManager.GetWatermarkAsync(FileId); - Assert.IsNotNull(fetchedWatermark, "Failed to fetch watermark of file"); - - var result = await Client.FilesManager.RemoveWatermarkAsync(FileId); - Assert.IsTrue(result, "Failed to remove watermark from file"); - - } - - [TestMethod] - public async Task FileWorkflow_ValidRequest_ValidResponse() - { - //file Ids of the two files to download - var imageFileId1 = "16894947279"; - var imageFileId2 = "16894946307"; - - // paths to store the two downloaded files - var dlPath1 = string.Format(GetSaveFolderPath(), "thumbnail1.png"); - var dlPath2 = string.Format(GetSaveFolderPath(), "thumbnail2.png"); - - //download 2 files - using (var fs = new FileStream(dlPath1, FileMode.OpenOrCreate)) - { - Stream stream = await Client.FilesManager.DownloadStreamAsync(imageFileId1); - await stream.CopyToAsync(fs); - } - - using (var fs = new FileStream(dlPath2, FileMode.OpenOrCreate)) - { - Stream stream = await Client.FilesManager.DownloadStreamAsync(imageFileId2); - await stream.CopyToAsync(fs); - } - - // File name to use to upload files - var uploadFileName = "testUpload.png"; - - // Upload file at dlPath1 - BoxFile file; - using (var fs = new FileStream(dlPath1, FileMode.Open)) - { - var req = new BoxFileRequest() - { - Name = uploadFileName, - Parent = new BoxRequestEntity() { Id = "0" } - }; - - file = await Client.FilesManager.UploadAsync(req, fs); - } - - Assert.AreEqual(uploadFileName, file.Name, "Incorrect file name"); - Assert.AreEqual("0", file.Parent.Id, "Incorrect destination folder"); - - // Upload file at dlPath2 as new version of 'file' - BoxFile newFileVersion; - using (var fs = new FileStream(dlPath2, FileMode.Open)) - { - newFileVersion = await Client.FilesManager.UploadNewVersionAsync(uploadFileName, file.Id, fs, file.ETag); - } - - Assert.AreEqual(newFileVersion.Name, uploadFileName); - Assert.AreEqual(newFileVersion.Parent.Id, "0"); - - //View file versions (Requires upgraded acct) - BoxCollection fileVersions = await Client.FilesManager.ViewVersionsAsync(newFileVersion.Id); - - Assert.AreEqual(fileVersions.TotalCount, 1, "Incorrect number of versions"); - - foreach (var f in fileVersions.Entries) - { - Assert.AreEqual(uploadFileName, f.Name); - } - - // Update the file name of a file - var updateName = GetUniqueName(); - - var updateReq = new BoxFileRequest() - { - Id = file.Id, - Name = updateName - }; - BoxFile fileUpdate = await Client.FilesManager.UpdateInformationAsync(updateReq); - - Assert.AreEqual(file.Id, fileUpdate.Id, "File Ids are not the same"); - Assert.AreEqual(updateName, fileUpdate.Name, "File Names are not the same"); - - // Test create shared link - var linkReq = new BoxSharedLinkRequest() - { - Access = BoxSharedLinkAccessType.open - }; - BoxFile fileWithLink = await Client.FilesManager.CreateSharedLinkAsync(newFileVersion.Id, linkReq); - - Assert.AreEqual(BoxSharedLinkAccessType.open, fileWithLink.SharedLink.Access, "Incorrect access for shared link"); - - // Copy file in same folder - var copyName = GetUniqueName(); - var copyReq = new BoxFileRequest() - { - Id = fileWithLink.Id, - Name = copyName, - Parent = new BoxRequestEntity() { Id = "0" } - }; - BoxFile fileCopy = await Client.FilesManager.CopyAsync(copyReq); - - Assert.AreEqual(fileCopy.Name, copyName, "Incorrect Name for copied file"); - Assert.AreEqual(fileCopy.Parent.Id, "0", "Incorrect parent folder for copied file"); - - // Test get file information - _ = await Client.FilesManager.GetInformationAsync(fileWithLink.Id); - - Assert.AreEqual(updateName, fileWithLink.Name, "File name is incorrect"); - Assert.AreEqual("0", fileWithLink.Parent.Id, "Parent folder is incorrect"); - - // Delete both files - await Client.FilesManager.DeleteAsync(fileCopy.Id, fileCopy.ETag); - await Client.FilesManager.DeleteAsync(fileWithLink.Id, fileWithLink.ETag); - } - - [TestMethod] - public async Task BatchGetInformation_ValidRequest_ValidResponse() - { - const string FileId = "16894947279"; - - /*** Arrange ***/ - var tasks = new List>(); - - var size = 574732; - var numTasks = 5; - - /*** Act ***/ - for (var i = 0; i < numTasks; ++i) - { - tasks.Add(Client.FilesManager.GetInformationAsync(FileId)); - } - - await Task.WhenAll(tasks); - - /*** Assert ***/ - foreach (var t in tasks) - { - Assert.AreEqual(size, (await t).Size); - } - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public void GetNumberOfParts_Utility_Function_CorrectPartNumber() - { - // This file size is expected to divide evenly with the partSize - long fileSize = 209717000; - // This file size is expected to have a small remainder after dividing with partSize - long divisibleFileSize = 209715200; - long partSize = 8388608; - - var numberOfPartsNoRemainder = UploadUsingSessionInternal.GetNumberOfParts(divisibleFileSize, partSize); - var numberOfPartsWithRemainder = UploadUsingSessionInternal.GetNumberOfParts(fileSize, partSize); - - Assert.AreEqual(numberOfPartsNoRemainder, 25); - Assert.AreEqual(numberOfPartsWithRemainder, 26); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task UploadFileInSession_AbortRequest_FileNotCommmited() - { - long fileSize = 50000000; - MemoryStream fileInMemoryStream = GetBigFileInMemoryStream(fileSize); - var remoteFileName = "UploadedUsingSession-" + DateTimeOffset.Now.TimeOfDay; - var parentFolderId = "0"; - - var boxFileUploadSessionRequest = new BoxFileUploadSessionRequest() - { - FolderId = parentFolderId, - FileName = remoteFileName, - FileSize = fileSize - }; - // Create Upload Session - BoxFileUploadSession boxFileUploadSession = await Client.FilesManager.CreateUploadSessionAsync(boxFileUploadSessionRequest); - BoxSessionEndpoint boxSessionEndpoint = boxFileUploadSession.SessionEndpoints; - var abortUri = new Uri(boxSessionEndpoint.Abort); - var uploadPartUri = new Uri(boxSessionEndpoint.UploadPart); - var partSize = boxFileUploadSession.PartSize; - long.TryParse(partSize, out var partSizeLong); - var numberOfParts = UploadUsingSessionInternal.GetNumberOfParts(fileSize, partSizeLong); - - // Upload parts in the session - await UploadPartsInSessionAsync(uploadPartUri, numberOfParts, partSizeLong, fileInMemoryStream, fileSize); - - // Assert file is not committed/uploaded to box yet - Assert.IsFalse(await DoesFileExistInFolder(parentFolderId, remoteFileName)); - - // Abort - await Client.FilesManager.DeleteUploadSessionAsync(abortUri); - - // Assert file is not committed/uploaded to box - Assert.IsFalse(await DoesFileExistInFolder(parentFolderId, remoteFileName)); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task UploadFileInSession_CommitSession_FilePresent() - { - long fileSize = 50000000; - MemoryStream fileInMemoryStream = GetBigFileInMemoryStream(fileSize); - var remoteFileName = "UploadedUsingSession-" + DateTimeOffset.Now.TimeOfDay; - var parentFolderId = "0"; - - var boxFileUploadSessionRequest = new BoxFileUploadSessionRequest() - { - FolderId = parentFolderId, - FileName = remoteFileName, - FileSize = fileSize - }; - // Create Upload Session - BoxFileUploadSession boxFileUploadSession = await Client.FilesManager.CreateUploadSessionAsync(boxFileUploadSessionRequest); - BoxSessionEndpoint boxSessionEndpoint = boxFileUploadSession.SessionEndpoints; - var listPartsUri = new Uri(boxSessionEndpoint.ListParts); - var uploadPartUri = new Uri(boxSessionEndpoint.UploadPart); - var commitUri = new Uri(boxSessionEndpoint.Commit); - var partSize = boxFileUploadSession.PartSize; - long.TryParse(partSize, out var partSizeLong); - var numberOfParts = UploadUsingSessionInternal.GetNumberOfParts(fileSize, partSizeLong); - - // Upload parts in the session - await UploadPartsInSessionAsync(uploadPartUri, numberOfParts, partSizeLong, fileInMemoryStream, fileSize); - - // Assert file is not committed/uploaded to box yet - Assert.IsFalse(await DoesFileExistInFolder(parentFolderId, remoteFileName)); - - // Get upload parts (1 by 1) for Integration testing purposes - var allSessionParts = new List(); - - // var boxSessionParts = await _client.FilesManager.GetSessionUploadedPartsAsync(listPartsUri, 0, 2, true); - var boxSessionParts = await Client.FilesManager.GetSessionUploadedPartsAsync(listPartsUri, null, null, true); - - foreach (var sessionPart in boxSessionParts.Entries) - { - allSessionParts.Add(sessionPart); - } - - /* w/o autopaging - var boxSessionParts = await _client.FilesManager.GetSessionUploadedPartsAsync(listPartsUri, 0, 1); - allSessionParts.AddRange(boxSessionParts.Entries); - - while (allSessionParts.Count < boxSessionParts.TotalCount) - { - boxSessionParts = await _client.FilesManager.GetSessionUploadedPartsAsync(listPartsUri, allSessionParts.Count, 1); - allSessionParts.AddRange(boxSessionParts.Entries); - } - */ - - var sessionPartsForCommit = new BoxSessionParts() { Parts = allSessionParts }; - - // Commit - await Client.FilesManager.CommitSessionAsync(commitUri, Helper.GetSha1Hash(fileInMemoryStream), sessionPartsForCommit); - - // Assert file is committed/uploaded to box - Assert.IsTrue(await DoesFileExistInFolder(parentFolderId, remoteFileName)); - - // Delete file - var fileId = await GetFileId(parentFolderId, remoteFileName); - if (!string.IsNullOrWhiteSpace(fileId)) - { - await Client.FilesManager.DeleteAsync(fileId); - } - - // Assert file has been deleted from Box - Assert.IsFalse(await DoesFileExistInFolder(parentFolderId, remoteFileName)); - } - - [TestMethod] - public async Task UploadFileInSession_Utility_Function_FilePresent() - { - long fileSize = 50000000; - MemoryStream fileInMemoryStream = GetBigFileInMemoryStream(fileSize); - - var remoteFileName = "UploadedUsingSession-" + DateTimeOffset.Now.TimeOfDay; - var newRemoteFileName = "UploadNewVersionUsingSession-" + DateTimeOffset.Now.TimeOfDay; - var parentFolderId = "0"; - - var progressReported = false; - - var progress = new Progress(val => - { - Debug.WriteLine("{0}%", val.progress); - progressReported = true; - }); - - // Call Utility function - await Client.FilesManager.UploadUsingSessionAsync(fileInMemoryStream, remoteFileName, parentFolderId, - null, progress); - - // Assert file is committed/uploaded to box - Assert.IsTrue(await DoesFileExistInFolder(parentFolderId, remoteFileName)); - var fileId = await GetFileId(parentFolderId, remoteFileName); - - // Using previously uploaded Box file, upload a new file version for that Box file - var newBoxFile = await Client.FilesManager.UploadNewVersionUsingSessionAsync(fileInMemoryStream, fileId, newRemoteFileName, - null, progress); - - Assert.IsNotNull(newBoxFile.FileVersion, "Did not successfully upload a new Box file version"); - Assert.IsTrue(progressReported); - - // Delete file - if (!string.IsNullOrWhiteSpace(fileId)) - { - await Client.FilesManager.DeleteAsync(fileId); - } - - // Assert file has been deleted from Box - Assert.IsFalse(await DoesFileExistInFolder(parentFolderId, remoteFileName)); - } - - [TestMethod] - public async Task GetRepresentationContentAsync_E2E() - { - - // Create stream from string content - var assembly = Assembly.GetExecutingAssembly(); - _ = Assembly.GetExecutingAssembly().GetManifestResourceNames(); - using (var fileStream = assembly.GetManifestResourceStream("Box.V2.Test.Integration.Properties.smalltestpdf.resources")) - { - var fileRequest = new BoxFileRequest(); - var parentFolder = new BoxRequestEntity - { - Type = BoxType.folder, - Id = "0" - }; - fileRequest.Parent = parentFolder; - fileRequest.Name = DateTimeOffset.Now.Ticks + ".pdf"; - var file = await Client.FilesManager.UploadAsync(fileRequest, fileStream); - - var repRequest = new BoxRepresentationRequest - { - FileId = file.Id, - XRepHints = "[png?dimensions=1024x1024]" - }; - Stream assetStream = await Client.FilesManager.GetRepresentationContentAsync(repRequest, "1.png"); - - // Delete the file when done - await Client.FilesManager.DeleteAsync(file.Id); - - var memStream = new MemoryStream(); - await assetStream.CopyToAsync(memStream); - var assetBytes = memStream.ToArray(); - - Assert.IsTrue(assetBytes.Length > 4096, "Downlaoded asset contained " + assetBytes.Length + " but should contain more than 4 KB"); - } - } - - #region Private functions - - private string GetSaveFolderPath() - { - var pathUser = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); - return Path.Combine(pathUser, "Downloads") + "\\{0}"; - } - - private MemoryStream GetBigFileInMemoryStream(long fileSize) - { - // Create random data to write to the file. - var dataArray = new byte[fileSize]; - new Random().NextBytes(dataArray); - var memoryStream = new MemoryStream(dataArray); - return memoryStream; - } - - private async Task UploadPartsInSessionAsync(Uri uploadPartsUri, int numberOfParts, long partSize, Stream stream, - long fileSize) - { - for (var i = 0; i < numberOfParts; i++) - { - // Split file as per part size - var partOffset = partSize * i; - Stream partFileStream = UploadUsingSessionInternal.GetFilePart(stream, partSize, partOffset); - var sha = Helper.GetSha1Hash(partFileStream); - partFileStream.Position = 0; - await Client.FilesManager.UploadPartAsync(uploadPartsUri, sha, partOffset, fileSize, partFileStream); - } - } - - private async Task DoesFileExistInFolder(string folderId, string fileName) - { - // TODO: Paging - BoxCollection boxCollection = await Client.FoldersManager.GetFolderItemsAsync(folderId, 1000); - return boxCollection.Entries.Any(item => item.Name == fileName); - } - - private async Task GetFileId(string folderId, string fileName) - { - // TODO: Paging - BoxCollection boxCollection = await Client.FoldersManager.GetFolderItemsAsync(folderId, 1000); - return boxCollection.Entries.FirstOrDefault(item => item.Name == fileName)?.Id; - } - #endregion - - internal static class UploadUsingSessionInternal - { - public static int GetNumberOfParts(long totalSize, long partSize) - { - if (partSize == 0) - { - throw new Exception("Part Size cannot be 0"); - } - - var numberOfParts = Convert.ToInt32(totalSize / partSize); - if (totalSize % partSize != 0) - { - numberOfParts++; - } - return numberOfParts; - } - - public static Stream GetFilePart(Stream stream, long partSize, long partOffset) - { - // Default the buffer size to 4K. - const int BufferSize = 4096; - - var buffer = new byte[BufferSize]; - stream.Position = partOffset; - var partStream = new MemoryStream(); - int bytesRead; - do - { - bytesRead = stream.Read(buffer, 0, 4096); - if (bytesRead > 0) - { - long bytesToWrite = bytesRead; - var shouldBreak = false; - if (partStream.Length + bytesRead >= partSize) - { - bytesToWrite = partSize - partStream.Length; - shouldBreak = true; - } - - partStream.Write(buffer, 0, Convert.ToInt32(bytesToWrite)); - - if (shouldBreak) - { - break; - } - } - } while (bytesRead > 0); - - return partStream; - } - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxFolderManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs similarity index 98% rename from Box.V2.Test.IntegrationNew/BoxFolderManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs index 586538514..488e2b148 100644 --- a/Box.V2.Test.IntegrationNew/BoxFolderManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs @@ -3,10 +3,10 @@ using System.Linq; using System.Threading.Tasks; using Box.V2.Models; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxFolderManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxFoldersManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxFoldersManagerTestIntegration.cs deleted file mode 100644 index 8eb2244d5..000000000 --- a/Box.V2.Test.Integration/BoxFoldersManagerTestIntegration.cs +++ /dev/null @@ -1,284 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Config; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxFoldersManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task RestoreFolder_ValidResponse() - { - const string FolderId = "44086997331"; - var folderRequest = new BoxFolderRequest() - { - Id = FolderId - }; - _ = await Client.FoldersManager.RestoreTrashedFolderAsync(folderRequest); - } - - [TestMethod] - public async Task GetFolder_LiveSession_ValidResponse() - { - await AssertFolderContents(Client); - } - - [TestMethod] - public async Task GetFolder_LiveSession_ValidResponse_GzipCompression() - { - var boxConfig = new BoxConfigBuilder(ClientId, ClientSecret, RedirectUri) - .SetAcceptEncoding(CompressionType.gzip) - .Build(); - var boxClient = new BoxClient(boxConfig, Auth); - await AssertFolderContents(boxClient); - } - - [TestMethod] - public async Task GetFolder_LiveSession_ValidResponse_DeflateCompression() - { - var boxConfig = new BoxConfigBuilder(ClientId, ClientSecret, RedirectUri) - .SetAcceptEncoding(CompressionType.deflate) - .Build(); - var boxClient = new BoxClient(boxConfig, Auth); - await AssertFolderContents(boxClient); - } - - private static async Task AssertFolderContents(BoxClient boxClient) - { - const int TotalCount = 11; - const int NumFiles = 9; - const int NumFolders = 2; - - BoxCollection c = await boxClient.FoldersManager.GetFolderItemsAsync("0", 3, 0, new List() { - BoxItem.FieldName, - BoxItem.FieldSize, - BoxFolder.FieldItemCollection - }, autoPaginate: true); - - Assert.AreEqual(TotalCount, c.TotalCount, "Incorrect total count"); - Assert.AreEqual(TotalCount, c.Entries.Count, "Incorrect number if items returned"); - - Assert.AreEqual(NumFolders, c.Entries.Count(item => item is BoxFolder), "Wrong number of Folders"); - Assert.AreEqual(NumFiles, c.Entries.Count(item => item is BoxFile), "Wrong number of Files"); - } - - [TestMethod] - public async Task GetFolderInformation_Fields_ValidResponse() - { - const string FolderId = "39105922916"; - var folder = await Client.FoldersManager.GetInformationAsync(FolderId, fields: new List { "allowed_shared_link_access_levels", "can_non_owners_invite", "is_externally_owned" }); - - Assert.AreEqual(folder.CanNonOwnersInvite, true); - Assert.AreEqual(folder.IsExternallyOwned, false); - Assert.AreEqual(folder.AllowedSharedLinkAccessLevels[0], "collaborators", "shared link access levels could not be retrieved"); - Assert.AreEqual(folder.AllowedSharedLinkAccessLevels[1], "open", "shared link access levels could not be retrieved"); - Assert.AreEqual(folder.AllowedSharedLinkAccessLevels[2], "company", "shared link access levels could not be retrieved"); - } - - [TestMethod] - public async Task GetFolderInformation_Fields_Metadata_ValidResponse() - { - const string FolderId = "1927307787"; - var folder = await Client.FoldersManager.GetInformationAsync(FolderId, fields: new List { "metadata.enterprise_440385.testtemplate" }); - - Assert.AreEqual(FolderId, folder.Id, "Incorrect folder id"); - Assert.IsNotNull(folder.Metadata, "Metadata is null"); - Assert.IsNotNull(folder.Metadata["enterprise_440385"], "Scope could not be found"); - - folder = await Client.FoldersManager.GetInformationAsync(FolderId, fields: new List { "metadata.enterprise.testtemplate" }); - - Assert.AreEqual(FolderId, folder.Id, "Incorrect folder id"); - Assert.IsNotNull(folder.Metadata, "Metadata is null"); - Assert.IsNotNull(folder.Metadata["enterprise"], "Scope could not be found"); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - [ExpectedException(typeof(TimeoutException))] - public async Task UpdateFolderInformation_ValidRequest_Timeout() - { - var folderReq = new BoxFolderRequest() - { - Id = "0" - }; - var timeout = new TimeSpan(0, 0, 0, 0, 1); // 1ms timeout, should always cancel the request - _ = await Client.FoldersManager.UpdateInformationAsync(folderRequest: folderReq, timeout: timeout); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task FolderGetTrashItems_LiveSession_ValidResponse() - { - var results = await Client.FoldersManager.GetTrashItemsAsync(10); - Assert.IsNotNull(results); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task Watermark_Folders_CRUD() - { - var testName = GetUniqueName(); - - // Create Folder - var folderReq = new BoxFolderRequest() - { - Name = testName, - Parent = new BoxRequestEntity() { Id = "0" } - }; - - var newFolder = await Client.FoldersManager.CreateAsync(folderReq); - - Assert.IsNotNull(newFolder, "Folder was not created"); - - var folderId = newFolder.Id; - - var mylist = new List(new string[] { "watermark_info" }); - var folder = await Client.FoldersManager.GetInformationAsync(folderId, mylist); - - Assert.IsFalse(folder.WatermarkInfo.IsWatermarked); - - var watermark = await Client.FoldersManager.ApplyWatermarkAsync(folderId); - Assert.IsNotNull(watermark, "Failed to apply watermark to folder"); - - folder = await Client.FoldersManager.GetInformationAsync(folderId, mylist); - Assert.IsTrue(folder.WatermarkInfo.IsWatermarked); - - var fetchedWatermark = await Client.FoldersManager.GetWatermarkAsync(folderId); - Assert.IsNotNull(fetchedWatermark, "Failed to fetch watermark of folder"); - - var result = await Client.FoldersManager.RemoveWatermarkAsync(folderId); - Assert.IsTrue(result, "Failed to remove watermark from folder"); - - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task FolderWorkflow_LiveSession_ValidResponse() - { - var testName = GetUniqueName(); - - // Test Create Folder - var folderReq = new BoxFolderRequest() - { - Name = testName, - Parent = new BoxRequestEntity() { Id = "0" } - }; - - BoxFolder f = await Client.FoldersManager.CreateAsync(folderReq); - - Assert.IsNotNull(f, "Folder was not created"); - Assert.AreEqual(testName, f.Name, "Folder with incorrect name was created"); - - // Test Get Information - BoxFolder fi = await Client.FoldersManager.GetInformationAsync(f.Id); - - Assert.AreEqual(f.Id, fi.Id, "Folder Ids are not identical"); - Assert.AreEqual(testName, fi.Name, "folder name is incorrect"); - - // Test Create Shared Link - var sharedLinkReq = new BoxSharedLinkRequest() - { - Access = BoxSharedLinkAccessType.open - }; - - BoxFolder fsl = await Client.FoldersManager.CreateSharedLinkAsync(f.Id, sharedLinkReq); - - Assert.AreEqual(BoxSharedLinkAccessType.open, fsl.SharedLink.Access, "Shared link Access is not correct"); - - // Test Update Folder Information - var newTestname = GetUniqueName(); - var updateReq = new BoxFolderRequest() - { - Id = f.Id, - Name = newTestname, - SyncState = BoxSyncStateType.not_synced, - FolderUploadEmail = new BoxEmailRequest { Access = "open" } - }; - - BoxFolder uf = await Client.FoldersManager.UpdateInformationAsync(updateReq); - - Assert.AreEqual(newTestname, uf.Name, "New folder name is not correct"); - - // Test Copy Folder - var copyTestName = GetUniqueName(); - var copyReq = new BoxFolderRequest() - { - Id = f.Id, - Parent = new BoxRequestEntity() { Id = "0" }, - Name = copyTestName - }; - - BoxFolder f2 = await Client.FoldersManager.CopyAsync(copyReq); - - Assert.AreEqual(copyTestName, f2.Name, "Copied file does not have correct name"); - - //Clean up - Delete Test Folders - await Client.FoldersManager.DeleteAsync(f.Id, true); - await Client.FoldersManager.DeleteAsync(f2.Id, true); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task FolderSharedLink_CreateAndDelete_ValidResponse() - { - var testName = GetUniqueName(); - - // Test Create Folder - var folderReq = new BoxFolderRequest() - { - Name = testName, - Parent = new BoxRequestEntity() { Id = "0" } - }; - - BoxFolder f = await Client.FoldersManager.CreateAsync(folderReq); - Assert.IsNotNull(f, "Folder was not created"); - Assert.AreEqual(testName, f.Name, "Folder with incorrect name was created"); - - var sharedLinkReq = new BoxSharedLinkRequest() - { - Access = BoxSharedLinkAccessType.open, - Permissions = new BoxPermissionsRequest - { - Download = true, - } - }; - - BoxFolder sl = await Client.FoldersManager.CreateSharedLinkAsync(f.Id, sharedLinkReq); - Assert.AreEqual(sl.Id, f.Id); - Assert.IsNotNull(sl.SharedLink); - Assert.AreEqual(sl.SharedLink.Access, BoxSharedLinkAccessType.open); - Assert.IsNotNull(sl.SharedLink.Permissions); - Assert.AreEqual(sl.SharedLink.Permissions.CanDownload, true); - - - sharedLinkReq = new BoxSharedLinkRequest() - { - Access = null, - Permissions = new BoxPermissionsRequest - { - Download = false, - } - }; - - sl = await Client.FoldersManager.CreateSharedLinkAsync(f.Id, sharedLinkReq); - Assert.AreEqual(sl.Id, f.Id); - Assert.IsNotNull(sl.SharedLink); - Assert.AreEqual(sl.SharedLink.Access, BoxSharedLinkAccessType.open); - Assert.IsNotNull(sl.SharedLink.Permissions); - Assert.AreEqual(sl.SharedLink.Permissions.CanDownload, false); - - sl = await Client.FoldersManager.DeleteSharedLinkAsync(f.Id); - Assert.AreEqual(sl.Id, f.Id); - Assert.IsNull(sl.SharedLink); - - //Clean up - Delete Test Folders - await Client.FoldersManager.DeleteAsync(f.Id, true); - } - } - -} diff --git a/Box.V2.Test.Integration/BoxGroupsManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxGroupsManagerTestIntegration.cs deleted file mode 100644 index 697fb09ae..000000000 --- a/Box.V2.Test.Integration/BoxGroupsManagerTestIntegration.cs +++ /dev/null @@ -1,167 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Models; -using Box.V2.Models.Request; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using static Box.V2.Config.Constants; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxGroupsManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task GroupsWorkflow_ValidRequest_GetGroups() - { - // Get all groups and one individual group - var allGroupsInit = await Client.GroupsManager.GetAllGroupsAsync(); - var oneGroup = await Client.GroupsManager.GetGroupAsync(allGroupsInit.Entries[0].Id); - Assert.AreEqual(allGroupsInit.Entries[0].Name, oneGroup.Name, "Did not retrieve the correct group"); - - // Create a new group - var groupName = GetUniqueName(); - - var groupReq = new BoxGroupRequest() - { - Name = groupName, - InvitabilityLevel = RequestParameters.AdminsOnly, - MemberViewabilityLevel = RequestParameters.AdminsOnly - }; - - var newGroup = await Client.GroupsManager.CreateAsync(groupReq); - var allGroupsAfterAdd = await Client.GroupsManager.GetAllGroupsAsync(limit: 3, autoPaginate: true); - - Assert.AreEqual(newGroup.Name, groupName, "New group does not have correct name"); - Assert.AreEqual(allGroupsInit.TotalCount + 1, allGroupsAfterAdd.TotalCount, "Number of groups after add is not correct"); - - //Update the name of an existing group - var updatedName = GetUniqueName(); - - Assert.IsFalse(allGroupsInit.Entries.Any(x => x.Name.Equals(updatedName)), "A group with updatedName already exists"); - - var updateRequest = new BoxGroupRequest() - { - Name = updatedName - }; - - var updatedGroup = await Client.GroupsManager.UpdateAsync(newGroup.Id, updateRequest); - var allGroupsAfterUpdate = await Client.GroupsManager.GetAllGroupsAsync(); - - Assert.AreEqual(updatedGroup.Name, updatedName, "The group name was not updated correctly"); - Assert.AreEqual(1, allGroupsAfterUpdate.Entries.Count(x => x.Name.Equals(updatedName)), "The updated group name does not exist among all groups"); - Assert.IsFalse(allGroupsAfterUpdate.Entries.Any(x => x.Name.Equals(groupName)), "The old group name still exists among all groups"); - - // Delete a group - var delResult = await Client.GroupsManager.DeleteAsync(newGroup.Id); - var allGroupsAfterDelete = await Client.GroupsManager.GetAllGroupsAsync(); - - Assert.IsTrue(delResult, "Group was not deleted successfully"); - Assert.AreEqual(allGroupsInit.TotalCount, allGroupsAfterDelete.TotalCount, "Number of groups after delete is not correct"); - Assert.IsFalse(allGroupsAfterDelete.Entries.Any(x => x.Id == newGroup.Id), "Deleted group still exists"); - } - - [TestMethod] - public async Task GroupMembershipWorkflow_ValidRequest() - { - // Get current user - var user = await Client.UsersManager.GetCurrentUserInformationAsync(); - - // Get all the current memberships for this user - var current_memberships = await Client.GroupsManager.GetAllGroupMembershipsForUserAsync(user.Id); - - // Create a new group - var groupName = GetUniqueName(); - - var groupReq = new BoxGroupRequest() - { - Name = groupName, - }; - - var newGroup = await Client.GroupsManager.CreateAsync(groupReq); - - // Create a membership - var request = new BoxGroupMembershipRequest() - { - User = new BoxRequestEntity() { Id = user.Id }, - Group = new BoxGroupRequest() { Id = newGroup.Id } - }; - - var responseMembership = await Client.GroupsManager.AddMemberToGroupAsync(request); - - Assert.AreEqual("group_membership", responseMembership.Type, "The type is not group_membership"); - Assert.AreEqual("member", responseMembership.Role, "Membership role is not set correctly"); - Assert.AreEqual(user.Id, responseMembership.User.Id, "User id not set correctly for membership"); - Assert.AreEqual(newGroup.Id, responseMembership.Group.Id, "Group id not set correctly for membership"); - - // Get the created group membership - var membership = await Client.GroupsManager.GetGroupMembershipAsync(responseMembership.Id); - Assert.AreEqual("group_membership", membership.Type, "The type is not group_membership"); - Assert.AreEqual("member", membership.Role, "Membership role is not set correctly"); - Assert.AreEqual(user.Id, membership.User.Id, "User id not set correctly for membership"); - Assert.AreEqual(newGroup.Id, membership.Group.Id, "Group id not set correctly for membership"); - - // Update the group membership's role - request = new BoxGroupMembershipRequest() { Role = "admin" }; - var updatedMembership = await Client.GroupsManager.UpdateGroupMembershipAsync(responseMembership.Id, request); - Assert.AreEqual("admin", updatedMembership.Role, "Membership role was not updated correctly"); - - // Get all memberships for the given groups - var memberships = await Client.GroupsManager.GetAllGroupMembershipsForGroupAsync(newGroup.Id); - - Assert.AreEqual(1, memberships.Entries.Count, "Wrong count of memberships"); - Assert.AreEqual(1, memberships.TotalCount, "Wrong total count of memberships"); - Assert.AreEqual("group_membership", memberships.Entries[0].Type, "Wrong type"); - Assert.AreEqual(newGroup.Id, memberships.Entries[0].Group.Id, "Wrong Group id"); - Assert.AreEqual(user.Id, memberships.Entries[0].User.Id, "Wrong User id"); - - // Add this group to a folder - const string FolderId = "1927307787"; - - // Add Collaboration - var addRequest = new BoxCollaborationRequest() - { - Item = new BoxRequestEntity() - { - Id = FolderId, - Type = BoxType.folder - }, - AccessibleBy = new BoxCollaborationUserRequest() - { - Type = BoxType.group, - Id = newGroup.Id - }, - Role = "viewer" - }; - - BoxCollaboration collab = await Client.CollaborationsManager.AddCollaborationAsync(addRequest, notify: false); - - Assert.AreEqual(FolderId, collab.Item.Id, "Folder and collaboration folder id do not match"); - Assert.AreEqual(BoxCollaborationRoles.Viewer, collab.Role, "Incorrect collaboration role"); - - // Get all collaborations for the give group - var collabs = await Client.GroupsManager.GetCollaborationsForGroupAsync(newGroup.Id); - Assert.AreEqual(1, collabs.Entries.Count, "Wrong count of collaborations"); - Assert.AreEqual(1, collabs.TotalCount, "Wrong total count of collaborations"); - - collab = collabs.Entries[0]; - Assert.AreEqual(newGroup.Id, collab.AccessibleBy.Id, "Wrong Group Id"); - Assert.AreEqual("viewer", collab.Role, "Wrong Role Type"); - - // Get memberships for the user - memberships = await Client.GroupsManager.GetAllGroupMembershipsForUserAsync(user.Id); - - Assert.AreEqual(current_memberships.TotalCount + 1, memberships.TotalCount, "The total count of memberships for user did not increase"); - Assert.IsTrue(memberships.Entries.Exists(m => m.Id.Equals(membership.Id)), "Newly created group membership does not exist in this users list of memberships"); - - // Delete the group membership - var success = await Client.GroupsManager.DeleteGroupMembershipAsync(membership.Id); - memberships = await Client.GroupsManager.GetAllGroupMembershipsForGroupAsync(newGroup.Id); - - Assert.AreEqual(0, memberships.Entries.Count, "Count should be 0"); - Assert.AreEqual(0, memberships.TotalCount, "Total count should be 0"); - - // Clean up - delete group - var delResult = await Client.GroupsManager.DeleteAsync(newGroup.Id); - } - } -} diff --git a/Box.V2.Test.Integration/BoxLegalHoldPoliciesManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxLegalHoldPoliciesManagerTestIntegration.cs deleted file mode 100644 index f0eb046c5..000000000 --- a/Box.V2.Test.Integration/BoxLegalHoldPoliciesManagerTestIntegration.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Exceptions; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxLegalHoldPoliciesManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task LegalHoldPoliciesWorkflow_ValidRequest() - { - // Init - var policyName = "PN" + Guid.NewGuid().ToString().Substring(0, 4); - var newPolicyName = "N" + policyName; - var description = "DESC"; - var filterStarted = DateTimeOffset.Now.AddDays(-30); - var filterEnded = DateTimeOffset.Now.AddDays(-15); - - // Create with filter_date - var legalHold = await Client.LegalHoldPoliciesManager.CreateLegalHoldPolicyAsync(new BoxLegalHoldPolicyRequest() - { - PolicyName = policyName, - Description = description, - FilterStartedAt = filterStarted, - FilterEndedAt = filterEnded - }); - - Assert.IsNotNull(legalHold.Id); - Assert.IsFalse(legalHold.IsOngoing); - - // Update - var uLegalHold = await Client.LegalHoldPoliciesManager.UpdateLegalHoldPolicyAsync(legalHold.Id, new BoxLegalHoldPolicyRequest() - { - PolicyName = newPolicyName - }); - - Assert.AreEqual(newPolicyName, uLegalHold.PolicyName); - - // Get - var gLegalHold = await Client.LegalHoldPoliciesManager.GetLegalHoldPolicyAsync(legalHold.Id); - Assert.AreEqual(newPolicyName, gLegalHold.PolicyName); - - // Gets - var gLegalHolds = await Client.LegalHoldPoliciesManager.GetListLegalHoldPoliciesAsync(); - Assert.AreEqual(newPolicyName, gLegalHolds.Entries.Single(lh => lh.PolicyName == newPolicyName).PolicyName); - - // Create assignment - var fileId = "102438629524"; - var legalHoldAssignment = await Client.LegalHoldPoliciesManager.CreateAssignmentAsync(new BoxLegalHoldPolicyAssignmentRequest() - { - PolicyId = legalHold.Id, - AssignTo = new BoxRequestEntity() - { - Id = fileId, - Type = BoxType.file - } - }); - - Assert.IsNotNull(legalHoldAssignment.Id); - - // Get assignment - var gLegalHoldAssignment = await Client.LegalHoldPoliciesManager.GetAssignmentAsync(legalHoldAssignment.Id); - - Assert.AreEqual(legalHoldAssignment.Id, gLegalHoldAssignment.Id); - - // Get assignments - var gLegalHoldAssignments = await Client.LegalHoldPoliciesManager.GetAssignmentsAsync(legalHold.Id); - - Assert.AreEqual(legalHoldAssignment.Id, gLegalHoldAssignments.Entries.Single(lha => lha.Id == gLegalHoldAssignment.Id).Id); - - // Get file version legal holds - var fileVersionLegalHolds = await Client.LegalHoldPoliciesManager.GetFileVersionLegalHoldsAsync(legalHold.Id); - - if (fileVersionLegalHolds.Entries.Count > 0) - { - var fileVersionLegalHoldId = fileVersionLegalHolds.Entries[0].Id; - - // Get file version legal hold - var fileVersionLegalHold = await Client.LegalHoldPoliciesManager.GetFileVersionLegalHoldAsync(fileVersionLegalHoldId); - - Assert.AreEqual(fileVersionLegalHoldId, fileVersionLegalHold.Id); - } - - // Delete assignment - try - { - var deleted1 = await Client.LegalHoldPoliciesManager.DeleteAssignmentAsync(legalHoldAssignment.Id); - Assert.IsTrue(deleted1); - - // Delete - var deleted2 = await Client.LegalHoldPoliciesManager.DeleteLegalHoldPolicyAsync(legalHold.Id); - Assert.IsTrue(deleted2); - } - catch (BoxConflictException) - { - // 409 will cause exception - } - } - - [TestMethod] - public async Task LegalHoldPoliciesWorkflow_IsOngoing_ValidRequest() - { - // Init - var policyName = "PN" + Guid.NewGuid().ToString().Substring(0, 4); - _ = "N" + policyName; - var description = "DESC"; - - // Create with is_ongoing - var legalHold = await Client.LegalHoldPoliciesManager.CreateLegalHoldPolicyAsync(new BoxLegalHoldPolicyRequest() - { - PolicyName = policyName, - Description = description, - isOngoing = true - }); - - Assert.IsNotNull(legalHold.Id); - Assert.IsTrue(legalHold.IsOngoing); - - // Delete - var deleted = await Client.LegalHoldPoliciesManager.DeleteLegalHoldPolicyAsync(legalHold.Id); - Assert.IsTrue(deleted); - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxMetadataManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxMetadataManagerIntegrationTest.cs similarity index 97% rename from Box.V2.Test.IntegrationNew/BoxMetadataManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxMetadataManagerIntegrationTest.cs index 93f7340f2..37125e54e 100644 --- a/Box.V2.Test.IntegrationNew/BoxMetadataManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxMetadataManagerIntegrationTest.cs @@ -3,10 +3,10 @@ using System.Threading.Tasks; using Box.V2.Models; using Box.V2.Models.Request; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxMetadataManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxMetadataManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxMetadataManagerTestIntegration.cs deleted file mode 100644 index 2d1e94019..000000000 --- a/Box.V2.Test.Integration/BoxMetadataManagerTestIntegration.cs +++ /dev/null @@ -1,432 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Exceptions; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxMetadataManagerTestIntegration : BoxResourceManagerTestIntegration - { - private const string TEMPLATE_KEY = "testtemplate"; - private const string SCOPE = "enterprise"; - private const string ATTR1 = "blah"; - private const int ATTR2 = 5; - private readonly DateTimeOffset _attr3 = new DateTimeOffset(2015, 1, 1, 0, 0, 0, TimeSpan.Zero); - private const string ATTR4 = "value1"; - - [TestMethod] - public async Task Metadata_File_CRUD_LiveSession() - { - const string FILE_ID = "16894937607"; - - //create metadata - var md = new Dictionary() { - { "attr1", ATTR1 }, - { "attr2", ATTR2 }, - { "attr3", _attr3 }, - { "attr4", ATTR4 } - }; - var createdMD = await Client.MetadataManager.CreateFileMetadataAsync(FILE_ID, md, SCOPE, TEMPLATE_KEY); - Assert.IsTrue(createdMD.Keys.Contains("attr1"), "Failed to correctly create file metadata"); - - //get metadata - var fetchedMD = await Client.MetadataManager.GetFileMetadataAsync(FILE_ID, SCOPE, TEMPLATE_KEY); - Assert.IsTrue(fetchedMD.Keys.Contains("attr1"), "Failed to correctly fetch file metadata"); - - //update metadata - var update = new BoxMetadataUpdate() { Op = MetadataUpdateOp.copy, Path = "/attr1", From = "/attr4" }; - var update2 = new BoxMetadataUpdate() { Op = MetadataUpdateOp.replace, Path = "/attr4", Value = "value2" }; - var update3 = new BoxMetadataUpdate() { Op = MetadataUpdateOp.replace, Path = "/attr2", Value = 2 }; // Int update - var updatedMD = await Client.MetadataManager.UpdateFileMetadataAsync(FILE_ID, new List() { update, update2, update3 }, SCOPE, TEMPLATE_KEY); - Assert.AreEqual(ATTR4, updatedMD["attr1"], "Failed to update metadata on file"); - Assert.AreEqual("value2", updatedMD["attr4"], "Failed to update metadata on file"); - Assert.AreEqual(Convert.ToInt64(2), updatedMD["attr2"], "Failed to update metadata on file"); - - //get all file metadata - var allMD = await Client.MetadataManager.GetAllFileMetadataTemplatesAsync(FILE_ID); - Assert.AreEqual(1, allMD.Entries.Count, "Failed to get all file metadata"); - - //delete metadata - var result = await Client.MetadataManager.DeleteFileMetadataAsync(FILE_ID, SCOPE, TEMPLATE_KEY); - Assert.IsTrue(result, "Failed to delete file metadata"); - } - - [TestMethod] - public async Task Metadata_DeleteTemplate_LiveSession() - { - var templateKey = "testtemplate"; - var displayName = "Test Template"; - var scope = "enterprise"; - - var templateToCreate = new BoxMetadataTemplate() { TemplateKey = templateKey, DisplayName = displayName, Fields = null, Hidden = true, Scope = scope }; - await Client.MetadataManager.CreateMetadataTemplate(templateToCreate); - - var templateIsDeleted = await Client.MetadataManager.DeleteMetadataTemplate(scope, templateKey); - - try - { - await Client.MetadataManager.GetMetadataTemplate(scope, templateKey); - } - catch (BoxException e) - { - Assert.IsNotNull(e); - } - Assert.IsTrue(templateIsDeleted, "Failed to delete metadata template"); - } - - [TestMethod] - public async Task Metadata_Folder_CRUD_LiveSession() - { - const string FOLDER_ID = "1927308583"; - - //create metadata - var md = new Dictionary() { - { "attr1", ATTR1 }, - { "attr2", ATTR2 }, - { "attr3", _attr3 }, - { "attr4", ATTR4 } - }; - var createdMD = await Client.MetadataManager.CreateFolderMetadataAsync(FOLDER_ID, md, SCOPE, TEMPLATE_KEY); - Assert.IsTrue(createdMD.Keys.Contains("attr1"), "Failed to correctly create folder metadata"); - - //get metadata - var fetchedMD = await Client.MetadataManager.GetFolderMetadataAsync(FOLDER_ID, SCOPE, TEMPLATE_KEY); - Assert.IsTrue(fetchedMD.Keys.Contains("attr1"), "Failed to correctly fetch folder metadata"); - - //update metadata - var update = new BoxMetadataUpdate() { Op = MetadataUpdateOp.copy, Path = "/attr1", From = "/attr4" }; - var update2 = new BoxMetadataUpdate() { Op = MetadataUpdateOp.replace, Path = "/attr4", Value = "value2" }; - var updatedMD = await Client.MetadataManager.UpdateFolderMetadataAsync(FOLDER_ID, new List() { update, update2 }, SCOPE, TEMPLATE_KEY); - Assert.AreEqual(ATTR4, updatedMD["attr1"], "Failed to update metadata on folder"); - Assert.AreEqual("value2", updatedMD["attr4"], "Failed to update metadata on folder"); - - //get all folder metadata - var allMD = await Client.MetadataManager.GetAllFolderMetadataTemplatesAsync(FOLDER_ID); - Assert.AreEqual(1, allMD.Entries.Count, "Failed to get all folder metadata"); - - //delete metadata - var result = await Client.MetadataManager.DeleteFolderMetadataAsync(FOLDER_ID, SCOPE, TEMPLATE_KEY); - Assert.IsTrue(result, "Failed to delete folder metadata"); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task Metadata_GetAllEnterprise_LiveSession() - { - var templates = await Client.MetadataManager.GetEnterpriseMetadataAsync(); - Assert.IsTrue(templates.Entries.Count > 1, "Failed to get enterprise metadata templates"); - Assert.IsNotNull(templates.Entries.Single(t => t.TemplateKey == TEMPLATE_KEY), "Failed to get enterprise metadata templates"); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task Metadata_GetTemplate_LiveSession() - { - var template = await Client.MetadataManager.GetMetadataTemplate(SCOPE, TEMPLATE_KEY); - Assert.AreEqual(TEMPLATE_KEY, template.TemplateKey, "Failed to get metadata template"); - Assert.AreEqual(4, template.Fields.Count, "Failed to get metadata template"); - } - - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task Metadata_GetTemplateById_LiveSesion() - { - var templates = await Client.MetadataManager.GetEnterpriseMetadataAsync(); - var metadataTemplate = await Client.MetadataManager.GetMetadataTemplateById(templates.Entries[0].Id); - Assert.IsNotNull(metadataTemplate); - Assert.AreEqual(metadataTemplate.Type, "metadata_template"); - } - - [TestMethod] - public async Task Metadata_ExecuteQueryAsync_LiveSession() - { - var folderName = ".Net Metadata Query Integration Test"; - var metadataTemplateScope = "enterprise"; - var metadataTemplateName = "testMetadataQueryTemplate"; - var metadataTemplateField = "testField"; - var metadataTemplateFieldValue = "testValue"; - - // Check that test metadata template exists or create if not there - BoxMetadataTemplate template; - try - { - template = await Client.MetadataManager.GetMetadataTemplate(metadataTemplateScope, metadataTemplateName); - } - catch (BoxException) - { - var templateParams = new BoxMetadataTemplate() - { - TemplateKey = metadataTemplateName, - DisplayName = "Test Metadata Query Template", - Scope = metadataTemplateScope, - Fields = new List() - { - new BoxMetadataTemplateField() - { - Type = "string", - Key = metadataTemplateField, - DisplayName = "Test Field" - } - } - }; - template = await Client.MetadataManager.CreateMetadataTemplate(templateParams); - } - - // Create folder and apply test metadata template. If folder is already there, assume that the folder has the correct metadata template from a previous integration test that might not have been able to delete the folder. - BoxFolder folder = null; - try - { - var folderParams = new BoxFolderRequest() - { - Name = folderName, - Parent = new BoxRequestEntity() - { - Id = "0" - } - }; - folder = await Client.FoldersManager.CreateAsync(folderParams); - var metadataValues = new Dictionary() - { - { metadataTemplateField, metadataTemplateFieldValue } - }; - Dictionary metadata = await Client.MetadataManager.SetFolderMetadataAsync(folder.Id, metadataValues, template.Scope, template.TemplateKey); - } - catch { } - - /*** Act ***/ - var from = template.Scope + "." + template.TemplateKey; - var query = metadataTemplateField + " = :arg"; - var queryParams = new Dictionary - { - { "arg", metadataTemplateFieldValue } - }; - var orderByList = new List(); - var orderBy = new BoxMetadataQueryOrderBy() - { - FieldKey = metadataTemplateField, - Direction = BoxSortDirection.DESC - }; - orderByList.Add(orderBy); - // Run metadata query - BoxCollectionMarkerBased items = await Client.MetadataManager.ExecuteMetadataQueryAsync(from: from, query: query, queryParameters: queryParams, orderBy: orderByList, ancestorFolderId: "0", autoPaginate: false); - // Delete folder if this test created a folder - if (folder != null) - { - await Client.FoldersManager.DeleteAsync(folder.Id, recursive: true); - } - /*** Assert ***/ - Assert.AreEqual(items.Entries.Count, 1); - Assert.AreEqual(items.Entries[0].Item.Name, folderName); - } - - [TestMethod] - public async Task Metadata_ExecuteQueryWithFieldsAsync_LiveSession() - { - var folderName = ".Net Metadata Query Integration Test"; - var metadataTemplateScope = "enterprise"; - var metadataTemplateName = "testMetadataQueryTemplate"; - var metadataTemplateField = "testField"; - var metadataTemplateFieldValue = "testValue"; - - // Check that test metadata template exists or create if not there - BoxMetadataTemplate template; - try - { - template = await Client.MetadataManager.GetMetadataTemplate(metadataTemplateScope, metadataTemplateName); - } - catch (BoxException) - { - var templateParams = new BoxMetadataTemplate() - { - TemplateKey = metadataTemplateName, - DisplayName = "Test Metadata Query Template", - Scope = metadataTemplateScope, - Fields = new List() - { - new BoxMetadataTemplateField() - { - Type = "string", - Key = metadataTemplateField, - DisplayName = "Test Field" - } - } - }; - template = await Client.MetadataManager.CreateMetadataTemplate(templateParams); - } - - // Create folder and apply test metadata template. If folder is already there, assume that the folder has the correct metadata template from a previous integration test that might not have been able to delete the folder. - BoxFolder folder = null; - try - { - var folderParams = new BoxFolderRequest() - { - Name = folderName, - Parent = new BoxRequestEntity() - { - Id = "0" - } - }; - folder = await Client.FoldersManager.CreateAsync(folderParams); - var metadataValues = new Dictionary() - { - { metadataTemplateField, metadataTemplateFieldValue } - }; - Dictionary metadata = await Client.MetadataManager.SetFolderMetadataAsync(folder.Id, metadataValues, template.Scope, template.TemplateKey); - } - catch { } - - /*** Act ***/ - var from = template.Scope + "." + template.TemplateKey; - var query = metadataTemplateField + " = :arg"; - var fields = new List - { - "type", - "id", - "name", - "metadata." + template.Scope + "." + template.TemplateKey + "." + metadataTemplateField - }; - var queryParams = new Dictionary - { - { "arg", metadataTemplateFieldValue } - }; - var orderByList = new List(); - var orderBy = new BoxMetadataQueryOrderBy() - { - FieldKey = metadataTemplateField, - Direction = BoxSortDirection.DESC - }; - orderByList.Add(orderBy); - // Run metadata query - BoxCollectionMarkerBased items = await Client.MetadataManager.ExecuteMetadataQueryAsync(from, query: query, fields: fields, queryParameters: queryParams, orderBy: orderByList, ancestorFolderId: "0", autoPaginate: false); - // Delete folder if this test created a folder - if (folder != null) - { - await Client.FoldersManager.DeleteAsync(folder.Id, recursive: true); - } - /*** Assert ***/ - Assert.AreEqual(items.Entries.Count, 1); - Assert.AreEqual(items.Entries[0].Name, folderName); - var folderItem = (BoxFolder)items.Entries[0]; - Assert.IsNotNull(folderItem.Metadata); - } - - // This test is disabled because our test account has hit the maximum number of metadata templates (50). - // Until we can figure out how to delete some templates or increase the limit this test will fail. - //[TestMethod] - public async Task Metadata_CreateTemplate_LiveSession() - { - var templateKey = "template-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8); - var createdTemplate = await CreateTestTemplate(templateKey); - - Assert.AreEqual(templateKey, createdTemplate.TemplateKey, "Failed to create metadata template"); - Assert.AreEqual(4, createdTemplate.Fields.Count, "Failed to create metadata template"); - Assert.AreEqual("string", createdTemplate.Fields.First(f => f.Key == "attr1").Type, "Failed to create metadata template"); - Assert.IsTrue(createdTemplate.Fields.First(f => f.Key == "attr1").Hidden.Value, "Failed to create metadata template"); - Assert.AreEqual("float", createdTemplate.Fields.First(f => f.Key == "attr2").Type, "Failed to create metadata template"); - Assert.IsFalse(createdTemplate.Fields.First(f => f.Key == "attr2").Hidden.Value, "Failed to create metadata template"); - Assert.AreEqual("date", createdTemplate.Fields.First(f => f.Key == "attr3").Type, "Failed to create metadata template"); - Assert.AreEqual("enum", createdTemplate.Fields.First(f => f.Key == "attr4").Type, "Failed to create metadata template"); - Assert.AreEqual(2, createdTemplate.Fields.First(f => f.Key == "attr4").Options.Count, "Failed to create metadata template"); - Assert.IsTrue(createdTemplate.Hidden.Value, "Failed to create metadata template"); - - } - - // This test is disabled because our test account has hit the maximum number of metadata templates (50). - // Until we can figure out how to delete some templates or increase the limit this test will fail. - [TestMethod] - // [TestCategory("CI-APP-USER")] - public async Task Metadata_UpdateTemplate_LiveSession() - { - /* - if (!IsUnderCI()) - { - return; - } - */ - - // var templateKey = "template-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8); - // var createdTemplate = await createTestTemplate(templateKey); - - var templateKey = "template-fbc81a44"; - - //addField operation - var newField = new BoxMetadataTemplateField() { Key = "attr5", DisplayName = "a string", Type = "string" }; - var update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.addField, Data = newField }; - var updates = new List() { update }; - var updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsTrue(updatedTemplate.Fields.Any(f => f.Key == "attr5"), "addField operation failed on metadata update"); - - //editField operation - var fieldUpdate = new BoxMetadataTemplateField() { DisplayName = "a string edited" }; - update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.editField, FieldKey = "attr1", Data = fieldUpdate }; - updates = new List() { update }; - updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsTrue(updatedTemplate.Fields.Single(f => f.Key == "attr1").DisplayName == "a string edited", "editField operation failed on metadata update"); - - //editTemplate operation - var templateUpdate = new BoxMetadataTemplate() { DisplayName = "new display name" }; - update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.editTemplate, Data = templateUpdate }; - updates = new List() { update }; - updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsTrue(updatedTemplate.DisplayName == "new display name", "editTemplate operation failed on metadata update"); - - //addEnumOption operation - var newValue = new BoxMetadataTemplateFieldOption() { Key = "value3" }; - update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.addEnumOption, FieldKey = "attr4", Data = newValue }; - updates = new List() { update }; - updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsTrue(updatedTemplate.Fields.Single(f => f.Key == "attr4").Options.Count == 3, "addEnumOption operation failed on metadata update"); - - //reorderEnumOptions operation - var newValueOrder = new List() { "value2", "value1", "value3" }; - update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.reorderEnumOptions, FieldKey = "attr4", EnumOptionKeys = newValueOrder }; - updates = new List() { update }; - updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsTrue(updatedTemplate.Fields.Single(f => f.Key == "attr4").Options[0].Key == "value2", "reorderEnumOptions operation failed on metadata update"); - - //editEnumOption operation - newValue = new BoxMetadataTemplateFieldOption() { Key = "value31" }; - update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.editEnumOption, FieldKey = "attr4", EnumOptionKey = "value3", Data = newValue }; - updates = new List() { update }; - updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsTrue(updatedTemplate.Fields.Single(f => f.Key == "attr4").Options.Count == 3, "editEnumOption operation failed on metadata update"); - - //removeEnumOption operation - update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.removeEnumOption, FieldKey = "attr4", EnumOptionKey = "value31" }; - updates = new List() { update }; - updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsTrue(updatedTemplate.Fields.Single(f => f.Key == "attr4").Options.Count == 2, "removeEnumOption operation failed on metadata update"); - - //reorderFields operation - var newFieldOrder = new List() { "attr5", "attr4", "attr3", "attr2", "attr1" }; - update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.reorderFields, FieldKeys = newFieldOrder }; - updates = new List() { update }; - updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsTrue(updatedTemplate.Fields[0].Key == "attr5", "reorderFields operation failed on metadata update"); - - //removeField operation - update = new BoxMetadataTemplateUpdate() { Op = MetadataTemplateUpdateOp.removeField, FieldKey = "attr5" }; - updates = new List() { update }; - updatedTemplate = await Client.MetadataManager.UpdateMetadataTemplate(updates, "enterprise", templateKey); - Assert.IsFalse(updatedTemplate.Fields.Any(f => f.Key == "attr5"), "removeField operation failed on metadata update"); - } - - private async Task CreateTestTemplate(string templateKey) - { - var field1 = new BoxMetadataTemplateField() { Key = "attr1", DisplayName = "a string", Type = "string", Hidden = true }; - var field2 = new BoxMetadataTemplateField() { Key = "attr2", DisplayName = "a float", Type = "float" }; - var field3 = new BoxMetadataTemplateField() { Key = "attr3", DisplayName = "a date", Type = "date" }; - var options = new List() { new BoxMetadataTemplateFieldOption() { Key = "value1" }, new BoxMetadataTemplateFieldOption() { Key = "value2" } }; - var field4 = new BoxMetadataTemplateField() { Key = "attr4", DisplayName = "a enum", Type = "enum", Options = options }; - var fields = new List() { field1, field2, field3, field4 }; - var templateToCreate = new BoxMetadataTemplate() { TemplateKey = templateKey, DisplayName = templateKey, Fields = fields, Hidden = true, Scope = SCOPE }; - var createdTemplate = await Client.MetadataManager.CreateMetadataTemplate(templateToCreate); - return createdTemplate; - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxRecentItemsManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxRecentItemsManagerIntegrationTest.cs similarity index 84% rename from Box.V2.Test.IntegrationNew/BoxRecentItemsManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxRecentItemsManagerIntegrationTest.cs index 6314f8fac..7981c5c96 100644 --- a/Box.V2.Test.IntegrationNew/BoxRecentItemsManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxRecentItemsManagerIntegrationTest.cs @@ -1,8 +1,8 @@ using System.Threading.Tasks; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxRecentItemsManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxRecentItemsManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxRecentItemsManagerTestIntegration.cs deleted file mode 100644 index 6f43ebdb3..000000000 --- a/Box.V2.Test.Integration/BoxRecentItemsManagerTestIntegration.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxRecentItemsManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task RecentItemsTests_LiveSession() - { - // Get 3 recents items w/o auto paging - var recentItems = await Client.RecentItemsManager.GetRecentItemsAsync(limit: 3); - Assert.AreEqual(recentItems.Limit, 3); - - // Get next page if possible - if (!string.IsNullOrEmpty(recentItems.NextMarker)) - { - recentItems = await Client.RecentItemsManager.GetRecentItemsAsync(limit: 3, marker: recentItems.NextMarker); - Assert.AreEqual(recentItems.Limit, 3); - } - - // Get all the recent items. - recentItems = await Client.RecentItemsManager.GetRecentItemsAsync(limit: 3, autoPaginate: true); - Assert.AreEqual(recentItems.Order.By, BoxSortBy.interacted_at); - } - } -} diff --git a/Box.V2.Test.Integration/BoxResourceManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxResourceManagerTestIntegration.cs deleted file mode 100644 index 4fe15eb44..000000000 --- a/Box.V2.Test.Integration/BoxResourceManagerTestIntegration.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using System.Diagnostics; -using System.Threading.Tasks; -using Box.V2.Auth; -using Box.V2.Config; -using Box.V2.Converter; -using Box.V2.JWTAuth; -using Box.V2.Models; -using Box.V2.Request; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public abstract class BoxResourceManagerTestIntegration - { - public const string ClientId = "YOUR_CLIENT_ID"; - public const string ClientSecret = "YOUR_CLIENT_SECRET"; - - public Uri RedirectUri = new Uri("http://boxsdk"); - - protected OAuthSession Auth; - protected BoxClient Client; - protected IBoxConfig Config; - protected IRequestHandler Handler; - protected IBoxConverter Parser; - - protected static string JsonConfig; - protected static BoxClient UserClient; - protected static BoxClient AdminClient; - protected static string UserId; - protected static string UserToken; - - [AssemblyInitialize] - public static void Initialize(TestContext testContext) - { - JsonConfig = Environment.GetEnvironmentVariable("JSON_CONFIG"); - - if (string.IsNullOrEmpty(JsonConfig)) - { - Debug.WriteLine("No json config found!"); - } - else - { - Debug.WriteLine("json config content length : " + JsonConfig.Length); - - var config = BoxConfigBuilder.CreateFromJsonString(JsonConfig) - .Build(); - var session = new BoxJWTAuth(config); - - // create a new app user - // client with permissions to manage application users - var adminToken = session.AdminTokenAsync().Result; - AdminClient = session.AdminClient(adminToken); - - var user = CreateNewUser(AdminClient).Result; - - UserId = user.Id; - - Debug.WriteLine("New app user created : " + UserId); - - // user client with access to user's data (folders, files, etc) - UserToken = session.UserTokenAsync(UserId).Result; - UserClient = session.UserClient(UserToken, UserId); - } - } - - [AssemblyCleanup] - public static void Cleanup() - { - // Delete the app user if we created one - if (UserId != null) - { - try - { - var task = AdminClient.UsersManager.DeleteEnterpriseUserAsync(UserId, false, true); - task.Wait(); - } - catch (Exception exp) - { - // Delete will fail if there are content in the user - Debug.Print(exp.StackTrace); - } - } - } - - protected static bool IsUnderCI() - { - // if we have adminClient, we are under the CI env. - return AdminClient == null; - } - - public BoxResourceManagerTestIntegration() - { - Handler = new HttpRequestHandler(); - Parser = new BoxJsonConverter(); - - if (UserToken == null) - { - // Legacy way of getting the token - Auth = new OAuthSession("YOUR_ACCESS_TOKEN", "YOUR_REFRESH_TOKEN", 3600, "bearer"); - - Config = new BoxConfigBuilder(ClientId, ClientSecret, RedirectUri) - .Build(); - Client = new BoxClient(Config, Auth); - } - else - { - Config = BoxConfigBuilder.CreateFromJsonString(JsonConfig) - .Build(); - - Client = UserClient; - Auth = new OAuthSession(UserToken, "", 3600, "bearer"); - } - } - - protected static Task CreateNewUser(BoxClient client) - { - var userRequest = new BoxUserRequest - { - Name = "CI App User " + DateTimeOffset.Now.ToString("dd-MM-yyyy"), // mark with date - IsPlatformAccessOnly = true // creating application specific user, not a Box.com user - }; - return client.UsersManager.CreateEnterpriseUserAsync(userRequest); - } - - protected string GetUniqueName() - { - return string.Format("test{0}", Guid.NewGuid().ToString()); - } - } -} diff --git a/Box.V2.Test.Integration/BoxRetentionPoliciesManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxRetentionPoliciesManagerTestIntegration.cs deleted file mode 100644 index 73ce27c84..000000000 --- a/Box.V2.Test.Integration/BoxRetentionPoliciesManagerTestIntegration.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Models; -using Box.V2.Models.Request; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxRetentionPoliciesManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task RetentionPoliciesTests_LiveSession() - { - var policyName = "PN-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8); - - // Create retention policy - var retentionPolicy = await Client.RetentionPoliciesManager.CreateRetentionPolicyAsync(new BoxRetentionPolicyRequest() - { - PolicyName = policyName, - PolicyType = "finite", - RetentionLength = 365, - DispositionAction = "remove_retention" - }); - - Assert.IsNotNull(retentionPolicy.Id); - Assert.AreEqual(policyName, retentionPolicy.PolicyName); - - // Get a retention policy - var gRp = await Client.RetentionPoliciesManager.GetRetentionPolicyAsync(retentionPolicy.Id); - - Assert.AreEqual(retentionPolicy.PolicyName, gRp.PolicyName); - - // Get retention policies - var gRps = await Client.RetentionPoliciesManager.GetRetentionPoliciesAsync(); - - Assert.AreEqual(retentionPolicy.PolicyName, gRps.Entries.Single(rp => rp.PolicyName == policyName).PolicyName); - - - // Create retention policy assignment - var rpAssignment = await Client.RetentionPoliciesManager.CreateRetentionPolicyAssignmentAsync(new BoxRetentionPolicyAssignmentRequest() - { - PolicyId = retentionPolicy.Id, - AssignTo = new BoxRequestEntity() - { - Id = "12046572539", - Type = BoxType.folder - } - }); - - Assert.IsNotNull(rpAssignment.Id); - Assert.AreEqual("12046572539", rpAssignment.AssignedTo.Id); - - // Get a retention policy assignment - var gRpa = await Client.RetentionPoliciesManager.GetRetentionPolicyAssignmentAsync(rpAssignment.Id); - - Assert.AreEqual("12046572539", gRpa.AssignedTo.Id); - - // Get retention policy assignments - var gRpas = await Client.RetentionPoliciesManager.GetRetentionPolicyAssignmentsAsync(retentionPolicy.Id); - - Assert.AreEqual(rpAssignment.Id, gRpas.Entries.Single(rpa => rpa.Id == rpAssignment.Id).Id); - - // Get files under retention policies for assignment - var fRPs = await Client.RetentionPoliciesManager.GetFilesUnderRetentionForAssignmentAsync(gRpas.Entries[0].Id); - - Assert.IsNotNull(fRPs.Entries[0].Id); - - // Get file version retention policies for assignment - var fvRPs = await Client.RetentionPoliciesManager.GetFileVersionsUnderRetentionForAssignmentAsync(gRpas.Entries[0].Id); - - // Update a retention policy - var uRp = await Client.RetentionPoliciesManager.UpdateRetentionPolicyAsync(retentionPolicy.Id, new BoxRetentionPolicyRequest() - { - Status = "retired" - }); - - Assert.AreEqual("retired", uRp.Status); - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxSearchManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs similarity index 87% rename from Box.V2.Test.IntegrationNew/BoxSearchManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs index 86dc6f46b..352fa7ad9 100644 --- a/Box.V2.Test.IntegrationNew/BoxSearchManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxSearchManagerIntegrationTest.cs @@ -1,9 +1,9 @@ using System.Threading.Tasks; using Box.V2.Models; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxSearchManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxSearchManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxSearchManagerTestIntegration.cs deleted file mode 100644 index 628e21379..000000000 --- a/Box.V2.Test.Integration/BoxSearchManagerTestIntegration.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Models; -using Box.V2.Models.Request; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxSearchManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task SearchKeyword_LiveSession_ValidResponse() - { - const string Keyword = "IMG"; - const int NumResults = 13; - const int NumFiles = 12; - const int NumFolders = 1; - - BoxCollection results = await Client.SearchManager.SearchAsync(Keyword, 200); - - Assert.IsNotNull(results, "Search results are null"); - Assert.AreEqual(NumResults, results.Entries.Count, "Incorrect number of search results"); - Assert.IsTrue(results.Entries.Count(item => item is BoxFolder) == NumFolders, "Incorrect number of folders in search results"); - Assert.IsTrue(results.Entries.Count(item => item is BoxFile) == NumFiles, "Incorrect number of files in search results"); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task SearchKeyword_LiveSession_EmptyResult() - { - const string Keyword = "NonExistentKeyWord"; - - BoxCollection results = await Client.SearchManager.SearchAsync(Keyword, 200); - - Assert.IsNotNull(results, "Search results are null"); - Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results"); - } - - [TestMethod] - public async Task SearchAdvanced_LiveSession() - { - const string Keyword = "IMG"; - - //search using an extension that should return results - BoxCollection results = await Client.SearchManager.SearchAsync(Keyword, 200, fileExtensions: new List() { "jpg" }); - Assert.AreEqual(12, results.Entries.Count, "Incorrect number of search results using extension"); - - //search using an extension that should not return results - results = await Client.SearchManager.SearchAsync(Keyword, 200, fileExtensions: new List() { "pdf" }); - Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using extension"); - - //search using a created at daterange that should return results - var start = new DateTimeOffset(2014, 5, 1, 0, 0, 0, TimeSpan.Zero); - var end = new DateTimeOffset(2014, 5, 30, 0, 0, 0, TimeSpan.Zero); - results = await Client.SearchManager.SearchAsync(Keyword, 200, createdAtRangeFromDate: start, createdAtRangeToDate: end); - Assert.AreEqual(13, results.Entries.Count, "Incorrect number of search results using created at date range"); - - //search using a created at daterange that should not return results - start = new DateTimeOffset(2014, 6, 1, 0, 0, 0, TimeSpan.Zero); - end = new DateTimeOffset(2014, 6, 30, 0, 0, 0, TimeSpan.Zero); - results = await Client.SearchManager.SearchAsync(Keyword, 200, createdAtRangeFromDate: start, createdAtRangeToDate: end); - Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using created at date range"); - - //search using a updated at daterange that should return results - start = new DateTimeOffset(2014, 5, 1, 0, 0, 0, TimeSpan.Zero); - end = new DateTimeOffset(2014, 5, 30, 0, 0, 0, TimeSpan.Zero); - results = await Client.SearchManager.SearchAsync(Keyword, 200, updatedAtRangeFromDate: start, updatedAtRangeToDate: end); - Assert.AreEqual(12, results.Entries.Count, "Incorrect number of search results using updated at date range"); - - //search using a size range that should return results - var minBytes = 150000; - var maxBytes = 400000; - results = await Client.SearchManager.SearchAsync(Keyword, 200, sizeRangeLowerBoundBytes: minBytes, sizeRangeUpperBoundBytes: maxBytes); - Assert.AreEqual(2, results.Entries.Count, "Incorrect number of search results using size range"); - - //search using a size range that should not return results - minBytes = 40000000; - maxBytes = 50000000; - results = await Client.SearchManager.SearchAsync(Keyword, 200, sizeRangeLowerBoundBytes: minBytes, sizeRangeUpperBoundBytes: maxBytes); - Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using size range"); - - //search using an owner Id that should return results - var ownerId = "215917383"; - results = await Client.SearchManager.SearchAsync(Keyword, 200, ownerUserIds: new List() { ownerId }); - Assert.AreEqual(13, results.Entries.Count, "Incorrect number of search results using owner id"); - - //search using an owner Id that should not return results - ownerId = "1"; - results = await Client.SearchManager.SearchAsync(Keyword, 200, ownerUserIds: new List() { ownerId }); - Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using owner id"); - - //search using an ancestor folder Id that should return subset of results - var ancestorFolderId = "1927308583"; - results = await Client.SearchManager.SearchAsync(Keyword, 200, ancestorFolderIds: new List() { ancestorFolderId }); - Assert.AreEqual(6, results.Entries.Count, "Incorrect number of search results using ancestor folder id"); - - //search using a content type that should return subset of results - var contentType = "file_content"; - results = await Client.SearchManager.SearchAsync(Keyword, 200, contentTypes: new List() { contentType }); - Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using ancestor folder id"); - - //search using a type that should return files only - var type = "file"; - results = await Client.SearchManager.SearchAsync(Keyword, 200, type: type); - Assert.AreEqual(12, results.Entries.Count, "Incorrect number of search results using type"); - - //search using a type that should return folders only - type = "folder"; - results = await Client.SearchManager.SearchAsync(Keyword, 200, type: type); - Assert.AreEqual(1, results.Entries.Count, "Incorrect number of search results using type"); - - //search using a type that should return web links only - type = "web_link"; - results = await Client.SearchManager.SearchAsync(Keyword, 200, type: type); - Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using type"); - - //search trashed content only - results = await Client.SearchManager.SearchAsync(Keyword, 200, trashContent: "trashed_only"); - Assert.AreEqual(0, results.Entries.Count, "Incorrect number of search results using trashed_only"); - - //search non-trashed content only - results = await Client.SearchManager.SearchAsync(Keyword, 200, trashContent: "non_trashed_only"); - Assert.AreEqual(13, results.Entries.Count, "Incorrect number of search results using non_trashed_only"); - } - - [TestMethod] - public async Task SearchMetadata_LiveSession() - { - - - var filter = new - { - attr1 = "blah", - attr2 = new { gt = 5, lt = 5 }, - attr3 = new - { - gt = new DateTimeOffset(2016, 10, 1, 0, 0, 0, TimeSpan.Zero), - lt = new DateTimeOffset(2016, 11, 5, 0, 0, 0, TimeSpan.Zero) - }, - attr4 = "value1" - }; - - var mdFilter = new BoxMetadataFilterRequest() - { - TemplateKey = "testtemplate", - Scope = "enterprise", - Filters = filter - }; - - var results = await Client.SearchManager.SearchAsync(mdFilters: new List() { mdFilter }); - Assert.AreEqual(1, results.Entries.Count, "Incorrect number of search results using metadata search"); - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxSharedItemsManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxSharedItemsManagerIntegrationTest.cs similarity index 91% rename from Box.V2.Test.IntegrationNew/BoxSharedItemsManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxSharedItemsManagerIntegrationTest.cs index 6242412e8..d0576e1b7 100644 --- a/Box.V2.Test.IntegrationNew/BoxSharedItemsManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxSharedItemsManagerIntegrationTest.cs @@ -1,9 +1,9 @@ using System.Threading.Tasks; using Box.V2.Models; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxSharedItemsManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxSharedItemsManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxSharedItemsManagerTestIntegration.cs deleted file mode 100644 index 42ec5f72c..000000000 --- a/Box.V2.Test.Integration/BoxSharedItemsManagerTestIntegration.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxSharedItemsManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task SharedLink_LiveSession() - { - const string SharedLink = "https://app.box.com/s/70pecdxd6pvnd285rs4hqdp7zphgyqva"; - const string Password = "demo1234"; - const string ExpectedId = "16894946307"; - - var sharedItem = await Client.SharedItemsManager.SharedItemsAsync(SharedLink, sharedLinkPassword: Password); - - Assert.AreEqual(ExpectedId, sharedItem.Id); - } - } -} diff --git a/Box.V2.Test.Integration/BoxStoragePoliciesManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxStoragePoliciesManagerTestIntegration.cs deleted file mode 100644 index 41816ff7f..000000000 --- a/Box.V2.Test.Integration/BoxStoragePoliciesManagerTestIntegration.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxStoragePoliciesManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task AssignStoragePolicyAsync_LiveSession() - { - _ = await Client.StoragePoliciesManager.GetAssignmentAsync("user_240097255"); - } - } -} diff --git a/Box.V2.Test.Integration/BoxTasksManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxTasksManagerTestIntegration.cs deleted file mode 100644 index 96f2b4e76..000000000 --- a/Box.V2.Test.Integration/BoxTasksManagerTestIntegration.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.Threading.Tasks; -using Box.V2.Models; -using Box.V2.Models.Request; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxTasksManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task TasksWorkflow_ValidRequest() - { - // Create a task - var task = await Client.TasksManager.CreateTaskAsync(new BoxTaskCreateRequest() - { - Item = new BoxRequestEntity() - { - Id = "100699285359", - Type = BoxType.file - }, - Message = "REVIEW PLZ K THX", - DueAt = DateTimeOffset.Now.AddDays(30) - }); - - // Creat task assignment - var taskAssignment = await Client.TasksManager.CreateTaskAssignmentAsync(new BoxTaskAssignmentRequest() - { - Task = new BoxTaskRequest() - { - Id = task.Id - }, - AssignTo = new BoxAssignmentRequest() - { - Id = "215917383" - } - }); - - // Get task - var gTask = await Client.TasksManager.GetTaskAsync(task.Id); - Assert.AreEqual(gTask.Message, task.Message, "Task does not have the same message"); - - // Get task assignment - var gTaskAssignment = await Client.TasksManager.GetTaskAssignmentAsync(taskAssignment.Id); - Assert.AreEqual(taskAssignment.AssignedTo.Id, gTaskAssignment.AssignedTo.Id, "Task does not have the same message"); - - // Update task - var uTask = await Client.TasksManager.UpdateTaskAsync(new BoxTaskUpdateRequest() - { - Id = task.Id, - Message = "PLZ" - }); - Assert.AreEqual(uTask.Message, "PLZ", "Task message does not update!"); - - // Update task assignment - var uTaskAssignment = await Client.TasksManager.UpdateTaskAssignmentAsync(new BoxTaskAssignmentUpdateRequest() - { - Id = taskAssignment.Id, - Message = "TA Update MSG" - }); - Assert.AreEqual(uTaskAssignment.Message, "TA Update MSG", "Task assignment message does not update!"); - - // Get task assignments - var taskAssignments = await Client.TasksManager.GetAssignmentsAsync(task.Id); - Assert.AreEqual(1, taskAssignments.Entries.Count, "Task assignmnet number are incorrect!"); - Assert.AreEqual(taskAssignments.Entries[0].Id, uTaskAssignment.Id, "Task assignment id are incorrect!"); - - // Delete task assignment - await Client.TasksManager.DeleteTaskAssignmentAsync(taskAssignment.Id); - - // Delete task - await Client.TasksManager.DeleteTaskAsync(task.Id); - } - } -} diff --git a/Box.V2.Test.Integration/BoxTermsOfServicesManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxTermsOfServicesManagerTestIntegration.cs deleted file mode 100644 index 901b32a87..000000000 --- a/Box.V2.Test.Integration/BoxTermsOfServicesManagerTestIntegration.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxTermsOfServicesManagerTestIntegration : BoxResourceManagerTestIntegration - { - // create terms of service - [TestMethod] - public async Task CreateTermsOfServices_ValidResponse() - { - var termsOfService = await Client.TermsOfServiceManager.CreateTermsOfServicesAsync(new BoxTermsOfServicesRequest - { - Status = "enabled", - TosType = "managed", - Text = "Test Text" - }); - - Assert.IsNotNull(termsOfService, "Terms of Service was not created"); - } - - // retrieve all terms of services - [TestMethod] - public async Task GetTermsOfServices_ValidResponse() - { - var termsOfService = await Client.TermsOfServiceManager.GetTermsOfServicesAsync(); - Assert.IsNotNull(termsOfService, "Returned Terms of Service successfully"); - } - - // retrieve terms of service by id - [TestMethod] - public async Task GetTermsOfServicesById_ValidResponse() - { - var termsOfService = await Client.TermsOfServiceManager.GetTermsOfServicesByIdAsync("2778"); - Assert.IsNotNull(termsOfService, "Successfully returned Terms of Service with specified ID"); - - var termsOfServiceUserStatuses = await Client.TermsOfServiceManager.CreateBoxTermsOfServiceUserStatusesAsync(new BoxTermsOfServiceUserStatusesRequest - { - TermsOfService = termsOfService, - IsAccepted = true - }); - Assert.IsNotNull(termsOfServiceUserStatuses, "User Status for Terms of Service was successfully created"); - } - - // update terms of service information - [TestMethod] - public async Task UpdateTermsOfServices_ValidReponse() - { - var termsOfService = await Client.TermsOfServiceManager.UpdateTermsOfServicesAsync("2778", new BoxTermsOfServicesRequest - { - Status = "enabled", - Text = "Test Text" - }); - Assert.AreEqual(termsOfService.Text, "Test Text"); - } - - // get terms of user status for terms of service - [TestMethod] - public async Task GetTermsOfServiceUserStatuses_ValidResponse() - { - var termsOfServiceUserStatuses = await Client.TermsOfServiceManager.GetTermsOfServiceUserStatusesAsync("2778"); - Assert.IsNotNull(termsOfServiceUserStatuses, "Returned user status for Terms of Service successfully"); - } - - // update user status on terms of service - [TestMethod] - public async Task UpdateTermsOfServiceUserStatuses_ValidResponse() - { - var termsOfServiceUserStatuses = await Client.TermsOfServiceManager.UpdateTermsofServiceUserStatusesAsync("1939280", true); - Assert.AreEqual(termsOfServiceUserStatuses.IsAccepted, true); - } - } -} diff --git a/Box.V2.Test.Integration/BoxTokenExchangeTestIntegration.cs b/Box.V2.Test.Integration/BoxTokenExchangeTestIntegration.cs deleted file mode 100644 index d1dcb7160..000000000 --- a/Box.V2.Test.Integration/BoxTokenExchangeTestIntegration.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Box.V2.Auth; -using Box.V2.Auth.Token; -using Box.V2.Config; -using Box.V2.Exceptions; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxTokenExchangeTestIntegration : BoxResourceManagerTestIntegration - { - private static BoxClient CreateClientByToken(string token) - { - var auth = new OAuthSession(token, "YOUR_REFRESH_TOKEN", 3600, "bearer"); - - var config = new BoxConfigBuilder(string.Empty, string.Empty, new Uri("http://boxsdk")) - .Build(); - var client = new BoxClient(config, auth); - - return client; - } - - [TestMethod] - public async Task TokenExchange_LiveSession() - { - var token = Client.Auth.Session.AccessToken; - var fileId = "16894965489"; - var folderId = "1927307787"; - - var client = CreateClientByToken(token); - _ = await client.FilesManager.GetInformationAsync(fileId); - - // var resource = string.Format("https://api.box.com/2.0/files/{0}", fileId); - var resource = string.Format("https://api.box.com/2.0/folders/{0}", folderId); - - var scopes = new List { "item_preview", "item_delete" }; - var tokenExchange = new TokenExchange(token, scopes); - - // Check resource to be optional - var token1 = tokenExchange.ExchangeAsync().Result; - var client1 = CreateClientByToken(token1); - - // Should be able to access the file - var file1 = await client1.FilesManager.GetInformationAsync(fileId); - Assert.IsNotNull(file1.Id); - - // Set resource - tokenExchange.SetResource(resource); - var token2 = tokenExchange.ExchangeAsync().Result; - var client2 = CreateClientByToken(token2); - try - { - await client2.FilesManager.GetInformationAsync(fileId); - Assert.Fail(); - } - catch (BoxException) - { - // The new token does not have access to the file any more. - } - - // Can still access the folder. - var folderInfo = await client2.FoldersManager.GetInformationAsync(folderId); - Assert.IsNotNull(folderInfo.Name); - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxUsersManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxUsersManagerIntegrationTest.cs similarity index 96% rename from Box.V2.Test.IntegrationNew/BoxUsersManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxUsersManagerIntegrationTest.cs index db23266b6..ff3595fb8 100644 --- a/Box.V2.Test.IntegrationNew/BoxUsersManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxUsersManagerIntegrationTest.cs @@ -1,10 +1,10 @@ using System.Linq; using System.Threading.Tasks; using Box.V2.Models; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxUsersManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxUsersManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxUsersManagerTestIntegration.cs deleted file mode 100644 index 6e0206021..000000000 --- a/Box.V2.Test.Integration/BoxUsersManagerTestIntegration.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxUsersManagerTestIntegration : BoxResourceManagerTestIntegration - { - private static readonly Random _random = new Random(); - - protected static string RandomString(int length) - { - const string Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - return new string(Enumerable.Repeat(Chars, length) - .Select(s => s[_random.Next(s.Length)]).ToArray()); - } - - [TestMethod] - public async Task UsersInformation_LiveSession_ValidResponse() - { - BoxUser user = await Client.UsersManager.GetCurrentUserInformationAsync(); - - Assert.AreEqual("215917383", user.Id); - Assert.AreEqual("Box Windows", user.Name); - Assert.AreEqual("boxwinintegration@gmail.com", user.Login, true); - } - - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task ExternalAppUserId_LiveSession_ValidResponse() - { - // Works only on adminClient - if (AdminClient == null) - { - return; - } - - // Create - var userRequest = new BoxUserRequest - { - Name = "AppUser ExtId Test", - IsPlatformAccessOnly = true, // creating application specific user, not a Box.com user - ExternalAppUserId = "yhu-au" + RandomString(3) - }; - - var newUser = await AdminClient.UsersManager.CreateEnterpriseUserAsync(userRequest); - - // Update - var updateUserRequest = new BoxUserRequest - { - Id = newUser.Id, - ExternalAppUserId = "yhu-au" + RandomString(3) - }; - - var updatedUser = await AdminClient.UsersManager.UpdateUserInformationAsync(updateUserRequest); - Assert.AreEqual(newUser.Id, updatedUser.Id); - - // Get - var appUsers = await AdminClient.UsersManager.GetEnterpriseUsersAsync(null, 0, 100, null, null, updateUserRequest.ExternalAppUserId); - Assert.AreEqual(appUsers.Entries.Count, 1); - - // Delete - await AdminClient.UsersManager.DeleteEnterpriseUserAsync(appUsers.Entries[0].Id, false, true); - } - - [TestMethod] - public async Task EnterpriseUsersInformation_LiveSession_ValidResponse() - { - BoxCollection users = await Client.UsersManager.GetEnterpriseUsersAsync("test.user", userType: "all"); - - Assert.AreEqual(users.TotalCount, 1); - Assert.AreEqual(users.Entries.First().Name, "Test User"); - Assert.AreEqual(users.Entries.First().Login, "test.user@example.com"); - } - - [TestMethod] - public async Task EnterpriseUsersAutoPagination_LiveSession_ValidResponse() - { - BoxCollection users = await Client.UsersManager.GetEnterpriseUsersAsync(limit: 1, userType: "all", autoPaginate: true); - - Assert.IsTrue(users.TotalCount > 2); - } - - [TestMethod] - public async Task EnterpriseUsersMarkerBasedPagination_LiveSession_ValidResponse() - { - BoxCollectionMarkerBased users = await Client.UsersManager.GetEnterpriseUsersWithMarkerAsync(limit: 1); - Assert.IsTrue(users.Entries.Count == 1); - - BoxCollectionMarkerBased users2 = await Client.UsersManager.GetEnterpriseUsersWithMarkerAsync(marker: users.NextMarker, limit: 2); - Assert.IsTrue(users2.Entries.Count == 2); - } - } -} diff --git a/Box.V2.Test.IntegrationNew/BoxWebLinkManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxWebLinkManagerIntegrationTest.cs similarity index 96% rename from Box.V2.Test.IntegrationNew/BoxWebLinkManagerIntegrationTest.cs rename to Box.V2.Test.Integration/BoxWebLinkManagerIntegrationTest.cs index db48f815a..989d506d8 100644 --- a/Box.V2.Test.IntegrationNew/BoxWebLinkManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxWebLinkManagerIntegrationTest.cs @@ -1,10 +1,10 @@ using System; using System.Threading.Tasks; using Box.V2.Models; -using Box.V2.Test.IntegrationNew.Configuration; +using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew +namespace Box.V2.Test.Integration { [TestClass] public class BoxWebLinkManagerIntegrationTest : TestInFolder diff --git a/Box.V2.Test.Integration/BoxWebLinkManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxWebLinkManagerTestIntegration.cs deleted file mode 100644 index 8e494392a..000000000 --- a/Box.V2.Test.Integration/BoxWebLinkManagerTestIntegration.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxWebLinkManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - [TestCategory("CI-APP-USER")] - public async Task WebLinks_CRUD_LiveSession() - { - var url = new Uri("http://www.box.com"); - const string Description = "A weblink to Box.com"; - const string Name = "Box.com website"; - - //create weblink - var wlr = new BoxWebLinkRequest() { Url = url, Name = Name, Description = Description, Parent = new BoxRequestEntity() { Id = "0" } }; - var weblink = await Client.WebLinksManager.CreateWebLinkAsync(wlr); - Assert.AreEqual(Name, weblink.Name, "Failed to create weblink."); - Assert.AreEqual(url, weblink.Url); - - //get weblink - var fetchedWeblink = await Client.WebLinksManager.GetWebLinkAsync(weblink.Id); - Assert.AreEqual(weblink.Id, fetchedWeblink.Id, "Failed to fetch existing weblink."); - Assert.AreEqual(weblink.Name, fetchedWeblink.Name, "Failed to fetch existing weblink."); - - //update weblink - var newUrl = new Uri("http://www.google.com"); - var newName = "Google website"; - var newDescription = "A weblink to Google.com"; - wlr = new BoxWebLinkRequest() { Url = newUrl, Description = newDescription, Name = newName }; - var updatedWeblink = await Client.WebLinksManager.UpdateWebLinkAsync(fetchedWeblink.Id, wlr); - Assert.AreEqual(fetchedWeblink.Id, updatedWeblink.Id, "Failed to update existing weblink."); - Assert.AreEqual(newUrl, updatedWeblink.Url, "Failed to update existing weblink."); - Assert.AreEqual(newDescription, updatedWeblink.Description, "Failed to update existing weblink."); - Assert.AreEqual(newName, updatedWeblink.Name, "Failed to update existing weblink."); - - //delete weblink - var result = await Client.WebLinksManager.DeleteWebLinkAsync(updatedWeblink.Id); - Assert.IsTrue(result, "Failed to delete weblink."); - - } - } -} diff --git a/Box.V2.Test.Integration/BoxWebhooksManagerTestIntegration.cs b/Box.V2.Test.Integration/BoxWebhooksManagerTestIntegration.cs deleted file mode 100644 index 41411252d..000000000 --- a/Box.V2.Test.Integration/BoxWebhooksManagerTestIntegration.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Box.V2.Models; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace Box.V2.Test.Integration -{ - [TestClass] - public class BoxWebhooksManagerTestIntegration : BoxResourceManagerTestIntegration - { - [TestMethod] - public async Task WebhookTests_LiveSession() - { - const string TRIGGER1 = "FILE.PREVIEWED"; - const string TRIGGER2 = "FILE.DOWNLOADED"; - const string ADDRESS1 = "https://example1.com"; - const string ADDRESS2 = "https://example2.com"; - - //first remove any dangling webhooks from previous failed tests - var existingWebhooks = await Client.WebhooksManager.GetWebhooksAsync(autoPaginate: true); - foreach (var wh in existingWebhooks.Entries) - { - await Client.WebhooksManager.DeleteWebhookAsync(wh.Id); - } - - //create a new webhook on a file - var target = new BoxRequestEntity() { Id = "16894937051", Type = BoxType.file }; - var triggers = new List() { TRIGGER1 }; - var whr = new BoxWebhookRequest() { Target = target, Address = ADDRESS1, Triggers = triggers }; - var webhook = await Client.WebhooksManager.CreateWebhookAsync(whr); - Assert.IsNotNull(webhook, "Failed to create webhook"); - Assert.AreEqual(TRIGGER1, webhook.Triggers.First(), "Webhook trigger does not match"); - Assert.AreEqual(ADDRESS1, webhook.Address, "Webhook address does not match"); - - //get a webhook - var fetchedWebhook = await Client.WebhooksManager.GetWebhookAsync(webhook.Id); - Assert.AreEqual(fetchedWebhook.Id, webhook.Id, "Failed to get webhook"); - - //update a webhook - triggers = new List() { TRIGGER1, TRIGGER2 }; - whr = new BoxWebhookRequest() { Id = webhook.Id, Address = ADDRESS2, Triggers = triggers }; - var updatedWebhook = await Client.WebhooksManager.UpdateWebhookAsync(whr); - Assert.IsTrue(updatedWebhook.Triggers.Contains(TRIGGER1), "Webhook trigger does not match"); - Assert.IsTrue(updatedWebhook.Triggers.Contains(TRIGGER2), "Webhook trigger does not match"); - Assert.AreEqual(ADDRESS2, updatedWebhook.Address, "Webhook address does not match"); - - //delete a webhook - var result = await Client.WebhooksManager.DeleteWebhookAsync(webhook.Id); - Assert.IsTrue(result, "Failed to delete webhook"); - } - } -} diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFileCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFileCommand.cs similarity index 86% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFileCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFileCommand.cs index 92efd36ba..46fac3c98 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFileCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFileCommand.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.CleanupCommands +namespace Box.V2.Test.Integration.Configuration.Commands.CleanupCommands { public class DeleteFileCommand : CommandBase, ICleanupCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs similarity index 87% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs index 040ff39dc..e2fbac525 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.CleanupCommands +namespace Box.V2.Test.Integration.Configuration.Commands.CleanupCommands { public class DeleteFolderCommand : CommandBase, ICleanupCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/CommandAccessLevel.cs b/Box.V2.Test.Integration/Configuration/Commands/CommandAccessLevel.cs similarity index 56% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/CommandAccessLevel.cs rename to Box.V2.Test.Integration/Configuration/Commands/CommandAccessLevel.cs index f72565d8a..48b8a7f13 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/CommandAccessLevel.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CommandAccessLevel.cs @@ -1,4 +1,4 @@ -namespace Box.V2.Test.IntegrationNew.Configuration.Commands +namespace Box.V2.Test.Integration.Configuration.Commands { public enum CommandAccessLevel { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/CommandBase.cs b/Box.V2.Test.Integration/Configuration/Commands/CommandBase.cs similarity index 86% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/CommandBase.cs rename to Box.V2.Test.Integration/Configuration/Commands/CommandBase.cs index c4e569239..835405b57 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/CommandBase.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CommandBase.cs @@ -1,4 +1,4 @@ -namespace Box.V2.Test.IntegrationNew.Configuration.Commands +namespace Box.V2.Test.Integration.Configuration.Commands { public abstract class CommandBase : ICommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/CommandScope.cs b/Box.V2.Test.Integration/Configuration/Commands/CommandScope.cs similarity index 60% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/CommandScope.cs rename to Box.V2.Test.Integration/Configuration/Commands/CommandScope.cs index 3c332e782..4ca2b1cb1 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/CommandScope.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CommandScope.cs @@ -1,4 +1,4 @@ -namespace Box.V2.Test.IntegrationNew.Configuration.Commands +namespace Box.V2.Test.Integration.Configuration.Commands { public enum CommandScope { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs similarity index 92% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs index 1d7cf7d9e..36f94553d 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/AddCollaborationExemptCommand.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; using Box.V2.Models; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands { public class AddCollaborationExemptCommand : CommandBase, IDisposableCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/ApplyMetadataCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/ApplyMetadataCommand.cs similarity index 93% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/ApplyMetadataCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/ApplyMetadataCommand.cs index 0c938ec45..3284f4964 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/ApplyMetadataCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/ApplyMetadataCommand.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands { public class ApplyMetadataCommand : CommandBase, IDisposableCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs similarity index 93% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs index 433ae8327..0089e07e9 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateEnterpriseUserCommand.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; using Box.V2.Models; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands { public class CreateEnterpriseUserCommand : CommandBase, IDisposableCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateFileCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFileCommand.cs similarity index 95% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateFileCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFileCommand.cs index e58279aa4..51bcdf5aa 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateFileCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFileCommand.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using Box.V2.Models; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands { public class CreateFileCommand : CommandBase, IDisposableCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs similarity index 94% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs index bb6e6c076..5d2b7a865 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; using Box.V2.Models; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands { public class CreateFolderCommand : CommandBase, IDisposableCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs similarity index 94% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs index 93421187a..4a7297fbb 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateMetadataTemplateCommand.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using Box.V2.Models; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands { public class CreateMetadataTemplateCommand : CommandBase, IDisposableCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateRetentionPolicyCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateRetentionPolicyCommand.cs similarity index 96% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateRetentionPolicyCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateRetentionPolicyCommand.cs index 7709eee48..08303c8db 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateRetentionPolicyCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateRetentionPolicyCommand.cs @@ -2,7 +2,7 @@ using Box.V2.Models; using Box.V2.Models.Request; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands { public class CreateRetentionPolicyCommand : CommandBase, IDisposableCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs similarity index 94% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs index 1bc4bab5d..859e01d27 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateWebLinkCommand.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using Box.V2.Models; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands { public class CreateWebLinkCommand : CommandBase, IDisposableCommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Commands/ICommand.cs b/Box.V2.Test.Integration/Configuration/Commands/ICommand.cs similarity index 87% rename from Box.V2.Test.IntegrationNew/Configuration/Commands/ICommand.cs rename to Box.V2.Test.Integration/Configuration/Commands/ICommand.cs index 24ce031b8..2e428d742 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Commands/ICommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/ICommand.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace Box.V2.Test.IntegrationNew.Configuration.Commands +namespace Box.V2.Test.Integration.Configuration.Commands { public interface ICommand { diff --git a/Box.V2.Test.IntegrationNew/Configuration/Extensions/DateTimeExtensions.cs b/Box.V2.Test.Integration/Configuration/Extensions/DateTimeExtensions.cs similarity index 85% rename from Box.V2.Test.IntegrationNew/Configuration/Extensions/DateTimeExtensions.cs rename to Box.V2.Test.Integration/Configuration/Extensions/DateTimeExtensions.cs index 6c3784090..1fa92b18c 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/Extensions/DateTimeExtensions.cs +++ b/Box.V2.Test.Integration/Configuration/Extensions/DateTimeExtensions.cs @@ -1,6 +1,6 @@ using System; -namespace Box.V2.Test.IntegrationNew.Configuration.Extensions +namespace Box.V2.Test.Integration.Configuration.Extensions { public static class DateTimeExtensions { diff --git a/Box.V2.Test.IntegrationNew/Configuration/IntegrationTestBase.cs b/Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs similarity index 98% rename from Box.V2.Test.IntegrationNew/Configuration/IntegrationTestBase.cs rename to Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs index 278861015..e79501dc4 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/IntegrationTestBase.cs +++ b/Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs @@ -8,9 +8,9 @@ using Box.V2.Config; using Box.V2.JWTAuth; using Box.V2.Models; -using Box.V2.Test.IntegrationNew.Configuration.Commands; -using Box.V2.Test.IntegrationNew.Configuration.Commands.CleanupCommands; -using Box.V2.Test.IntegrationNew.Configuration.Commands.DisposableCommands; +using Box.V2.Test.Integration.Configuration.Commands; +using Box.V2.Test.Integration.Configuration.Commands.CleanupCommands; +using Box.V2.Test.Integration.Configuration.Commands.DisposableCommands; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json.Linq; diff --git a/Box.V2.Test.IntegrationNew/Configuration/TestInFolder.cs b/Box.V2.Test.Integration/Configuration/TestInFolder.cs similarity index 85% rename from Box.V2.Test.IntegrationNew/Configuration/TestInFolder.cs rename to Box.V2.Test.Integration/Configuration/TestInFolder.cs index 4efe2ca1c..8bbc6a014 100644 --- a/Box.V2.Test.IntegrationNew/Configuration/TestInFolder.cs +++ b/Box.V2.Test.Integration/Configuration/TestInFolder.cs @@ -1,9 +1,9 @@ using System.Threading.Tasks; using Box.V2.Test.Integration; -using Box.V2.Test.IntegrationNew.Configuration.Commands; +using Box.V2.Test.Integration.Configuration.Commands; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Box.V2.Test.IntegrationNew.Configuration +namespace Box.V2.Test.Integration.Configuration { [TestClass] public abstract class TestInFolder : IntegrationTestBase diff --git a/Box.V2.Test.Integration/Properties/AssemblyInfo.cs b/Box.V2.Test.Integration/Properties/AssemblyInfo.cs deleted file mode 100644 index e6624b6ad..000000000 --- a/Box.V2.Test.Integration/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Box.V2.Test.Integration")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Box.V2.Test.Integration")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("13b23b67-057b-4357-93e8-5f61544683a5")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Box.V2.Test.Integration/Properties/smalltestpdf.Designer.cs b/Box.V2.Test.Integration/Properties/smalltestpdf.Designer.cs deleted file mode 100644 index 181bd2cc5..000000000 --- a/Box.V2.Test.Integration/Properties/smalltestpdf.Designer.cs +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Box.V2.Test.Integration.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class smalltestpdf { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal smalltestpdf() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Box.V2.Test.Integration.Properties.smalltestpdf", typeof(smalltestpdf).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Byte[]. - /// - internal static byte[] smalltest { - get { - object obj = ResourceManager.GetObject("smalltest", resourceCulture); - return ((byte[])(obj)); - } - } - } -} diff --git a/Box.V2.Test.Integration/Properties/smalltestpdf.resx b/Box.V2.Test.Integration/Properties/smalltestpdf.resx deleted file mode 100644 index 206e605b0..000000000 --- a/Box.V2.Test.Integration/Properties/smalltestpdf.resx +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\TestData\smalltest.pdf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Box.V2.Test.IntegrationNew/TestData/smalltestV2.pdf b/Box.V2.Test.Integration/TestData/smalltestV2.pdf similarity index 100% rename from Box.V2.Test.IntegrationNew/TestData/smalltestV2.pdf rename to Box.V2.Test.Integration/TestData/smalltestV2.pdf diff --git a/Box.V2.Test.Integration/app.config b/Box.V2.Test.Integration/app.config deleted file mode 100644 index 597a774ee..000000000 --- a/Box.V2.Test.Integration/app.config +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Box.V2.Test.IntegrationNew/Box.V2.Test.IntegrationNew.csproj b/Box.V2.Test.IntegrationNew/Box.V2.Test.IntegrationNew.csproj deleted file mode 100644 index 658406ca7..000000000 --- a/Box.V2.Test.IntegrationNew/Box.V2.Test.IntegrationNew.csproj +++ /dev/null @@ -1,37 +0,0 @@ - - - - netcoreapp2.0;net45 - - false - false - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - diff --git a/Box.V2.Test.IntegrationNew/TestData/smalltest.pdf b/Box.V2.Test.IntegrationNew/TestData/smalltest.pdf deleted file mode 100644 index 043d578cd822a1a5909d19aa51fce66cf1e2d660..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2526 zcmcguZBN@U5dQ98aYO0^6M1ivf+_@bLz)I#fl1SZ_Q6fuG$XM)$3=9%ezuc1r7a9J zv6Gr8PtJGGa~Gf68^1rZJUc|F_xgrA7>@b3p-)u5xj-r?Scz?J|+3IAjjqMmKAtXzXX7u%<oVe(q!lvJ>wRx(qa zPv3y_d%nq9y}lvjfeUQ%6Agz5z!~FAa&9b;udWpObvY+32+jx#T(Ars9U($fwHEmg zf}H4&zFDvf7VN1Yx)qGqutCS1rHh2rutDp#G5Q`00tUTcsRne28eQR_*mgojY(YiK z*;DyH<*88yH_%t&;K!ysU4m6{%5ya^6@-d9RH%Ze5EmrP@hQ948E+)&LU<6upzqfy z#+b`R4Ifk2D^jrqPwI;62DFU3yCW-hUs+Ylca?s*aI0}*l5Bmy27Y_@B6n)M zRsQz37SlZP%(w@Bpc#h;O7eCqjkh2F-Mi?#qp*(M+_yzv@%C#5;q$!XzK$KcgGYIH zv0IhT^p2w!@D75P@NStrRqu}Xwu-G|GgI%ttGg35m0b5!&nvw=s4Ex6k9WRf;t%RC z`>EKS_qNRI*i`erM3+d7)n+HQ16J)&wRxjB8knhj&&d?I5F^(ZL}3_&Fog#52c8`8 z%7Av56uO4VQpFpX@5{6g*9LuG&XEV0=lY=>ku8Pe h3<1;$q|xjAcX!OhYIaoubD?F*EO97L#1CK2&>wsk-?#t( diff --git a/Box.V2.Test.IntegrationNew/config.json b/Box.V2.Test.IntegrationNew/config.json deleted file mode 100644 index 8951dec44..000000000 --- a/Box.V2.Test.IntegrationNew/config.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "boxAppSettings": { - "clientID": "", - "clientSecret": "", - "appAuth": { - "publicKeyID": "", - "privateKey": "", - "passphrase": "" - } - }, - "enterpriseID": "", - "userID": "" -} diff --git a/Box.V2.sln b/Box.V2.sln index 1855b7865..eb453c33e 100644 --- a/Box.V2.sln +++ b/Box.V2.sln @@ -11,8 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SDK Samples", "SDK Samples" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Box.V2.Test", "Box.V2.Test\Box.V2.Test.csproj", "{AA6B9D70-9314-43F8-A21D-773C814ED54E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box.V2.Test.Integration", "Box.V2.Test.Integration\Box.V2.Test.Integration.csproj", "{BC6D323A-09D0-4477-B695-7F6F6B32401F}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box.V2.Samples.JWTAuth", "Box.V2.Samples.JWTAuth\Box.V2.Samples.JWTAuth.csproj", "{D76E28A5-E9A4-4810-82E0-101F2B0C45B0}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box.V2.Samples.TransactionalAuth", "Box.V2.Samples.TransactionalAuth\Box.V2.Samples.TransactionalAuth.csproj", "{3438C884-06FE-4F94-A4DF-6DA024EB2B2D}" @@ -27,7 +25,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box.V2", "Box.V2\Box.V2.csp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Box.V2.Samples.Core.HttpProxy", "Box.V2.Samples.Core.HttpProxy\Box.V2.Samples.Core.HttpProxy.csproj", "{3CE48886-2A12-4DEB-874B-D2E3511A4F6A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Box.V2.Test.IntegrationNew", "Box.V2.Test.IntegrationNew\Box.V2.Test.IntegrationNew.csproj", "{C907EB1B-1654-48E5-AEB2-AF8D968F1B93}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Box.V2.Test.Integration", "Box.V2.Test.Integration\Box.V2.Test.Integration.csproj", "{C907EB1B-1654-48E5-AEB2-AF8D968F1B93}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -51,16 +49,6 @@ Global {AA6B9D70-9314-43F8-A21D-773C814ED54E}.Release|ARM.ActiveCfg = Release|Any CPU {AA6B9D70-9314-43F8-A21D-773C814ED54E}.Release|x64.ActiveCfg = Release|Any CPU {AA6B9D70-9314-43F8-A21D-773C814ED54E}.Release|x86.ActiveCfg = Release|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Debug|ARM.ActiveCfg = Debug|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Debug|x64.ActiveCfg = Debug|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Debug|x86.ActiveCfg = Debug|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Release|Any CPU.Build.0 = Release|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Release|ARM.ActiveCfg = Release|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Release|x64.ActiveCfg = Release|Any CPU - {BC6D323A-09D0-4477-B695-7F6F6B32401F}.Release|x86.ActiveCfg = Release|Any CPU {D76E28A5-E9A4-4810-82E0-101F2B0C45B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D76E28A5-E9A4-4810-82E0-101F2B0C45B0}.Debug|Any CPU.Build.0 = Debug|Any CPU {D76E28A5-E9A4-4810-82E0-101F2B0C45B0}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -189,7 +177,6 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {AA6B9D70-9314-43F8-A21D-773C814ED54E} = {5E724E70-EFFA-48E7-A539-F341E7E7CE30} - {BC6D323A-09D0-4477-B695-7F6F6B32401F} = {5E724E70-EFFA-48E7-A539-F341E7E7CE30} {D76E28A5-E9A4-4810-82E0-101F2B0C45B0} = {1F66A59A-7F58-43B6-81FA-3EA5EB40C764} {3438C884-06FE-4F94-A4DF-6DA024EB2B2D} = {1F66A59A-7F58-43B6-81FA-3EA5EB40C764} {CF62B2C3-4A2C-4C3F-821F-0CB89DE6CF62} = {A5BC8AA0-5191-4B1D-845F-B4F0BD0287A4} From 9438eb2e66967a1f452f931faaf82a25c2ffaae9 Mon Sep 17 00:00:00 2001 From: mwoda Date: Wed, 16 Feb 2022 21:02:37 +0100 Subject: [PATCH 03/17] add empty config --- Box.V2.Test.Integration/config.json | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Box.V2.Test.Integration/config.json diff --git a/Box.V2.Test.Integration/config.json b/Box.V2.Test.Integration/config.json new file mode 100644 index 000000000..8951dec44 --- /dev/null +++ b/Box.V2.Test.Integration/config.json @@ -0,0 +1,13 @@ +{ + "boxAppSettings": { + "clientID": "", + "clientSecret": "", + "appAuth": { + "publicKeyID": "", + "privateKey": "", + "passphrase": "" + } + }, + "enterpriseID": "", + "userID": "" +} From a939f28a5af6d3b6592a4b94a08934ae48966886 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 12:02:38 +0100 Subject: [PATCH 04/17] add documentation --- .../Commands/CommandAccessLevel.cs | 5 + .../Configuration/Commands/CommandBase.cs | 3 + .../Configuration/Commands/CommandScope.cs | 6 + .../Configuration/Commands/ICommand.cs | 35 +++++- .../Configuration/TestInFolder.cs | 4 +- Box.V2.Test.Integration/README.md | 105 ++++++++++++++++++ 6 files changed, 152 insertions(+), 6 deletions(-) create mode 100644 Box.V2.Test.Integration/README.md diff --git a/Box.V2.Test.Integration/Configuration/Commands/CommandAccessLevel.cs b/Box.V2.Test.Integration/Configuration/Commands/CommandAccessLevel.cs index 48b8a7f13..21141d241 100644 --- a/Box.V2.Test.Integration/Configuration/Commands/CommandAccessLevel.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CommandAccessLevel.cs @@ -1,5 +1,10 @@ namespace Box.V2.Test.Integration.Configuration.Commands { + /// + /// Defines with which BoxClient command will be executed. Possible values are User and Admin. + /// User - BoxClient with "user" scope (Managed User) + /// Admin - BoxClient with "enterprise" scope (ServiceAccount). + /// public enum CommandAccessLevel { User, diff --git a/Box.V2.Test.Integration/Configuration/Commands/CommandBase.cs b/Box.V2.Test.Integration/Configuration/Commands/CommandBase.cs index 835405b57..b25f26952 100644 --- a/Box.V2.Test.Integration/Configuration/Commands/CommandBase.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CommandBase.cs @@ -1,5 +1,8 @@ namespace Box.V2.Test.Integration.Configuration.Commands { + /// + /// Base class for ICommand intefaces. + /// public abstract class CommandBase : ICommand { public CommandScope Scope { get; } diff --git a/Box.V2.Test.Integration/Configuration/Commands/CommandScope.cs b/Box.V2.Test.Integration/Configuration/Commands/CommandScope.cs index 4ca2b1cb1..79a19fe7a 100644 --- a/Box.V2.Test.Integration/Configuration/Commands/CommandScope.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CommandScope.cs @@ -1,5 +1,11 @@ namespace Box.V2.Test.Integration.Configuration.Commands { + /// + /// Defines in which scope command will call Dispose method. Possible values are Test, Class and Assembly. + /// Test - Dispose will be called when the test is completed. + /// Class - Dispose will be called after all tests in the class have completed. + /// Assembly - Dispose will be called after all tests in the project have completed. + /// public enum CommandScope { Test, diff --git a/Box.V2.Test.Integration/Configuration/Commands/ICommand.cs b/Box.V2.Test.Integration/Configuration/Commands/ICommand.cs index 2e428d742..7588c54ee 100644 --- a/Box.V2.Test.Integration/Configuration/Commands/ICommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/ICommand.cs @@ -2,20 +2,45 @@ namespace Box.V2.Test.Integration.Configuration.Commands { + /// + /// Base interface for commands. Implement IDisposableCommand or ICleanupCommand instead. + /// public interface ICommand { CommandScope Scope { get; } CommandAccessLevel AccessLevel { get; } } - public interface ICleanupCommand : ICommand - { - Task Execute(IBoxClient client); - } - + /// + /// Interface used to create and remove/dispose of resources. Use for test setup. + /// public interface IDisposableCommand : ICommand { + /// + /// Creates resources required for the test. Returns the identifier of the resource. + /// + /// Box Client + /// Resource Id Task Execute(IBoxClient client); + + /// + /// Executed during tear down of the test. Clean resources created during Execute. + /// + /// Box Client + /// Task Dispose(IBoxClient client); } + + /// + /// Interface used to remove/dispose of resources. Use in test teardown if IDisposableCommand was not used for resource creation. + /// + public interface ICleanupCommand : ICommand + { + /// + /// Clean resources created in the test. + /// + /// Box Client + /// + Task Execute(IBoxClient client); + } } diff --git a/Box.V2.Test.Integration/Configuration/TestInFolder.cs b/Box.V2.Test.Integration/Configuration/TestInFolder.cs index 8bbc6a014..a6c89cb08 100644 --- a/Box.V2.Test.Integration/Configuration/TestInFolder.cs +++ b/Box.V2.Test.Integration/Configuration/TestInFolder.cs @@ -1,10 +1,12 @@ using System.Threading.Tasks; -using Box.V2.Test.Integration; using Box.V2.Test.Integration.Configuration.Commands; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Box.V2.Test.Integration.Configuration { + /// + /// Base class for most tests. When inherited, tests in the class will be executed in a separate folder + /// [TestClass] public abstract class TestInFolder : IntegrationTestBase { diff --git a/Box.V2.Test.Integration/README.md b/Box.V2.Test.Integration/README.md new file mode 100644 index 000000000..b777f275c --- /dev/null +++ b/Box.V2.Test.Integration/README.md @@ -0,0 +1,105 @@ +Integration tests +================== + +## Setup + +To run the integration tests locally, you need an existing Box app. Create a box app in https://cloud.app.box.com/developers/console. Select the JWT authentication method. You must enable all possible scopes and authorize your app to access the Enterprise if you want to run all the tests. Some tests requires enterprise access and different scopes. When your application is ready download App Settings as and replace the existing `config.json` file in this directory with your own. + +There is an optional `userId` field that you can fill in with your existing `userId`, so this user will be used in the tests and no new user will be created. + +You can run the test using Visual Studio test explorer or from the command line by calling the following command + +``` +dotnet test .\Box.V2.Test.Integration +``` + +By default, integration tests will run for .net framework and .net core. You can run tests against either of these by passing the -f flag as follows. + +``` +dotnet test .\Box.V2.Test.Integration -f netcoreapp2.0 +``` + +## Command approach for test setup + +Typically, integration tests require pre-existing resources (such as files) to operate on them. Such resources should also be removed from the account when the test ends or when an exception is thrown. To eliminate the need to duplicate such logic, the command approach was introduced. + +An example `IDisposableCommand` implementation looks like this + +```c# +using System.Threading.Tasks; +using Box.V2.Models; + +namespace Box.V2.Test.Integration.Configuration.Commands.DisposableCommands +{ + public class CreateFolderCommand : CommandBase, IDisposableCommand + { + private readonly string _folderName; + private readonly string _parentId; + + public string FolderId; + public BoxFolder Folder; + + public CreateFolderCommand(string folderName, string parentId = "0", CommandScope scope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) : base(scope, accessLevel) + { + _folderName = folderName; + _parentId = parentId; + } + + public async Task Execute(IBoxClient client) + { + var createFolderRequest = new BoxFolderRequest + { + Name = _folderName, + Parent = new BoxRequestEntity + { + Id = _parentId + } + }; + Folder = await client.FoldersManager.CreateAsync(createFolderRequest); + FolderId = Folder.Id; + return FolderId; + } + + public async Task Dispose(IBoxClient client) + { + await client.FoldersManager.DeleteAsync(FolderId); + + await client.FoldersManager.PurgeTrashedFolderAsync(FolderId); + } + } +} +``` + +The Execute command will be called when the command is executed, and Dispose when the test is terminated or an exception is thrown. As you can see, dispose or execute command could consist of multiple API calls. + +`CommandAccessLevel` indicates which BoxClient should be used for the test (managed or service account). Depends on what you may need and the enterprise access (e.g., to create a MetadataTemplate). + +`CommandScope` indicates when dispose will be called (test, class, assembly). You can usually keep this as `CommandScope.Test` for single test setup commands. + +Commands are usually wrapped in helper methods that look like this + +```c# +public static async Task CreateFolder(string parentId = "0", CommandScope commandScope = CommandScope.Test, CommandAccessLevel accessLevel = CommandAccessLevel.User) +{ + var createFolderCommand = new CreateFolderCommand(GetUniqueName("folder"), parentId, commandScope, accessLevel); + await ExecuteCommand(createFolderCommand); + return createFolderCommand.Folder; +} +``` + +You can then simply call this command in your test as follows + +```c# +[TestMethod] +public async Task GetWatermarkAsync_ForExistingFolder_ShouldCorrectlyApplyWatermarkOnFolder() +{ + var folder = await CreateFolder(FolderId); + await UserClient.FoldersManager.ApplyWatermarkAsync(folder.Id); + + var watermark = await UserClient.FoldersManager.GetWatermarkAsync(folder.Id); + + Assert.IsNotNull(watermark); +} +``` + +As you can see, since this test does not test folder creation, so command logic is used. Try using or adding commands like this to simplify and reuse the test setup. This makes the tests more readable, easier to maintain, and ensures that the test account is in the same state after and before running all the tests. \ No newline at end of file From 6c3f41063b7e522ae5ab4a90621276fc893e06a1 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 12:17:33 +0100 Subject: [PATCH 05/17] add retry logic --- .../BoxEventsManagerIntegrationTest.cs | 25 +++++++++++-------- .../BoxFilesManagerIntegrationTest.cs | 9 ++++--- .../Configuration/IntegrationTestBase.cs | 23 +++++++++++++++++ 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Box.V2.Test.Integration/BoxEventsManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxEventsManagerIntegrationTest.cs index 4960272c5..4c2bb5f37 100644 --- a/Box.V2.Test.Integration/BoxEventsManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxEventsManagerIntegrationTest.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -16,18 +17,20 @@ public async Task EnterpriseEventsStreamingAsync_ForNewFile_ShouldReturnUploadFi { var uploadedFile = await CreateSmallFile(FolderId); - var events = await AdminClient.EventsManager.EnterpriseEventsStreamingAsync(); - BoxEnterpriseEvent uploadedFileEvent = null; - while (events.ChunkSize == 500 || uploadedFileEvent == null) + await Retry(async () => { - events = await AdminClient.EventsManager.EnterpriseEventsStreamingAsync(500, events.NextStreamPosition, new List() { "UPLOAD" }); - uploadedFileEvent = events.Entries.FirstOrDefault(x => x.Source?.Id == uploadedFile.Id); - } - - Assert.IsNotNull(uploadedFileEvent); - Assert.AreEqual("UPLOAD", uploadedFileEvent.EventType); - Assert.AreEqual(uploadedFile.Id, uploadedFileEvent.Source.Id); - Assert.AreEqual("file", uploadedFileEvent.Source.Type); + var events = await AdminClient.EventsManager.EnterpriseEventsStreamingAsync(); + BoxEnterpriseEvent uploadedFileEvent = null; + while (events.ChunkSize == 500 || uploadedFileEvent == null) + { + events = await AdminClient.EventsManager.EnterpriseEventsStreamingAsync(500, events.NextStreamPosition, new List() { "UPLOAD" }); + uploadedFileEvent = events.Entries.FirstOrDefault(x => x.Source?.Id == uploadedFile.Id); + } + Assert.IsNotNull(uploadedFileEvent); + Assert.AreEqual("UPLOAD", uploadedFileEvent.EventType); + Assert.AreEqual(uploadedFile.Id, uploadedFileEvent.Source.Id); + Assert.AreEqual("file", uploadedFileEvent.Source.Type); + }); } } } diff --git a/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs index 99972e32d..529dab9bf 100644 --- a/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs @@ -169,11 +169,14 @@ public async Task UpdateFileInformation_ForNewDispositionDate_ShouldBeAbleToUpda DispositionAt = newDispositionDate }; - await AdminClient.FilesManager.UpdateInformationAsync(boxFileRequest); + await Retry(async () => + { + await AdminClient.FilesManager.UpdateInformationAsync(boxFileRequest); - var response = await AdminClient.FilesManager.GetInformationAsync(uploadedFile.Id, new List() { "disposition_at" }); + var response = await AdminClient.FilesManager.GetInformationAsync(uploadedFile.Id, new List() { "disposition_at" }); - Assert.IsTrue(newDispositionDate.IsEqualUpToSeconds(response.DispositionAt.Value)); + Assert.IsTrue(newDispositionDate.IsEqualUpToSeconds(response.DispositionAt.Value)); + }); } [TestMethod] diff --git a/Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs b/Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs index e79501dc4..914bd5eda 100644 --- a/Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs +++ b/Box.V2.Test.Integration/Configuration/IntegrationTestBase.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Text.RegularExpressions; +using System.Threading; using System.Threading.Tasks; using Box.V2.Config; using Box.V2.JWTAuth; @@ -330,5 +331,27 @@ public static async Task AddCollaborationE await ExecuteCommand(addCollaborationExemptCommand); return addCollaborationExemptCommand.WhitelistTargetEntry; } + + public static async Task Retry(Func action, int retries = 3, int sleep = 1000) + { + var retryCount = 0; + while (retryCount < retries) + { + try + { + await action(); + break; + } + catch (Exception) { } + + Thread.Sleep(sleep); + retryCount++; + } + + if (retryCount >= retries) + { + Assert.Fail("Retries limit exceeded"); + } + } } } From cd2230d08d8aaf54093ab0fea68e36b3da408317 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 12:31:49 +0100 Subject: [PATCH 06/17] update packages increate timeout on disposition_at test --- .../Box.V2.Test.Integration.csproj | 11 +++++++---- .../BoxFilesManagerIntegrationTest.cs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj index 658406ca7..41e914137 100644 --- a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj +++ b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj @@ -9,10 +9,13 @@ - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs index 529dab9bf..7a429c67c 100644 --- a/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs @@ -176,7 +176,7 @@ await Retry(async () => var response = await AdminClient.FilesManager.GetInformationAsync(uploadedFile.Id, new List() { "disposition_at" }); Assert.IsTrue(newDispositionDate.IsEqualUpToSeconds(response.DispositionAt.Value)); - }); + }, 5, 5000); } [TestMethod] From f4973d4fad8820d92bbf2b99f2869bb305e241a7 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 12:37:42 +0100 Subject: [PATCH 07/17] add setup dotnet --- .github/workflows/integration_tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index d336d74d1..1810cec44 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -15,6 +15,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '2.0.x' - name: Test env: INTEGRATION_TESTING_CONFIG: ${{ secrets.INTEGRATION_TESTING_CONFIG }} From 1d4a70e8483a1472452a8c1767cb135f434aa78e Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 12:41:53 +0100 Subject: [PATCH 08/17] remove coverlet --- Box.V2.Test.Integration/Box.V2.Test.Integration.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj index 41e914137..7cf8658cc 100644 --- a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj +++ b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj @@ -12,10 +12,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - From 2f55cadbb0bb7d1b3e7158767d16cce0c150abba Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 12:48:02 +0100 Subject: [PATCH 09/17] bump dotnet version --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 1810cec44..8fc479a71 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -18,7 +18,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: '2.0.x' + dotnet-version: '6.0.x' - name: Test env: INTEGRATION_TESTING_CONFIG: ${{ secrets.INTEGRATION_TESTING_CONFIG }} From 418b26e25f000fb36459b0a0ff1987fb32288967 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 12:58:44 +0100 Subject: [PATCH 10/17] add platform target x64 --- Box.V2.Test.Integration/Box.V2.Test.Integration.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj index 7cf8658cc..8722e58c6 100644 --- a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj +++ b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj @@ -5,6 +5,7 @@ false false + x64 From 9ef6c33ff7666fad20cf94aca37d8fbeacd38df2 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 13:06:01 +0100 Subject: [PATCH 11/17] increase logs verbosity --- .github/workflows/integration_tests.yml | 2 +- Box.V2.Test.Integration/Box.V2.Test.Integration.csproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 8fc479a71..63d44e7ed 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -22,4 +22,4 @@ jobs: - name: Test env: INTEGRATION_TESTING_CONFIG: ${{ secrets.INTEGRATION_TESTING_CONFIG }} - run: dotnet test .\Box.V2.Test.Integration -f netcoreapp2.0 \ No newline at end of file + run: dotnet test .\Box.V2.Test.Integration -f netcoreapp2.0 -v diagnostic \ No newline at end of file diff --git a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj index 8722e58c6..7cf8658cc 100644 --- a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj +++ b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj @@ -5,7 +5,6 @@ false false - x64 From aa66d061329476455d5e3e2d20bc970cd5017e0a Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 13:14:22 +0100 Subject: [PATCH 12/17] remove target --- Box.V2.Test.Integration/Box.V2.Test.Integration.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj index 7cf8658cc..0cfce0541 100644 --- a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj +++ b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0;net45 + netcoreapp2.0 false false From 1971d585aeda4e1fa602669f52f542adc1ea8491 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 13:22:32 +0100 Subject: [PATCH 13/17] downgrade net.test.sdk --- .github/workflows/integration_tests.yml | 2 +- Box.V2.Test.Integration/Box.V2.Test.Integration.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 63d44e7ed..8fc479a71 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -22,4 +22,4 @@ jobs: - name: Test env: INTEGRATION_TESTING_CONFIG: ${{ secrets.INTEGRATION_TESTING_CONFIG }} - run: dotnet test .\Box.V2.Test.Integration -f netcoreapp2.0 -v diagnostic \ No newline at end of file + run: dotnet test .\Box.V2.Test.Integration -f netcoreapp2.0 \ No newline at end of file diff --git a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj index 0cfce0541..4d8fad3c4 100644 --- a/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj +++ b/Box.V2.Test.Integration/Box.V2.Test.Integration.csproj @@ -1,7 +1,7 @@ - netcoreapp2.0 + netcoreapp2.0;net45 false false @@ -9,7 +9,7 @@ - + From 28623946a55c4f39d17788a923c7995aae2528b7 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 13:42:16 +0100 Subject: [PATCH 14/17] revert to .net 5.0 --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 8fc479a71..9bb4a7dcc 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -18,7 +18,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '5.0.x' - name: Test env: INTEGRATION_TESTING_CONFIG: ${{ secrets.INTEGRATION_TESTING_CONFIG }} From 143bd43486516f3e41a0f2e2b89d867e0bff20d2 Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 13:47:36 +0100 Subject: [PATCH 15/17] revert to .net 2.0 --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 9bb4a7dcc..289d051a0 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -18,7 +18,7 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' + dotnet-version: '2.0.0' - name: Test env: INTEGRATION_TESTING_CONFIG: ${{ secrets.INTEGRATION_TESTING_CONFIG }} From 1f72674b450b08c71d688854d83b4648a229ef0d Mon Sep 17 00:00:00 2001 From: mwoda Date: Thu, 17 Feb 2022 13:56:10 +0100 Subject: [PATCH 16/17] add recursive deletion to folder commands --- .../Commands/CleanupCommands/DeleteFolderCommand.cs | 2 +- .../Commands/DisposableCommands/CreateFolderCommand.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs index e2fbac525..825c990e1 100644 --- a/Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/CleanupCommands/DeleteFolderCommand.cs @@ -13,7 +13,7 @@ public DeleteFolderCommand(string folderId, CommandScope scope = CommandScope.Te public async Task Execute(IBoxClient client) { - await client.FoldersManager.DeleteAsync(_folderId); + await client.FoldersManager.DeleteAsync(_folderId, true); await client.FoldersManager.PurgeTrashedFolderAsync(_folderId); } diff --git a/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs index 5d2b7a865..15b4eaaca 100644 --- a/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs +++ b/Box.V2.Test.Integration/Configuration/Commands/DisposableCommands/CreateFolderCommand.cs @@ -34,7 +34,7 @@ public async Task Execute(IBoxClient client) public async Task Dispose(IBoxClient client) { - await client.FoldersManager.DeleteAsync(FolderId); + await client.FoldersManager.DeleteAsync(FolderId, true); await client.FoldersManager.PurgeTrashedFolderAsync(FolderId); } From e744484918c3ed51f2f6c281075bab9b855f8606 Mon Sep 17 00:00:00 2001 From: mwoda Date: Fri, 18 Feb 2022 10:53:36 +0100 Subject: [PATCH 17/17] fix tests after review --- Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs | 2 +- Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs | 4 +++- Box.V2.Test.Integration/BoxWebLinkManagerIntegrationTest.cs | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs index 7a429c67c..76777c661 100644 --- a/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxFilesManagerIntegrationTest.cs @@ -192,7 +192,7 @@ public async Task DownloadStreamAsync_ForTimeoutShorterThanDownloadTime_ShouldAb [TestMethod] public async Task UploadBigFileInSession_ShouldUploadTheFile_OnlyIfCommitIsCalled() { - long fileSize = 50000000; + long fileSize = 20000000; MemoryStream fileInMemoryStream = CreateFileInMemoryStream(fileSize); var remoteFileName = GetUniqueName("UploadSession"); diff --git a/Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs index 488e2b148..3b29d9788 100644 --- a/Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxFolderManagerIntegrationTest.cs @@ -195,7 +195,9 @@ public async Task RemoveWatermarkAsync_ForExistingFolder_ShouldCorrectlyRemoveWa var result = await UserClient.FoldersManager.RemoveWatermarkAsync(folder.Id); - Assert.IsTrue(result); + var fieldList = new List(new string[] { "watermark_info" }); + var folderInfo = await UserClient.FoldersManager.GetInformationAsync(folder.Id, fieldList); + Assert.IsFalse(folderInfo.WatermarkInfo.IsWatermarked); } } } diff --git a/Box.V2.Test.Integration/BoxWebLinkManagerIntegrationTest.cs b/Box.V2.Test.Integration/BoxWebLinkManagerIntegrationTest.cs index 989d506d8..80c4c8e19 100644 --- a/Box.V2.Test.Integration/BoxWebLinkManagerIntegrationTest.cs +++ b/Box.V2.Test.Integration/BoxWebLinkManagerIntegrationTest.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Box.V2.Exceptions; using Box.V2.Models; using Box.V2.Test.Integration.Configuration; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -49,7 +50,7 @@ public async Task UpdateWebLinkAsync_ForExistingWebLink_ShouldUpdateWebLink() } [TestMethod] - public async Task DeleteWebLinkAsync_ForExistingWebLink_ShouldDeleteWebLink() + public async Task DeleteWebLinkAsync_ForExistingWebLink_ShouldDeleteWebLinkAndExceptionShouldBeThrown() { var url = new Uri("http://www.box.com"); const string Description = "A weblink to Box.com"; @@ -59,7 +60,7 @@ public async Task DeleteWebLinkAsync_ForExistingWebLink_ShouldDeleteWebLink() var result = await UserClient.WebLinksManager.DeleteWebLinkAsync(weblink.Id); - Assert.IsTrue(result); + await Assert.ThrowsExceptionAsync(async () => { _ = await UserClient.WebLinksManager.GetWebLinkAsync(weblink.Id); }); } } }