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

PRO-16923: ProvarDX runtests fails to handle special characters in Scratch Org Passwords properly #25

Merged
merged 4 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
node_modules
/.circleci
/.sfdx
/.vscode
35 changes: 35 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Remote",
"address": "127.0.0.1",
"port": 9229
},
{
"name": "Unit Tests",
"type": "node",
"request": "launch",
"protocol": "inspector",
"program": "${workspaceRoot}/node_modules/.bin/_mocha",
"args": [
"--require",
"test/helpers/init.js",
"--require",
"ts-node/register",
"--require",
"source-map-support/register",
"--recursive",
"--reporter",
"spec",
"test/**/*.test.ts"
],
"cwd": "${workspaceRoot}"
}
]
}
15 changes: 15 additions & 0 deletions .vscode/provardx-copyright.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Insert Copyright Header": {
"prefix": "copyright",
"body": [
"/*",
" * Copyright (c) 2020 Make Positive Provar Ltd",
" * All rights reserved.",
" * Licensed under the BSD 3-Clause license.",
" * For full license text, see LICENSE.md file in the repo root or https://opensource.org/licenses/BSD-3-Clause",
ProvarTesting marked this conversation as resolved.
Show resolved Hide resolved
" */",
"$0"
],
"description": "Insert the Provar copyright header"
}
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.3] - 2020-08-19

### Fixed

- ProvarDX runtests, metadatacache command fails in case we are having special characters in Scratch Org password

### Changed

- ProvarDX trademark changes

### Added

- Added .vscode folder containing
- `launch.json`: debug configuration for vscode
- `provardx-copyright.code-snippets`: used to add copyright tag on source files

ProvarTesting marked this conversation as resolved.
Show resolved Hide resolved
## [0.2.2] - 2020-08-04

### Changed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# provartesting/provardx
# ProvarDX™

ProvarDX is a Salesforce CLI Plugin for existing Provar customer to allow them to execute Provar Test Cases from the command line, leveraging the Salesforce CLI and SalesforceDX applications. This provides an alternative mechanism for running test cases than running under ANT.
ProvarDX is a Salesforce CLI Plugin for existing Provar customer to allow them to execute Provar Test Cases from the command line, leveraging the Salesforce CLI and SalesforceDX applications. This provides an alternative mechanism for running test cases than running under ANT.
You must be a Provar customer with a valid paid license to write and maintain your test cases.

[![Version](https://img.shields.io/npm/v/@provartesting/provardx.svg)](https://npmjs.org/package/@provartesting/provardx)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@provartesting/provardx",
"description": "A plugin for the Salesforce CLI to run provar testcases",
"version": "0.2.2",
"version": "0.2.3",
"author": "Provar",
"bugs": "https://github.com/ProvarTesting/provardx/issues",
"dependencies": {
Expand Down
4 changes: 1 addition & 3 deletions src/utilities/ProvarDXUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ export default class ProvarDXUtility {

private handleSpecialCharacters(password: string): string {
if (password) {
password = password.split('&').join('"&"');
password = password.split('|').join('"|"');
password = password.split('^').join('"^"');
password = password.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look like the right fix to me. The example in the Jira is an invalid JSON string where the final character in the password is \ which is escaping the closing quote. That's just an error in the JSON not a bug in our code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debugged it on my local and faced a similar issue where the commands were failing due to special characters in the password
2X#$[3P8mj
&2Cp9%Wt4M

So, that's why added a regex to escape special characters correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we have encoded the password value before sending it to Provar.

}
return password;
}
Expand Down