Permalink
Browse files

Add test to ensure cert bundle only gets loaded once

  • Loading branch information...
1 parent cfc4839 commit d72b80d574863223d0d5a73a0b05dca655dbcf68 @lsegal lsegal committed Mar 12, 2013
Showing with 12 additions and 3 deletions.
  1. +12 −3 test/node_http_client.spec.coffee
View
15 test/node_http_client.spec.coffee
@@ -18,12 +18,21 @@ describe 'AWS.NodeHttpClient', ->
http = new AWS.NodeHttpClient()
describe 'handleRequest', ->
+ it 'loads certificate bundle from disk in SSL request (once)', ->
+ readSpy = spyOn(AWS.util, 'readFileSync').andCallThrough()
+ done = false
+ req = new AWS.HttpRequest 'https://invalid'
+ runs -> http.handleRequest req, null, ->
+ done = true
+ expect(AWS.NodeHttpClient.sslAgent).not.toEqual(null)
+ expect(readSpy.callCount).toEqual(1)
+ waitsFor -> done
+
it 'emits error event', ->
done = false
- endpoint = new AWS.Endpoint('http://invalid')
- req = endpoint: endpoint
+ req = new AWS.HttpRequest 'http://invalid'
runs ->
- stream = http.handleRequest req, null, (err) ->
+ http.handleRequest req, null, (err) ->
expect(err.code).toEqual 'ENOTFOUND'
done = true
waitsFor -> done

0 comments on commit d72b80d

Please sign in to comment.