trustedHeader.js 675 B

1234567891011121314151617181920212223242526272829303132
  1. import { expect } from 'chai'
  2. describe('config: trustedHeader', function () {
  3. before(async function () {
  4. await runner.start('trustedHeader')
  5. })
  6. after(async () => {
  7. await runner.stop()
  8. })
  9. it('req with X-User', async () => {
  10. const req = await fetch(runner.baseUrl() + '/api/WhoAmI', {
  11. headers: {
  12. "X-User": "fred",
  13. }
  14. })
  15. if (!req.ok) {
  16. console.log(req)
  17. }
  18. expect(req.ok, 'WhoAmI Request is ' + req.status).to.be.true
  19. const json = await req.json()
  20. expect(json).to.not.be.null
  21. expect(json).to.have.own.property('authenticatedUser')
  22. expect(json['authenticatedUser']).to.be.equal('fred')
  23. })
  24. })