Skip to content

Commit

Permalink
Add test to ensure cert bundle only gets loaded once
Browse files Browse the repository at this point in the history
  • Loading branch information
lsegal committed Mar 18, 2013
1 parent cfc4839 commit d72b80d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/node_http_client.spec.coffee
Expand Up @@ -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.