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(new FileTypeDetectionResponse(FileType.Unknown)); HttpTest.ResponseQueue.Enqueue(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new ByteArrayContent(ExpectedDownloadFile) }); _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 }); FileAnalyserMock.Setup(s => s.GetReport( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(""); _result = ClassInTest.AnalyseFromUrl(new UrlRequest { InputGetUrl = _expectedInputUrl }); }
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 No_Engine_Actions_Are_Performed(string base64) { ClassInTest.DetermineFileTypeFromBase64(new Base64Request { Base64 = base64 }); GlasswallVersionServiceMock.VerifyNoOtherCalls(); FileTypeDetectorMock.VerifyNoOtherCalls(); }
public void OnetimeSetup() { CommonSetup(); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(new FileTypeDetectionResponse(FileType.Unknown)); _result = ClassInTest.RebuildFromFormFile(null, ValidFormFileMock.Object); }
public void OnetimeSetup() { CommonSetup(); GlasswallVersionServiceMock.Setup(s => s.GetVersion()) .Returns(Version); FileTypeDetectorMock.Setup(s => s.DetermineFileType(It.IsAny <byte[]>())) .Returns(new FileTypeDetectionResponse(FileType.Unknown)); _result = ClassInTest.RebuildFromBase64(new Base64Request { Base64 = "dGVzdA==" }); }
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)); FileAnalyserMock.Setup(s => s.GetReport( It.IsAny <ContentManagementFlags>(), It.IsAny <string>(), It.IsAny <byte[]>())) .Returns(DummyXml); _result = ClassInTest.AnalyseFromBase64(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 = ValidFileBytes }); _result = ClassInTest.RebuildFromFormFile(null, ValidFormFileMock.Object); }
public void FileTypeDetection_Is_Retrieved() { FileTypeDetectorMock.Verify(s => s.DetermineFileType(It.Is <byte[]>(x => x.SequenceEqual(ExpectedDownloadFile))), Times.Once); FileTypeDetectorMock.VerifyNoOtherCalls(); }
public void No_Engine_Actions_Are_Performed() { GlasswallVersionServiceMock.VerifyNoOtherCalls(); FileTypeDetectorMock.VerifyNoOtherCalls(); FileProtectorMock.VerifyNoOtherCalls(); }