public void EmptyBodyDoesNotHangHandler() { var request = new WorkerRequest("", "filename=aaa.jpg", ""); var context = new HttpContext(request); AjaxFileUploadHelper.Process(context); }
public void DoNotUseBufferlessInputStream() { var request = new WorkerRequest(testBody, testQuery, testContentType); var context = new HttpContext(request); Assert.DoesNotThrow(() => AjaxFileUploadHelper.Process(context)); }
public void NotAllowedFileExtensionIsBlocked() { var request = new WorkerRequest("", "fileName=aaa.exe", ""); var context = new HttpContext(request); Assert.Throws <Exception>(() => AjaxFileUploadHelper.Process(context)); }
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"))); }
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"))); }
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"))); }
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)); }