protractor-junit-xml-plugin
Advanced tools
Comparing version 1.2.0 to 1.2.1
54
index.js
@@ -10,2 +10,3 @@ 'use strict' | ||
OUTDIR_FINAL, | ||
PR_CARE_ORCHESTRATOR_VERSION = 'PR_CARE_ORCHESTRATOR_VERSION', | ||
currentBrowser, | ||
@@ -122,17 +123,29 @@ outputFile, | ||
let sapphireWebAppConfig = await currentBrowser.executeScript('return sapphireWebAppConfig'); | ||
console.debug('sapphireWebAppConfig: ' + JSON.stringify(sapphireWebAppConfig)) | ||
const requiredKeys = ['environment', 'appName', 'appVersion', | ||
'isNewRelicEnabled', 'careOrchestratorVersion', 'careOrchestratorBuildNumber', | ||
'careOrchestratorLastBuildDate', 'gatewayUrl'] | ||
// if sapphireWebAppConfig global var not present then quit | ||
if (!sapphireWebAppConfig) return; | ||
console.debug('sapphireWebAppConfig: ' + JSON.stringify(sapphireWebAppConfig)); | ||
const requiredKeys = ['environment', 'appName', 'appVersion', | ||
'isNewRelicEnabled', 'careOrchestratorVersion', 'careOrchestratorBuildNumber', | ||
'careOrchestratorLastBuildDate', 'gatewayUrl']; | ||
const PR_CARE_ORCH_KEY = 'pr.care-orchestrator', | ||
TOGGLES_KEY = 'TOGGLES', | ||
PACKAGED_DEPS_KEY = 'packagedDeps'; | ||
requiredKeys.forEach((item) => (envProperties[item] = sapphireWebAppConfig[item])); | ||
if(sapphireWebAppConfig.packagedDeps) { | ||
envProperties.pr_care_orchestrator_version = sapphireWebAppConfig.packagedDeps['pr.care-orchestrator']; | ||
if (sapphireWebAppConfig[PACKAGED_DEPS_KEY]) { | ||
envProperties[PR_CARE_ORCHESTRATOR_VERSION] = sapphireWebAppConfig.packagedDeps[PR_CARE_ORCH_KEY]; | ||
} | ||
// Get toggles and add them in metadata | ||
const TOGGLE_PREFIX = 'TOGGLES_' | ||
for(let toggle in sapphireWebAppConfig.TOGGLES) { | ||
envProperties[TOGGLE_PREFIX + toggle] = sapphireWebAppConfig.TOGGLES[toggle]; | ||
} | ||
for (let toggle in sapphireWebAppConfig[TOGGLES_KEY]) { | ||
envProperties[TOGGLE_PREFIX + toggle] = sapphireWebAppConfig.TOGGLES[toggle]; | ||
} | ||
} | ||
const addReqProcessEnvProp = (envProperties) => { | ||
const reqKeys = ['BUILD_NUMBER', 'TEAMCITY_BUILDCONF_NAME', 'USER', 'LANG', 'PWD']; | ||
reqKeys.forEach((key) => (envProperties[key] = process.env[key])); | ||
} | ||
JUnitXmlPlugin.prototype.onPrepare = async function () { | ||
@@ -211,3 +224,3 @@ if (browser) { | ||
let suite = suites[await getBrowserId()]; | ||
// resolving path and creating dir if it doesn't exist | ||
@@ -224,5 +237,24 @@ if (pluginConfig.uniqueName === false) { | ||
} | ||
// add process.env useful properties | ||
addReqProcessEnvProp(metaDataContents.envProperties); | ||
if (pluginConfig.captureSapphireWebAppContextVar) { | ||
// add sapphireWebAppConfig app object properties | ||
await addSapphireWebAppConfigProperties(metaDataContents.envProperties); | ||
// if BUILD_NUMBER & TEAMCITY_BUILDCONF_NAME not found then populate them using sapphireWebAppConfig | ||
if (!metaDataContents.envProperties.BUILD_NUMBER) { | ||
if (metaDataContents.envProperties[PR_CARE_ORCHESTRATOR_VERSION]) { | ||
metaDataContents.envProperties.BUILD_NUMBER = metaDataContents.envProperties[PR_CARE_ORCHESTRATOR_VERSION]; | ||
} | ||
} | ||
if (!metaDataContents.envProperties.TEAMCITY_BUILDCONF_NAME) { | ||
if (metaDataContents.envProperties.appName) { | ||
metaDataContents.envProperties.TEAMCITY_BUILDCONF_NAME = metaDataContents.envProperties.appName; | ||
} else { | ||
metaDataContents.envProperties.TEAMCITY_BUILDCONF_NAME = 'Local Run by User ' + process.env.USER; | ||
} | ||
} | ||
} | ||
@@ -229,0 +261,0 @@ |
{ | ||
"name": "protractor-junit-xml-plugin", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A Protracotor plugin. Report results in junit xml format including requirement ids if available.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
17205
234
3