~jtv/gwacl/storage-tool-command-line

« back to all changes in this revision

Viewing changes to x509session_test.go

  • Committer: Tarmac
  • Author(s): Raphael Badin
  • Date: 2013-03-20 23:51:29 UTC
  • mfrom: (28.1.8 add-hosted-service)
  • Revision ID: tarmac-20130320235129-wayppufg6za20sln
[r=jtv][bug=][author=rvb] Add method to create a new hosted service.

Show diffs side-by-side

added added

removed removed

Lines of Context:
230
230
    subscriptionID := "subscriptionID"
231
231
    uri := "resource"
232
232
    requestBody := []byte("Request body")
 
233
    requestContentType := "bogusContentType"
233
234
    session, err := NewX509Session(subscriptionID, "cert.pem")
234
235
    c.Assert(err, IsNil)
235
236
    // Record incoming requests, and have them return a given reply.
241
242
    recordedRequests := make([]*X509Request, 0)
242
243
    rigRecordingDispatcher(&recordedRequests)
243
244
 
244
 
    receivedBody, err := session.post(uri, requestBody)
 
245
    receivedBody, err := session.post(uri, requestBody, requestContentType)
245
246
    c.Assert(err, IsNil)
246
247
 
247
248
    c.Assert(len(recordedRequests), Equals, 1)
248
249
    request := recordedRequests[0]
249
250
    c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri)
250
251
    c.Check(request.Method, Equals, "POST")
 
252
    c.Check(request.ContentType, Equals, requestContentType)
251
253
    c.Check(request.Payload, DeepEquals, requestBody)
252
254
    c.Check(receivedBody, DeepEquals, fixedResponse.Body)
253
255
}
257
259
    msg := "could not dispatch request"
258
260
    rigFailingDispatcher(fmt.Errorf(msg))
259
261
 
260
 
    body, err := session.post("/flop", []byte("body"))
 
262
    body, err := session.post("/flop", []byte("body"), "contentType")
261
263
    c.Assert(err, NotNil)
262
264
 
263
265
    c.Check(body, IsNil)
272
274
    }
273
275
    rigFixedResponseDispatcher(&fixedResponse)
274
276
 
275
 
    body, err := session.post("/fail", []byte("request body"))
 
277
    body, err := session.post("/fail", []byte("request body"), "contentType")
276
278
    c.Assert(err, NotNil)
277
279
 
278
280
    serverError := err.(*ServerError)