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

BasicAuthentication is not working when Username or Password contains URL special characters #615

Closed
danielang-ortec opened this issue May 17, 2024 · 0 comments · Fixed by #616

Comments

@danielang-ortec
Copy link
Contributor

Describe the bug
When using the Basic Authentication method of wdi5 with usernames or passwords that contain special URL characters like # or @ the program stops with the exception: TypeError: Invalid URL (Stacktrace attached).

To Reproduce
Steps to reproduce the behavior:

  1. Provide credentials with URL special characters in the .envfile
  2. Start wdi5
  3. 🧨

Expected behavior
Currently the content of the .env file simply put inside the URL. But instead it should be encoded before used in an URL.
The following snippet in BasicAuthenticator.ts:23 resolves the issue:

const username = encodeURIComponent(this.getUsername());
const password = encodeURIComponent(this.getPassword());
const basicAuthUrls = matches[1] + username + ":" + password + "@" + matches[2];

Logs/Console Output

[0-0] RUNNING in chrome - file:///C:/development/repositories/.../webapp/test/e2e/ResourceTypeListJourney.test.ts
[0-0] 2024-05-17T11:48:43.193Z ERROR @wdio/utils:shim: TypeError: Invalid URL
[0-0]     at new URL (node:internal/url:775:36)
[0-0]     at Browser.url (file:///C:/development/repositories/.../node_modules/webdriverio/build/commands/browser/url.js:43:17)
[0-0]     at Browser.wrapCommandFn (file:///C:/development/repositories/.../node_modules/@wdio/utils/build/shim.js:90:38)
[0-0]     at processTicksAndRejections (node:internal/process/task_queues:95:5)
[0-0]     at async BasicAuthenticator.basicAuthLogin (file:///C:/development/repositories/.../node_modules/wdio-ui5-service/src/lib/authentication/BasicAuthenticator.ts:32:6)
[0-0]     at async BasicAuthenticator.login (file:///C:/development/repositories/.../node_modules/wdio-ui5-service/src/lib/authentication/BasicAuthenticator.ts:15:9)
[0-0]     at async authenticate (file:///C:/development/repositories/.../node_modules/wdio-ui5-service/src/lib/wdi5-bridge.ts:183:13)       
[0-0]     at async Service.before (file:///C:/development/repositories/.../node_modules/wdio-ui5-service/src/service.ts:47:17)
[0-0]     at async Promise.all (index 0)
[0-0]     at async executeHooksWithArgs (file:///C:/development/repositories/.../node_modules/@wdio/utils/build/shim.js:68:20)
[0-0]     at async Runner.run (file:///C:/development/repositories/.../node_modules/@wdio/runner/build/index.js:99:9)

Runtime Env (please complete the following information):

  • wdi5/wdio-ui5-service-version: 2.0.8
  • UI5 version: 1.120.13
  • wdio-version (output of wdio --version): 20.11.0
  • node-version (output of node --version): [e.g. v17.3.0]
  • OS: Windows 10 x64
  • Browser + Version: Chrome 124.0.6367.208
danielang pushed a commit to danielang/wdi5 that referenced this issue May 17, 2024
@vobu vobu closed this as completed in #616 May 23, 2024
vobu pushed a commit that referenced this issue May 23, 2024
Co-authored-by: Daniel Lang <daniel.lang@ortec.com>
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

Successfully merging a pull request may close this issue.

1 participant