auth.js 440B

12345678910111213141516171819202122
  1. var Buffer = require('buffer').Buffer
  2. var test = require('tape')
  3. var http = require('../..')
  4. test('authentication', function (t) {
  5. http.get({
  6. path: '/auth',
  7. auth: 'TestUser:trustno1'
  8. }, function (res) {
  9. var buffers = []
  10. res.on('end', function () {
  11. t.ok(new Buffer('You\'re in!').equals(Buffer.concat(buffers)), 'authentication succeeded')
  12. t.end()
  13. })
  14. res.on('data', function (data) {
  15. buffers.push(data)
  16. })
  17. })
  18. })