コード例 #1
0
        public void EmptyBodyDoesNotHangHandler()
        {
            var request = new WorkerRequest("", "filename=aaa.jpg", "");
            var context = new HttpContext(request);

            AjaxFileUploadHelper.Process(context);
        }
コード例 #2
0
        public void DoNotUseBufferlessInputStream()
        {
            var request = new WorkerRequest(testBody, testQuery, testContentType);
            var context = new HttpContext(request);

            Assert.DoesNotThrow(() => AjaxFileUploadHelper.Process(context));
        }
コード例 #3
0
        public void NotAllowedFileExtensionIsBlocked()
        {
            var request = new WorkerRequest("", "fileName=aaa.exe", "");
            var context = new HttpContext(request);

            Assert.Throws <Exception>(() => AjaxFileUploadHelper.Process(context));
        }
コード例 #4
0
        public void AllowedFileExtensionIsAccepted()
        {
            var request = new WorkerRequest(testBody, testQuery, testContentType);
            var context = new HttpContext(request);

            AjaxFileUploadHelper.Process(context);
            Assert.True(File.Exists(Path.Combine(_tempFolder, "E63F2078-D5C7-66FA-5CAD-02C169149BD5", "aaa.jpg.tmp")));
        }
コード例 #5
0
        public void AllowedFileExtensionIsAccepted()
        {
            var request = new WorkerRequest("------WebKitFormBoundaryCqenIHPHe1ZTCr0d\r\nContent-Disposition: form-data; name=\"act-file-data\"; filename=\"zero.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n\r\n------WebKitFormBoundaryCqenIHPHe1ZTCr0d--\r\n", "filename=aaa.jpg&fileId=E63F2078-D5C7-66FA-5CAD-02C169149BD5", "multipart/form-data; boundary=----WebKitFormBoundaryCqenIHPHe1ZTCr0d");
            var context = new HttpContext(request);

            AjaxFileUploadHelper.Process(context);
            Assert.True(File.Exists(Path.Combine(_tempFolder, "E63F2078-D5C7-66FA-5CAD-02C169149BD5", "aaa.jpg.tmp")));
        }
コード例 #6
0
        public void InvalidFilenameChars()
        {
            var request = new WorkerRequest(testBody, testQueryFilenameInvalidChars, testContentType);
            var context = new HttpContext(request);

            AjaxFileUploadHelper.Process(context);
            Assert.True(File.Exists(Path.Combine(_tempFolder, "E63F2078-D5C7-66FA-5CAD-02C169149BD5", "a-a-a.jpg.tmp")));
        }
コード例 #7
0
        public void UseBufferlessInputStream()
        {
            var request = new WorkerRequest(testBody, testQuery, testContentType);
            var context = new HttpContext(request);

            // read entity via InputStream
            // https://referencesource.microsoft.com/#System.Web/HttpRequest.cs,3231
            context.Request.InputStream.ReadByte();
            Assert.DoesNotThrow(() => AjaxFileUploadHelper.Process(context));
        }