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

Seems to hide insecure certificate exceptions/helpful errors? #3

Open
literallyMello opened this issue Jan 4, 2023 · 4 comments
Open

Comments

@literallyMello
Copy link

When testing internal APIs with insecure/untrusted certificates I was getting error

  ✖ NightwatchAssertError
   Cannot read properties of undefined (reading 'status')

when running a test similar to

await supertest
      .request("https://internal-insecurely-signed-app.url.int")
      .get("/_manage/health")
      .expect(200);

until I thought to try using the .disableTLSCerts() option (the API under test int his scenario does not use a securely-signed certificate)

await supertest
      .request("https://internal-insecurely-signed-app.url.int")
      .get("/_manage/health")
      .disableTLSCerts()
      .expect(200);

Unless I'm mistaken I recall SuperTest providing an error in these scenarios that would more easily let the user realize it didn't connect because of an insecure certificate. Is the plugin hiding the exception?

@beatfactor
Copy link
Member

No, but what does the superset. disableTLSCerts() do?

@reallymello
Copy link
Contributor

It stops supertest from checking the validity of the certificates so we you are using self-signed for local dev or hitting environments with otherwise non-legit certificates (like test environments). Without it supertest throws errors like Error: self signed certificate (see for example ladjs/supertest#737)

@beatfactor
Copy link
Member

Ok, so the issue is that those errors aren't reported correctly, like the assertion error you mentioned? Can you post a stack trace?

@reallymello
Copy link
Contributor

  Running Example Test:

───────────────────────────────────────────────────────────────────────────────────────────────────

→ Running [beforeEach]:

→ Completed [beforeEach].

 → Running command: request ('https://redactedUrlHere')

  Error

   uncaughtException: Cannot read properties of undefined (reading 'request')

TypeError: Cannot read properties of undefined (reading 'request')

    at Test.<anonymous> (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/@nightwatch/apitesting/nightwatch/commands/supertest/request.js:33:71)

    at Test.assert (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/supertest/lib/test.js:172:8)

    at localAssert (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/supertest/lib/test.js:120:14)

    at fn (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/supertest/lib/test.js:125:7)

    at Test.callback (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/superagent/src/node/index.js:924:3)

    at ClientRequest.<anonymous> (/Users/davidme/projects/nightwatch-framework-template-ts/node_modules/superagent/src/node/index.js:836:10)

    at ClientRequest.emit (node:events:513:28)

    at ClientRequest.emit (node:domain:489:12)

    at TLSSocket.socketErrorListener (node:_http_client:481:9)

    at TLSSocket.emit (node:events:513:28)

 

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

 

  ️TEST FAILURE (5.891s):

   - 1 error during execution;

   - 0 tests failed;

   - 0/NA tests passed

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

3 participants