Skip to content

Instantly share code, notes, and snippets.

@SevereCloud
Last active March 30, 2020 05:56
Show Gist options
  • Save SevereCloud/69ae16d62c34ed1f54c7218244a727f8 to your computer and use it in GitHub Desktop.
Save SevereCloud/69ae16d62c34ed1f54c7218244a727f8 to your computer and use it in GitHub Desktop.
package main
import "testing"
func Test_isValid(t *testing.T) {
f := func(URL, clientSecret string, want, wantErr bool) {
t.Helper()
got, err := isValid(URL, clientSecret)
if (err != nil) != wantErr {
t.Errorf("isValid() error = %v, wantErr %v", err, wantErr)
return
}
if got != want {
t.Errorf("isValid() = %v, want %v", got, want)
}
}
f("http://[%10::1]", "", false, true)
f("https://example.com", "", false, true)
f("https://example.com?sign=abc", "", false, false)
f("https://example.com?q=abc", "", false, false)
f("https://example.com?sign=abc&%gh&%ij", "", false, true)
f(
"https://example.com/?vk_user_id=494075&vk_app_id=6736218&vk_is_app_user=1&vk_are_notifications_enabled=1&vk_language=ru&vk_access_token_settings=notify&vk_platform=android&sign=exTIBPYTrAKDTHLLm2AwJkmcVcvFCzQUNyoa6wAjvW6k",
"wvl68m4dR1UpLrVRli",
false,
false,
)
f(
"https://example.com/?vk_user_id=494075&vk_app_id=6736218&vk_is_app_user=1&vk_are_notifications_enabled=1&vk_language=ru&vk_access_token_settings=&vk_platform=android&sign=htQFduJpLxz7ribXRZpDFUH-XEUhC9rBPTJkjUFEkRA",
"wvl68m4dR1UpLrVRli",
true,
false,
)
}
@SevereCloud
Copy link
Author

@SenchoPens тут можно посмотреть

@SenchoPens
Copy link

@SevereCloud спасибо!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment