Browse Source

build signature and append to existing url

master
Patrick Peng Sun 8 years ago
parent
commit
53472fa711
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      server_test.go

+ 10
- 2
server_test.go View File

return req return req
} }




func buildReqCommonHeader(r *http.Request) { func buildReqCommonHeader(r *http.Request) {
// //
// example request // example request
r.Header.Set("X-Forwarded-Server", "wechat.hitxy.org.au") r.Header.Set("X-Forwarded-Server", "wechat.hitxy.org.au")


} }

func TestBuildQueryString(t *testing.T) {
url := "http://www.hitxy.org.au/crmcache?a=abc"
newURL := buildSignatureAppend2Url(url, IntraAPIConfig.CRMSecrete)
//log.Println(newURL)
AssertEqual(t, url != newURL, true, "URL append signature should be correct")
req, err := http.NewRequest("GET", newURL, nil)
AssertEqual(t, err, nil, "pase new URL should be correct")
AssertEqual(t, checkSignatureByToken(req, IntraAPIConfig.CRMSecrete), true, "check signature shold be correct")
}

Loading…
Cancel
Save