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-rfc2617.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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('auth')
  12. describe('digest-fetch', function(){
  13. it('Test RFC2617', 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 RFC2617 with precomputed hash', function() {
  28. var client = new DigestFetch('test', DigestFetch.computeHash('test', 'Users', 'test'), { precomputedHash: true })
  29. chai.request(app).get('/auth').then(res => {
  30. expect(res).to.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(200)
  38. })
  39. })
  40. })
  41. it('Test RFC2617 with wrong credential', function() {
  42. var client = new DigestFetch('test', 'test-null')
  43. chai.request(app).get('/auth').then(res => {
  44. expect(res).to.have.status(401)
  45. client.lastAuth = res.res.headers['www-authenticate']
  46. })
  47. .then(() => {
  48. client.parseAuth(client.lastAuth)
  49. const auth = client.addAuth('/auth', { method: 'GET' }).headers.Authorization
  50. chai.request(app).get('/auth').set('Authorization', auth).then(res => {
  51. expect(res).to.have.status(401)
  52. })
  53. })
  54. })
  55. })