apiauth_test.go 425 B

1234567891011121314151617181920
  1. package apiauth
  2. import (
  3. "net/url"
  4. "testing"
  5. )
  6. func TestSignature(t *testing.T) {
  7. appsecret := "beego secret"
  8. method := "GET"
  9. RequestURL := "http://localhost/test/url"
  10. params := make(url.Values)
  11. params.Add("arg1", "hello")
  12. params.Add("arg2", "beego")
  13. signature := "mFdpvLh48ca4mDVEItE9++AKKQ/IVca7O/ZyyB8hR58="
  14. if Signature(appsecret, method, params, RequestURL) != signature {
  15. t.Error("Signature error")
  16. }
  17. }