github.com/hoffie/larasync@v0.0.0-20151025221940-0384d2bddcef/api/common/signWin_test.go (about) 1 package common 2 3 import ( 4 "bufio" 5 "bytes" 6 "net/http" 7 8 . "gopkg.in/check.v1" 9 ) 10 11 // Tests a real world signature being sent by a windows client. 12 func (t *SignTests) TestWindowsRequest(c *C) { 13 windowsRequest := "PUT /repositories/test HTTP/1.1\r\nHost: 192.168.100.212:14124\r\nUser-Agent: Go 1.1 package http\r\nContent-Length: 58\r\nAuthorization: lara 5549dd45c22957284dd4e0435c521f8e232519af02644ae7fe1f42470ffa6cb2da7344b1f9fea17209766e03266827b644e06a1216d1c5684d22babfa5847c0b\r\nContent-Type: application/json\r\nDate: Sat, 17 Jan 2015 16:51:38 GMT\r\nAccept-Encoding: gzip\r\n\r\n{\"pub_key\":\"83bd+XpfKbkDPx3i6Cg5ClOjWPds0YwktsbdPg6FtAE=\"}" 14 windowsRequestBuffer := bytes.NewBuffer([]byte(windowsRequest)) 15 var err error 16 t.req, err = http.ReadRequest(bufio.NewReader(windowsRequestBuffer)) 17 c.Assert(err, IsNil) 18 19 adminPubkey, err = GetAdminSecretPubkey([]byte("test")) 20 if err != nil { 21 panic(err) 22 } 23 sigCheck := validateRequestSig(t.req, adminPubkey) 24 c.Assert(sigCheck, Equals, true) 25 }