public void DeserializeRawContent_Success() { var rawContent = "{\"Name\":\"z3T3j3ZDSFLM6DVc5l7s5Q==\",\"Files\":[\"LwhnBoFuFhXYPwNPzW5Vmg==\"],\"Folders\":[]}"; var encryptedZipArchiveHandler = new EncryptedZipArchiveHandler(MockAesEncryptionHelper.Object); ZipArchiveEntryItem deserializedContent = encryptedZipArchiveHandler.DeserializeRawContent(rawContent); deserializedContent.Should().NotBeNull(); deserializedContent.Name.Should().NotBeNull(); }
public void SaveRawContent_Failed_With_NonDeserializedStatus() { var rawContent = "{\"Name\":\"Name\",\"Files\":[\"Sub file\"]}"; ZipArchiveEntryItem zipArchiveEntryItem = null; MockEncryptedZipArchiveHandler.Setup(x => x.DeserializeRawContent(It.IsAny <string>())).Returns(zipArchiveEntryItem); var storeManager = new StorageManager(MockEncryptedZipArchiveHandler.Object, MockZipArchiveDBContext.Object); var result = storeManager.Save(rawContent); result.IsSuccess.Should().BeFalse(); }
public void FormJSON_Success() { var zipFileProcessor = new ZipFileProcessor(MockAesEncryptionHelper.Object, MockZipArchivePathsResolver.Object, MockZipArchiveFactory.Object); var zipArchiveEntryItem = new ZipArchiveEntryItem { Name = "decrypted" }; zipArchiveEntryItem.Files = new List <string>() { "decrypted", "decrypted", "decrypted" }; var expected = JsonConvert.SerializeObject(zipArchiveEntryItem); var formJson = zipFileProcessor.FormJSON(zipArchiveEntryItem); Assert.Equal(expected, formJson); }
public void SaveRawContent_Success() { var deserializedExpected = new ZipArchiveEntryItem { Name = "Name" }; var rawContent = "{\"Name\":\"Name\"}"; MockEncryptedZipArchiveHandler.Setup(x => x.DeserializeRawContent(It.IsAny <string>())).Returns(deserializedExpected); var storeManager = new StorageManager(MockEncryptedZipArchiveHandler.Object, MockZipArchiveDBContext.Object); var result = storeManager.Save(rawContent); result.IsSuccess.Should().BeTrue(); MockZipArchiveDbSetMock.Verify(x => x.Add(It.IsAny <ZipArchive>()), Times.Once); MockZipArchiveDBContext.Verify(x => x.SaveChanges(), Times.Once); }
public void DecryptZipArchive_Success() { MockAesEncryptionHelper.Setup(x => x.Decrypt(It.IsAny <string>())).Returns("decrypted"); var zipArchiveEntryItem = new ZipArchiveEntryItem { Name = "encrypted" }; zipArchiveEntryItem.Files = new List <string>() { "encrypted", "encrypted", "encrypted" }; var subZipArchiveEntryItem = new ZipArchiveEntryItem { Name = "encrypted" }; subZipArchiveEntryItem.Files = new List <string>() { "encrypted", "encrypted", "encrypted" }; zipArchiveEntryItem.Folders = new List <ZipArchiveEntryItem> { subZipArchiveEntryItem }; var encryptedZipArchiveHandler = new EncryptedZipArchiveHandler(MockAesEncryptionHelper.Object); var decryptedPaths = encryptedZipArchiveHandler.DecryptZipArchive(zipArchiveEntryItem); decryptedPaths.Name.Should().Be("decrypted"); decryptedPaths.Files.First().Should().Be("decrypted"); decryptedPaths.Folders.First().Name.Should().Be("decrypted"); decryptedPaths.Folders.First().Files.First().Should().Be("decrypted"); }
public void EncryptPaths_Success() { MockAesEncryptionHelper.Setup(x => x.Encrypt(It.IsAny <string>())).Returns("encrypted"); var zipFileProcessor = new ZipFileProcessor(MockAesEncryptionHelper.Object, MockZipArchivePathsResolver.Object, MockZipArchiveFactory.Object); var zipArchiveEntryItem = new ZipArchiveEntryItem { Name = "decrypted" }; zipArchiveEntryItem.Files = new List <string>() { "decrypted", "decrypted", "decrypted" }; var subZipArchiveEntryItem = new ZipArchiveEntryItem { Name = "decrypted" }; subZipArchiveEntryItem.Files = new List <string>() { "decrypted", "decrypted", "decrypted" }; zipArchiveEntryItem.Folders = new List <ZipArchiveEntryItem> { subZipArchiveEntryItem }; var encryptedPaths = zipFileProcessor.EncryptPaths(zipArchiveEntryItem); encryptedPaths.Name.Should().Be("encrypted"); encryptedPaths.Files.First().Should().Be("encrypted"); encryptedPaths.Folders.First().Name.Should().Be("encrypted"); encryptedPaths.Folders.First().Files.First().Should().Be("encrypted"); }