Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cypress-downloadfile does not respect HTTP_PROXY value set #37

Open
noopurmath3 opened this issue Dec 14, 2023 · 2 comments
Open

cypress-downloadfile does not respect HTTP_PROXY value set #37

noopurmath3 opened this issue Dec 14, 2023 · 2 comments

Comments

@noopurmath3
Copy link

Describe the bug
I am trying to use cypress-downloadfile to download a file on hitting a url. However, the url I am hitting is behind proxy, hence downloadfile is failing with 403 error. However, when I hit the same url that is behind proxy using cy.request it works as expected

To Reproduce
Steps to reproduce the behavior:

  1. Try to download a file that is behind proxy using cy.download file
  2. Even though HTTP_PROXY is set cy.download fails with. 403 error
  3. However, the same url works when used as cy.request()
  4. See stack trace:
cy.task('downloadFile') failed with the following error:
> request is not defined
at <unknown> (http://localhost:51356/__cypress/runner/cypress_runner.js:135703:70)
    at tryCatcher (http://localhost:51356/__cypress/runner/cypress_runner.js:1807:23)
    at Promise._settlePromiseFromHandler (http://localhost:51356/__cypress/runner/cypress_runner.js:1519:31)
    at Promise._settlePromise (http://localhost:51356/__cypress/runner/cypress_runner.js:1576:18)
    at Promise._settlePromise0 (http://localhost:51356/__cypress/runner/cypress_runner.js:1621:10)
    at Promise._settlePromises (http://localhost:51356/__cypress/runner/cypress_runner.js:1697:18)
    at <unknown> (http://localhost:51356/__cypress/runner/cypress_runner.js:2392:25)
From previous event:
    at Promise.longStackTracesCaptureStackTrace [as _captureStackTrace] (http://localhost:51356/__cypress/runner/cypress_runner.js:3486:19)
    at Promise._then (http://localhost:51356/__cypress/runner/cypress_runner.js:1239:17)
    at Promise._passThrough (http://localhost:51356/__cypress/runner/cypress_runner.js:4110:17)
    at Promise.lastly.Promise.finally (http://localhost:51356/__cypress/runner/cypress_runner.js:4119:17)
    at Object.onRunnableRun (http://localhost:51356/__cypress/runner/cypress_runner.js:163777:53)
    at $Cypress.action (http://localhost:51356/__cypress/runner/cypress_runner.js:41042:28)
    at Runnable.run (http://localhost:51356/__cypress/runner/cypress_runner.js:146089:13)
    at Runner.runTest (http://localhost:51356/__cypress/runner/cypress_runner.js:156307:10)
    at <unknown> (http://localhost:51356/__cypress/runner/cypress_runner.js:156433:12)
    at next (http://localhost:51356/__cypress/runner/cypress_runner.js:156216:14)
    at <unknown> (http://localhost:51356/__cypress/runner/cypress_runner.js:156226:7)
    at next (http://localhost:51356/__cypress/runner/cypress_runner.js:156128:14)
    at <unknown> (http://localhost:51356/__cypress/runner/cypress_runner.js:156194:5)
    at timeslice (http://localhost:51356/__cypress/runner/cypress_runner.js:146429:27)
From Your Spec Code:
    at Context.eval ([webpack:///./node_modules/cypress-downloadfile/lib/downloadFileCommand.js:5](http://localhost:51356/__/#))
From Node.js Internals:
  ReferenceError: request is not defined
      at downloadFile (/Users/nmath/Content_Gateway/node_modules/cypress-downloadfile/lib/addPlugin.js:21:3)
      at invoke (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:248:16)
      at <unknown> (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:59:14)
      at tryCatcher (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)
      at Function.Promise.attempt.Promise.try (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29)
      at Object.wrapChildPromise (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:58:23)
      at RunPlugins.taskExecute (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:254:10)
      at RunPlugins.execute (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:166:21)
      at EventEmitter.<anonymous> (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:56:12)
      at EventEmitter.emit (events.js:400:28)
      at process.<anonymous> (/Users/nmath/Library/Caches/Cypress/13.6.1/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
      at process.emit (events.js:400:28)
      at emit (internal/child_process.js:912:12)
      at processTicksAndRejections (internal/process/task_queues.js:83:21)

Expected behavior
cypress-downloadfile should request the proxy set

Screenshots
Screenshot 2023-12-14 at 6 24 32 PM

Desktop:

  • Cypress [v13.6.1]
  • OS: [macOS 14.1.2 ]
  • Browser [chrome]
  • Version [120]
@Xvier
Copy link
Owner

Xvier commented Dec 18, 2023

Hi @noopurmath3, thank you for raising this. I will have to do some research to have a nice working solution for you.

@Xvier
Copy link
Owner

Xvier commented Jan 22, 2024

I think i found a solution to your problem and hope to have it completed by end of the week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants