public void OnetimeSetup() { CommonSetup(); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(_expectedType = new FileTypeDetectionResponse(FileType.Bmp)); FileProtectorMock.Setup(s => s.GetProtectedFile( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(_expectedProtectResponse = new FileProtectResponse { Outcome = EngineOutcome.Error, ProtectedFile = null, ErrorMessage = "banana has been removed because monkey content is set to disallowed" }); _result = ClassInTest.RebuildFromBase64(new Base64Request { Base64 = "dGVzdA==" }); }
public void OnetimeSetup() { CommonSetup(); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(_expectedType = new FileTypeDetectionResponse(FileType.Bmp)); FileProtectorMock.Setup(s => s.GetProtectedFile( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(new FileProtectResponse { Outcome = EngineOutcome.Success, ProtectedFile = ExpectedDecoded }); _result = ClassInTest.RebuildFromBase64(new Base64Request { Base64 = "dGVzdA==" }); }
public void No_Engine_Actions_Are_Performed() { _result = ClassInTest.RebuildFromFormFile(null, InvalidFormFileMock.Object); GlasswallVersionServiceMock.VerifyNoOtherCalls(); FileTypeDetectorMock.VerifyNoOtherCalls(); FileProtectorMock.VerifyNoOtherCalls(); }
public void File_Is_Rebuilt() { FileProtectorMock.Verify( s => s.GetProtectedFile( It.Is <ContentManagementFlags>(x => x == Policy.DefaultContentManagementFlags), It.Is <string>(x => x == _expectedType.FileTypeName), It.Is <byte[]>(x => x.SequenceEqual(ExpectedDownloadFile))), Times.Once); FileProtectorMock.VerifyNoOtherCalls(); }
public void No_Engine_Actions_Are_Performed(string base64) { ClassInTest.RebuildFromBase64(new Base64Request { Base64 = base64 }); GlasswallVersionServiceMock.VerifyNoOtherCalls(); FileTypeDetectorMock.VerifyNoOtherCalls(); FileProtectorMock.VerifyNoOtherCalls(); }
public void OnetimeSetup() { CommonSetup(); _expectedInputUrl = new Uri("https://www.myfileserver.com/myfile.png"); _expectedOutputUrl = new Uri("https://www.s3bucket.com/buckets/rebuilt/myfile.png"); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(_expectedType = new FileTypeDetectionResponse(FileType.Bmp)); HttpTest.ResponseQueue.Enqueue(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new ByteArrayContent(ExpectedDownloadFile) }); HttpTest.ResponseQueue.Enqueue(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Headers = { ETag = _expectedEtag = new EntityTagHeaderValue("\"Some Tag\"", false) } }); FileProtectorMock.Setup(s => s.GetProtectedFile( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(new FileProtectResponse { Outcome = EngineOutcome.Success, ProtectedFile = ExpectedUploadFile }); _result = ClassInTest.RebuildUrlToUrl(new UrlToUrlRequest { InputGetUrl = _expectedInputUrl, OutputPutUrl = _expectedOutputUrl }); }
public void OnetimeSetup() { CommonSetup(); _expectedInputUrl = new Uri("https://www.myfileserver.com/myfile.png"); _expectedOutputUrl = new Uri("https://www.s3bucket.com/buckets/rebuilt/myfile.png"); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(_expectedType = new FileTypeDetectionResponse(FileType.Bmp)); HttpTest.ResponseQueue.Enqueue(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new ByteArrayContent(ExpectedDownloadFile) }); HttpTest.ResponseQueue.Enqueue(new HttpResponseMessage { StatusCode = HttpStatusCode.OK }); FileProtectorMock.Setup(s => s.GetProtectedFile( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(_expectedProtectResponse = new FileProtectResponse { Outcome = EngineOutcome.Error, ProtectedFile = null, ErrorMessage = "banana has been removed because monkey content is set to disallowed" }); _result = ClassInTest.RebuildUrlToUrl(new UrlToUrlRequest { InputGetUrl = _expectedInputUrl, OutputPutUrl = _expectedOutputUrl }); }
public void OnetimeSetup() { CommonSetup(); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(_expectedType = new FileTypeDetectionResponse(FileType.Bmp)); FileProtectorMock.Setup(s => s.GetProtectedFile( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(new FileProtectResponse { Outcome = EngineOutcome.Success, ProtectedFile = ValidFileBytes }); _result = ClassInTest.RebuildFromFormFile(null, ValidFormFileMock.Object); }
public void File_Is_Not_Rebuilt() { FileProtectorMock.VerifyNoOtherCalls(); }
public void No_Engine_Actions_Are_Performed() { GlasswallVersionServiceMock.VerifyNoOtherCalls(); FileTypeDetectorMock.VerifyNoOtherCalls(); FileProtectorMock.VerifyNoOtherCalls(); }