205daea027
Moved api services. All validations are now in validator util and all upload functions are in upload util
32 lignes
923 o
Go
32 lignes
923 o
Go
package sanitize
|
|
|
|
import "testing"
|
|
|
|
func TestSafe(t *testing.T) {
|
|
safeString := map[string]string{
|
|
"'": "'",
|
|
"&": "&",
|
|
"http://exemple.com": "http://exemple.com",
|
|
}
|
|
for key, val := range safeString {
|
|
safe := Safe(key)
|
|
if string(safe) != val {
|
|
t.Errorf("Safe doesn't escape the right values, expected result %s, got %s", key, val)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSafeText(t *testing.T) {
|
|
safeString := map[string]string{
|
|
"'": "'",
|
|
"&": "&",
|
|
"http://exemple.com": "http://exemple.com",
|
|
"<em>test</em><script>lol();</script>": "<em>test</em><script>lol();</script>",
|
|
}
|
|
for key, val := range safeString {
|
|
safe := Safe(key)
|
|
if string(safe) != val {
|
|
t.Errorf("Safe doesn't escape the right values, expected result %s, got %s", key, val)
|
|
}
|
|
}
|
|
}
|