-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove redundant parenthesis and use async * Fix typo * Fix private naming convention * Fix HasProjectPermission mock type signature * Make RoundTripObj immutable * Remove extra parens and reduce nesting * More refactor * Use ??= operator to simplify expression * Remove redundant else blocks * Make PasswordResetData attributes readonly * Make EmailInviteData immutable * Remove null check that cannot happen * Properly sanitize filenames in Audio Controller * Add unit tests for SanitizeId * Add switch expression * Allow ( ) , and space file name characters * Fix LGTM issue
- Loading branch information
1 parent
9a28ce2
commit aa6cfa2
Showing
20 changed files
with
228 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
|
||
using BackendFramework.Helper; | ||
|
||
namespace Backend.Tests.Helper | ||
{ | ||
public class SanitizationTests | ||
{ | ||
private static List<string> _validIds = new List<string> | ||
{ | ||
"a", | ||
"1", | ||
"a-5", | ||
}; | ||
|
||
[TestCaseSource(nameof(_validIds))] | ||
public void TestValidIds(string id) | ||
{ | ||
Assert.That(Sanitization.SanitizeId(id)); | ||
} | ||
|
||
private static List<string> _invalidIds = new List<string> | ||
{ | ||
"_", | ||
"a_1", | ||
".", | ||
"a.1", | ||
"/", | ||
"\\", | ||
"../a", | ||
"..\\a", | ||
"../1", | ||
"..\\1", | ||
"!", | ||
"@", | ||
"#", | ||
"$", | ||
"%", | ||
"^", | ||
"&", | ||
"*", | ||
"+", | ||
"<", | ||
">", | ||
":", | ||
"|", | ||
"?" | ||
}; | ||
[TestCaseSource(nameof(_invalidIds))] | ||
public void TestInvalidIds(string id) | ||
{ | ||
Assert.False(Sanitization.SanitizeId(id)); | ||
} | ||
|
||
private static List<string> _validFileNames = new List<string> | ||
{ | ||
"a", | ||
"1", | ||
"ab555.webm", | ||
"a-5.webm", | ||
"a-5.jpg", | ||
"a-5.png", | ||
"a_5.png", | ||
"a-5.png", | ||
"a(5).png", | ||
"a 5.png", | ||
"a,5.png" | ||
}; | ||
|
||
[TestCaseSource(nameof(_validFileNames))] | ||
public void TestValidFileNames(string fileName) | ||
{ | ||
Assert.That(Sanitization.SanitizeFileName(fileName)); | ||
} | ||
|
||
private static List<string> _invalidFileNames = new List<string> | ||
{ | ||
"/", | ||
"\\", | ||
"../a", | ||
"..\\a", | ||
"../1", | ||
"..\\1", | ||
"!", | ||
"@", | ||
"#", | ||
"$", | ||
"%", | ||
"^", | ||
"&", | ||
"*", | ||
"+", | ||
"<", | ||
">", | ||
":", | ||
"|", | ||
"?" | ||
}; | ||
[TestCaseSource(nameof(_invalidFileNames))] | ||
public void TestInvalidFileNames(string fileName) | ||
{ | ||
Assert.False(Sanitization.SanitizeFileName(fileName)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.