trustedHeader.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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.skip('req with X-User', async () => {
  17. await getRootAndWait()
  18. // Use the Connect RPC client format
  19. const req = await fetch(runner.baseUrl() + '/api/Init', {
  20. method: 'POST',
  21. headers: {
  22. "X-User": "fred",
  23. "Content-Type": "application/json",
  24. },
  25. body: JSON.stringify({}),
  26. })
  27. console.log(`Final URL: ${req.url}, Status: ${req.status}`)
  28. if (!req.ok) {
  29. console.log('Request failed:', req.status, req.statusText)
  30. const text = await req.text()
  31. console.log('Response body:', text)
  32. }
  33. expect(req.ok, 'Init Request is ' + req.status).to.be.true
  34. const json = await req.json()
  35. expect(json).to.not.be.null
  36. expect(json).to.have.own.property('authenticatedUser')
  37. expect(json['authenticatedUser']).to.be.equal('fred')
  38. })
  39. })