Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

digest-fetch-rfc2069.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. process.env.NO_DEPRECATION = 'digest-fetch';
  2. var after = require('after')
  3. var assert = require('assert')
  4. var DigestFetch = require('../')
  5. var factory = require('./test-server')
  6. var chai = require('chai')
  7. var expect = chai.expect
  8. var chaiHttp = require('chai-http')
  9. chai.use(chaiHttp)
  10. chai.should()
  11. var app = factory.getApp()
  12. describe('digest-fetch', function(){
  13. it('Test RFC2069', function() {
  14. var client = new DigestFetch('test', 'test')
  15. chai.request(app).get('/auth').then(res => {
  16. expect(res).to.have.status(401)
  17. client.lastAuth = res.res.headers['www-authenticate']
  18. })
  19. .then(() => {
  20. client.parseAuth(client.lastAuth)
  21. const auth = client.addAuth('/auth', { method: 'GET' }).headers.Authorization
  22. chai.request(app).get('/auth').set('Authorization', auth).then(res => {
  23. expect(res).to.have.status(200)
  24. })
  25. })
  26. })
  27. it('Test RFC2069 with wrong credential', function() {
  28. var client = new DigestFetch('test', 'test-null')
  29. chai.request(app).get('/auth').then(res => {
  30. res.should.have.status(401)
  31. client.lastAuth = res.res.headers['www-authenticate']
  32. })
  33. .then(() => {
  34. client.parseAuth(client.lastAuth)
  35. const auth = client.addAuth('/auth', { method: 'GET' }).headers.Authorization
  36. chai.request(app).get('/auth').set('Authorization', auth).then(res => {
  37. expect(res).to.have.status(401)
  38. })
  39. })
  40. })
  41. })