From a660e66604af69d236bc4514c0a1fe92397aa3e3 Mon Sep 17 00:00:00 2001 From: riteshnahar <50190808+riteshnahar@users.noreply.github.com> Date: Tue, 4 Aug 2020 18:40:59 +0530 Subject: [PATCH 1/4] PRO-16810: ProvarDX Incorrect Help messages (#23) - Updated help messages for runtests, validate commands displayed on running `sfdx provar --help` - Updated company name in LICENSE.md --- CHANGELOG.md | 7 +++++++ LICENSE.md | 2 +- README.md | 6 +++--- messages/metadatacache.json | 2 +- messages/runtests.json | 2 +- messages/validate.json | 2 +- package.json | 18 +++++++++++++++--- src/commands/provar/runtests.ts | 2 +- 8 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81f20fa..977afe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ 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.2] - 2020-08-04 + +### Changed + +- Updated help messages for runtests, validate commands displayed on running `sfdx provar --help` +- Updated company name in LICENSE.md + ## [0.2.1] - 2020-07-08 ### Fixed diff --git a/LICENSE.md b/LICENSE.md index 05ce98a..659698c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2020, ProvarTesting +Copyright (c) 2020, Make Positive Provar Ltd All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index cd7b2f6..db3baec 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ EXAMPLE ## `sfdx provar:metadatacache` -Command to pre-download any required metadata for a specified user or provar connections. +Command to pre-download any required metadata for a specified user or provar connection ``` USAGE @@ -94,7 +94,7 @@ EXAMPLE ## `sfdx provar:runtests` -Runs the specified list of Provar test cases against the currently configured SFDX defaultuserrname +Runs a specified list of Provar test cases against a specified DevHub user alias or username ``` USAGE @@ -136,7 +136,7 @@ EXAMPLE ## `sfdx provar:validate` -Validate the provardx property file agains standard JSON Schema +Verify a property file to confirm it is a well formed provardx property file ``` USAGE diff --git a/messages/metadatacache.json b/messages/metadatacache.json index 9c9aedc..6c78730 100644 --- a/messages/metadatacache.json +++ b/messages/metadatacache.json @@ -1,5 +1,5 @@ { - "commandDescription": "Command to pre-download any required metadata for a specified user or provar connections.", + "commandDescription": "Command to pre-download any required metadata for a specified user or provar connection", "metadataLevelFlagDescription": "Permitted values reload (get all metadata - default) | refresh (only download changes).", "cachePathFlagDescription": "Relative or full file path for where the metadata cache will be stored.", "propertyFileFlagDescription": "Specify custom property file.", diff --git a/messages/runtests.json b/messages/runtests.json index e1a8b6d..de95268 100644 --- a/messages/runtests.json +++ b/messages/runtests.json @@ -1,5 +1,5 @@ { - "commandDescription": "Runs the specified list of Provar test cases against the currently configured SFDX defaultuserrname", + "commandDescription": "Runs a specified list of Provar test cases against a specified DevHub user alias or username", "propertyFileFlagDescription": "provardx-properties.json file. If filepath specified the filename will be assumed or it can be specified (.e.g myprops.json). File must be in JSON format and conform to the provardx-properties JSON schema.", "fileSpecFlagDescription": "Specify comma-delimited, ordered paths of test cases to be executed. If not provided all tests in the PROJECTPATH will be executed.", "connectionOverridefile": "Connection file in the format provardx-connection-schema.json providing a mapping between the Provar project Connection names and the target users to be used.", diff --git a/messages/validate.json b/messages/validate.json index c439ef4..13d0763 100644 --- a/messages/validate.json +++ b/messages/validate.json @@ -1,5 +1,5 @@ { - "commandDescription": "Validate the provardx property file agains standard JSON Schema", + "commandDescription": "Verify a property file to confirm it is a well formed provardx property file", "propertyFileFlagDescription": "Specify custom property file.", "showErrorsFlagDescription": "Allow to show validation errors. Default is false.", "loglevelFlagDescription": "Allow to provide loglevels." diff --git a/package.json b/package.json index ca41c44..afc9461 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@provartesting/provardx", "description": "A plugin for the Salesforce CLI to run provar testcases", - "version": "0.2.1", + "version": "0.2.2", "author": "Provar", "bugs": "https://github.com/ProvarTesting/provardx/issues", "dependencies": { @@ -51,8 +51,20 @@ "commands": "./lib/commands", "bin": "sfdx", "topics": { - "hello": { - "description": "Commands to say hello." + "provar": { + "description": "Developer tools for executing Provar tests from a command line and using Salesforce DevHub aliases" + }, + "provar:compile": { + "description": "Pre-compiles any /src PageObject or PageControl Java source files into object code to use in runtests" + }, + "provar:metadacache": { + "description": "Command to pre-download any required metadata for a specified user or provar connection" + }, + "provar:runtests": { + "description": "Runs a specified list of Provar test cases against a specified DevHub user alias or username" + }, + "provar:validate": { + "description": "Verify a property file to confirm it is a well formed provardx property file" } }, "devPlugins": [ diff --git a/src/commands/provar/runtests.ts b/src/commands/provar/runtests.ts index 553e158..dd99fb8 100644 --- a/src/commands/provar/runtests.ts +++ b/src/commands/provar/runtests.ts @@ -13,7 +13,7 @@ import { cli } from 'cli-ux'; import ProvarDXUtility from '../../utilities/ProvarDXUtility'; /** - * Runs the specified list of Provar test cases against the currently configured SFDX defaultuserrname unless overridden + * Runs a specified list of Provar test cases against a specified DevHub user alias or username unless overridden * in the command below or by a provardx-properties.json file * @author Himanshu Sharma * From 609db17eeb7ffbf7c8ac0147ac2cbfd77396a88e Mon Sep 17 00:00:00 2001 From: riteshnahar <50190808+riteshnahar@users.noreply.github.com> Date: Fri, 28 Aug 2020 14:00:03 +0530 Subject: [PATCH 2/4] PRO-16923: ProvarDX runtests fails to handle special characters in Scratch Org Passwords properly (#25) * PRO-16923: ProvarDX runtests fails to handle special characters in Scratch Org Passwords properly * PRO-16923: Special characters were causing issues on different OS so encoded the password * PRO-16897: ProvarDX: Runtests secrets flag override incorrectly documented * PRO-16897: ProvarDX: Runtests secrets flag override incorrectly documented --- .gitignore | 1 - .vscode/launch.json | 35 ++++++++++++++++++++++++ .vscode/provardx-copyright.code-snippets | 15 ++++++++++ CHANGELOG.md | 17 ++++++++++++ README.md | 6 ++-- messages/runtests.json | 2 +- package.json | 2 +- src/utilities/ProvarDXUtility.ts | 4 +-- 8 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/provardx-copyright.code-snippets diff --git a/.gitignore b/.gitignore index 2275ab6..79f6e4e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,3 @@ node_modules /.circleci /.sfdx -/.vscode diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..43b585c --- /dev/null +++ b/.vscode/launch.json @@ -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}" + } + ] +} diff --git a/.vscode/provardx-copyright.code-snippets b/.vscode/provardx-copyright.code-snippets new file mode 100644 index 0000000..7694d3b --- /dev/null +++ b/.vscode/provardx-copyright.code-snippets @@ -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", + " */", + "$0" + ], + "description": "Insert the Provar copyright header" + } +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 977afe6..ea80fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,23 @@ 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-25 + +### Fixed + +- ProvarDX runtests, metadatacache command fails in case we are having special characters in Scratch Org password + +### Changed + +- ProvarDX trademark changes +- Updated help messages for runtests + +### Added + +- Added .vscode folder containing + - `launch.json`: debug configuration for vscode + - `provardx-copyright.code-snippets`: used to add copyright tag on source files + ## [0.2.2] - 2020-08-04 ### Changed diff --git a/README.md b/README.md index db3baec..8343dd3 100644 --- a/README.md +++ b/README.md @@ -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) @@ -126,7 +126,7 @@ OPTIONS must be in JSON format and conform to the provardx-properties JSON schema. - -s, --secrets=secrets Specify path to secrets file + -s, --secrets=secrets Specify a secrets encryption key for accessing the chosen project/environment. --json format output as json diff --git a/messages/runtests.json b/messages/runtests.json index de95268..8406d26 100644 --- a/messages/runtests.json +++ b/messages/runtests.json @@ -5,6 +5,6 @@ "connectionOverridefile": "Connection file in the format provardx-connection-schema.json providing a mapping between the Provar project Connection names and the target users to be used.", "cachePathFlagDescription": "Specify relative or full file path for where a metadata cache has already been downloaded using either a VCS extract or metadata ProvarDX command.", "metadataLevelFlagDescription": "Specify permitted values reload (get all metadata - default) | refresh (only download changes). This overrides any settings made in the propertyfile.", - "secretsFlagDescription": "Specify path to secrets file", + "secretsFlagDescription": "Specify a secrets encryption key for accessing the chosen project/environment.", "loglevelFlagDescription": "Specify the level of feedback provided during the compilation (see above) and execution." } diff --git a/package.json b/package.json index afc9461..890eb04 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/utilities/ProvarDXUtility.ts b/src/utilities/ProvarDXUtility.ts index 64a1cfd..f18285a 100644 --- a/src/utilities/ProvarDXUtility.ts +++ b/src/utilities/ProvarDXUtility.ts @@ -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 = encodeURIComponent(password); } return password; } From 1d25b10e87ec6ed0f17740594517ea226160d4bf Mon Sep 17 00:00:00 2001 From: Mayank Nehru Date: Fri, 28 Aug 2020 17:17:56 +0530 Subject: [PATCH 3/4] PRO-16890 : Enforce required flags for provar:metadatacache (#26) * PRO-16890 : Enforce required flags for provar:metadatacache The command started executing even when required flags were not given. Changed that to give error in typescript itself. Also made changes to make sure that the flags work correctly in tandem. * PRO-16890 : Implement review comments and add change log * PRO-16890 : Implement review comments Corrected conditional checks to use "===" & '!==' for comparison and renamed variables with self explanatory names * PRO-16890 : Implement review comments Co-authored-by: mayank.nehru --- CHANGELOG.md | 8 ++++ package.json | 3 +- src/commands/provar/metadatacache.ts | 65 ++++++++++++++++++++-------- 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea80fa8..95b3b06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ 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.4] - 2020-08-25 + +### Fixed + +- Enforced the required flags for ProvarDX metadatacache command +- Fixed the working of flags for ProvarDX metadatacache command in tandem + ## [0.2.3] - 2020-08-25 ### Fixed diff --git a/package.json b/package.json index 890eb04..fc96ee9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "name": "@provartesting/provardx", "description": "A plugin for the Salesforce CLI to run provar testcases", - "version": "0.2.3", + + "version": "0.2.4", "author": "Provar", "bugs": "https://github.com/ProvarTesting/provardx/issues", "dependencies": { diff --git a/src/commands/provar/metadatacache.ts b/src/commands/provar/metadatacache.ts index d743610..b83757f 100644 --- a/src/commands/provar/metadatacache.ts +++ b/src/commands/provar/metadatacache.ts @@ -81,6 +81,22 @@ export default class MetadataCache extends SfdxCommand { const connections: string = this.flags.connections; const connectionoverrides: string = this.flags.connectionoverrides; + if ( + !metadataLevel || !cachePath + ) { + this.ux.error( + "ERROR running provar:metadatacache : Please specify a cachepath and metadatalevel" + ); + return {}; + } + + if (!["Reload", "Refresh", "Reuse"].includes(metadataLevel)) { + this.ux.error( + "ERROR running provar:metadatacache : Please specify a valid metadata level(-m flag). Valid levels are : 'Reuse', 'Refresh' and 'Reload'" + ); + return {}; + } + const provarDxUtils: ProvarDXUtility = new ProvarDXUtility(); const isValid: boolean = provarDxUtils.validatePropertiesJson( propertyFile @@ -96,7 +112,7 @@ export default class MetadataCache extends SfdxCommand { provarDxUtils.hasDuplicateConnectionOverride(propertiesInstance) ) { this.ux.error( - "Invalid property file. Run command sfdx provar:validate' to know the validation errors" + "ERROR running provar:metadatacache : Please specify a valid property file. Run command sfdx provar:validate' to know the validation errors" ); return {}; } @@ -117,26 +133,26 @@ export default class MetadataCache extends SfdxCommand { const userInfo = await provarDxUtils.getDxUsersInfo( properties.connectionOverride ); - if (userInfo == null) { + if (userInfo === null && !connections) { this.ux.error( '[ERROR] No valid user org found to download metadata. Terminating command.' ); return {}; } - const userInfoString = provarDxUtils.prepareRawProperties( + const userInfoString = connections && userInfo === null ? "NA" : provarDxUtils.prepareRawProperties( JSON.stringify({ dxUsers: userInfo }) ); const jarPath = properties.provarHome + '/provardx/provardx.jar'; execSync( 'java -cp "' + - jarPath + - '" com.provar.provardx.DxCommandExecuter ' + - updateProperties + - ' ' + - userInfoString + - ' ' + - 'Metadata', + jarPath + + '" com.provar.provardx.DxCommandExecuter ' + + updateProperties + + ' ' + + userInfoString + + ' ' + + 'Metadata', { stdio: 'inherit' } ); return {}; @@ -167,15 +183,30 @@ export default class MetadataCache extends SfdxCommand { properties: any, connectionOverride: string ): void { - if (!connectionOverride) { + if (!connectionOverride && !properties.connectionName) { return; } - const overrides = connectionOverride.split(','); - const connOver = []; - for (const override of overrides) { - const v = override.split(':'); - connOver.push({ connection: v[0], username: v[1] }); + + if (properties.connectionName && properties.connectionOverride) { + const overrides = properties.connectionName.split(','); + const connOver = []; + for (const override of properties.connectionOverride) { + if (overrides.indexOf(override.connection) !== -1) { + connOver.push(override); + } + } + properties.connectionOverride = connOver; + } + + if (connectionOverride) { + const overrides = connectionOverride.split(','); + for (const override of overrides) { + const overrideDetails = override.split(':'); + const prop = properties.connectionOverride.find(f => f.connection === overrideDetails[0]); + if(prop){ + prop.username = overrideDetails[1]; + } + } } - properties.connectionOverride = connOver; } } From 679ed696c42e138712d7ac7ab86a2d4367197035 Mon Sep 17 00:00:00 2001 From: riteshnahar <50190808+riteshnahar@users.noreply.github.com> Date: Fri, 11 Sep 2020 21:24:18 +0530 Subject: [PATCH 4/4] PRO-17213: ProvarDX 0.3.0 release (#27) Bumped version to 0.3.0 --- CHANGELOG.md | 10 ++-------- package.json | 3 +-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95b3b06..148dcd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,20 +5,14 @@ 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.4] - 2020-08-25 +## [0.3.0] - 2020-09-11 ### Fixed +- ProvarDX runtests, metadatacache command fails in case we are having special characters in Scratch Org password - Enforced the required flags for ProvarDX metadatacache command - Fixed the working of flags for ProvarDX metadatacache command in tandem -## [0.2.3] - 2020-08-25 - -### Fixed - -- ProvarDX runtests, metadatacache command fails in case we are having special characters in Scratch Org password - ### Changed - ProvarDX trademark changes diff --git a/package.json b/package.json index fc96ee9..eb9801e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,7 @@ { "name": "@provartesting/provardx", "description": "A plugin for the Salesforce CLI to run provar testcases", - - "version": "0.2.4", + "version": "0.3.0", "author": "Provar", "bugs": "https://github.com/ProvarTesting/provardx/issues", "dependencies": {