trustedHeader.js 877 B

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