mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-30 00:38:38 +00:00
Add security & testing for file uploads
This commit is contained in:
parent
d1093fdf8f
commit
e0d14232d8
4 changed files with 92 additions and 2 deletions
44
ProjectLighthouse.Tests/Tests/UploadTests.cs
Normal file
44
ProjectLighthouse.Tests/Tests/UploadTests.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace ProjectLighthouse.Tests {
|
||||
public class UploadTests : LighthouseTest {
|
||||
public UploadTests() {
|
||||
string assetsDirectory = Path.Combine(Environment.CurrentDirectory, "r");
|
||||
if(Directory.Exists(assetsDirectory)) Directory.Delete(assetsDirectory, true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldNotAcceptScript() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/scriptTest", "ExampleFiles/TestScript.ff");
|
||||
Assert.False(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldNotAcceptFarc() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/farcTest", "ExampleFiles/TestFarc.farc");
|
||||
Assert.False(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldNotAcceptGarbage() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/garbageTest", "ExampleFiles/TestGarbage.bin");
|
||||
Assert.False(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldAcceptTexture() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/textureTest", "ExampleFiles/TestTexture.tex");
|
||||
Assert.True(response.IsSuccessStatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ShouldAcceptLevel() {
|
||||
HttpResponseMessage response = await UploadFileRequest("/LITTLEBIGPLANETPS3_XML/upload/levelTest", "ExampleFiles/TestLevel.lvl");
|
||||
Assert.True(response.IsSuccessStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue