azure-pipelines-tasks-webdeployment-common 4.230.1 → 4.230.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Tests/L0.d.ts +1 -0
- package/Tests/L0.js +23 -0
- package/Tests/L0.ts +22 -0
- package/Tests/L0CopyDirectory.d.ts +1 -5
- package/Tests/L0CopyDirectory.js +89 -51
- package/Tests/L0CopyDirectory.ts +93 -55
- package/Tests/L0GenerateWebConfig.d.ts +1 -2
- package/Tests/L0GenerateWebConfig.js +55 -24
- package/Tests/L0GenerateWebConfig.ts +51 -31
- package/Tests/L0MSDeployUtility.d.ts +2 -16
- package/Tests/L0MSDeployUtility.js +91 -97
- package/Tests/L0MSDeployUtility.ts +91 -100
- package/Tests/L1JSONVarSubWithComments.d.ts +1 -1
- package/Tests/L1JSONVarSubWithComments.js +31 -46
- package/Tests/L1JSONVarSubWithComments.ts +40 -52
- package/Tests/L1JsonVarSub.d.ts +1 -1
- package/Tests/L1JsonVarSub.js +58 -66
- package/Tests/L1JsonVarSub.ts +67 -66
- package/Tests/L1JsonVarSubV2.d.ts +1 -1
- package/Tests/L1JsonVarSubV2.js +82 -93
- package/Tests/L1JsonVarSubV2.ts +82 -94
- package/Tests/L1ValidateFileEncoding.d.ts +2 -5
- package/Tests/L1ValidateFileEncoding.js +52 -65
- package/Tests/L1ValidateFileEncoding.ts +61 -77
- package/Tests/L1XdtTransform.d.ts +2 -3
- package/Tests/L1XdtTransform.js +48 -6
- package/Tests/L1XdtTransform.ts +57 -6
- package/Tests/L1XmlVarSub.d.ts +2 -3
- package/Tests/L1XmlVarSub.js +56 -20
- package/Tests/L1XmlVarSub.ts +81 -24
- package/ctt/ctt/ctt.exe +0 -0
- package/package.json +7 -3
- package/packageUtility.js +6 -5
- package/utility.js +1 -1
- package/webconfigutil.d.ts +3 -1
- package/xdttransformationutility.js +1 -1
|
@@ -1,101 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runGetWebDeployErrorCodeTests = exports.runGetMSDeployCmdArgsTests = void 0;
|
|
4
|
+
const assert = require("assert");
|
|
5
|
+
const msdeployutility_1 = require("../msdeployutility");
|
|
6
|
+
function runGetMSDeployCmdArgsTests() {
|
|
7
|
+
it('Should produce default valid args', () => {
|
|
8
|
+
const profile = createDefaultPublishProfile();
|
|
9
|
+
const args = msdeployutility_1.getMSDeployCmdArgs('package.zip', 'webapp_name', profile, true, false, true, null, null, null, true, false, false);
|
|
10
|
+
const expectedArgs = [
|
|
11
|
+
"-source:package=\"'package.zip'\"",
|
|
12
|
+
"-dest:auto,ComputerName=\"'https://http://webapp_name.scm.azurewebsites.net:443/msdeploy.axd?site=webapp_name'\",UserName=\"'$webapp_name'\",Password=\"'webapp_password'\",AuthType=\"'Basic'\"",
|
|
13
|
+
"-setParam:name=\"'IIS Web Application Name'\",value=\"'webapp_name'\"",
|
|
14
|
+
"-enableRule:AppOffline"
|
|
15
|
+
];
|
|
16
|
+
const notExpectedArgs = ["-setParamFile"];
|
|
17
|
+
checkParametersIfPresent(args, expectedArgs);
|
|
18
|
+
checkParametersNotPresent(args, notExpectedArgs);
|
|
19
|
+
});
|
|
20
|
+
it('Should produce valid args with token auth', () => {
|
|
21
|
+
const profile = createDefaultPublishProfile();
|
|
22
|
+
const args = msdeployutility_1.getMSDeployCmdArgs('package.zip', 'webapp_name', profile, true, false, true, null, null, null, true, false, false, "Bearer");
|
|
23
|
+
checkParametersIfPresent(args, ["AuthType=\"'Bearer'\""]);
|
|
24
|
+
});
|
|
25
|
+
it('Should produce valid args with parameter file', () => {
|
|
26
|
+
const profile = createDefaultPublishProfile();
|
|
27
|
+
const args = msdeployutility_1.getMSDeployCmdArgs('package.zip', 'webapp_name', profile, false, false, true, null, 'temp_param.xml', null, false, false, true);
|
|
28
|
+
const expectedArgs = ['-setParamFile=temp_param.xml', "-dest:contentPath=\"'webapp_name'\"", '-enableRule:DoNotDelete'];
|
|
29
|
+
checkParametersIfPresent(args, expectedArgs);
|
|
30
|
+
});
|
|
31
|
+
it('Should produce valid args with folder package', () => {
|
|
32
|
+
const profile = createDefaultPublishProfile();
|
|
33
|
+
const args = msdeployutility_1.getMSDeployCmdArgs('c:/package/folder', 'webapp_name', profile, true, false, true, null, null, null, true, true, true);
|
|
34
|
+
const expectedArgs = [
|
|
35
|
+
"-source:IisApp=\"'c:/package/folder'\"",
|
|
36
|
+
" -dest:iisApp=\"'webapp_name'\""
|
|
37
|
+
];
|
|
38
|
+
checkParametersIfPresent(args, expectedArgs);
|
|
39
|
+
});
|
|
40
|
+
it('Should produce valid args with exclude data', () => {
|
|
41
|
+
const profile = createDefaultPublishProfile();
|
|
42
|
+
const args = msdeployutility_1.getMSDeployCmdArgs('package.zip', 'webapp_name', profile, false, true, true, null, null, null, false, false, true);
|
|
43
|
+
checkParametersIfPresent(args, ['-skip:Directory=App_Data']);
|
|
44
|
+
});
|
|
45
|
+
it("Should produce valid args with war file", () => {
|
|
46
|
+
const profile = createDefaultPublishProfile();
|
|
47
|
+
const args = msdeployutility_1.getMSDeployCmdArgs('package.war', 'webapp_name', profile, false, true, true, null, null, null, false, false, true);
|
|
48
|
+
checkParametersIfPresent(args, [
|
|
49
|
+
" -source:contentPath=\"'package.war'\"",
|
|
50
|
+
" -dest:contentPath=\"'/site/webapps/package.war'\""
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
it("Should override retry arguments", () => {
|
|
54
|
+
const profile = createDefaultPublishProfile();
|
|
55
|
+
const args = msdeployutility_1.getMSDeployCmdArgs('package.zip', 'webapp_name', profile, false, true, true, null, null, '-retryAttempts:11 -retryInterval:5000', false, false, true);
|
|
56
|
+
checkParametersIfPresent(args, ['-retryAttempts:11', '-retryInterval:5000']);
|
|
57
|
+
});
|
|
58
|
+
function checkParametersIfPresent(argumentString, argumentCheckArray) {
|
|
59
|
+
for (const argument of argumentCheckArray) {
|
|
60
|
+
if (argumentString.indexOf(argument) === -1) {
|
|
61
|
+
assert.strictEqual(argumentString.indexOf(argument), -1, `Argument ${argument} not found in ${argumentString}`);
|
|
62
|
+
}
|
|
13
63
|
}
|
|
14
64
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
var tokenAuthMSBuildPackageArgument = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
|
|
30
|
-
publishUrl: 'publishUrl', userName: 'user', userPWD: 'token'
|
|
31
|
-
}, true, false, true, null, null, null, true, false, false, "Bearer");
|
|
32
|
-
console.log(` * MSBUILD TOKEN AUTH PARAMS: ${tokenAuthMSBuildPackageArgument}`);
|
|
33
|
-
if (checkParametersIfPresent(tokenAuthMSBuildPackageArgument, ["AuthType=\"'Bearer'\""])) {
|
|
34
|
-
console.log("MSBUILD TOKEN AUTH PARAMS PASSED");
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
throw new Error('MSBUILD TOKEN AUTH PARAMS FAILED');
|
|
38
|
-
}
|
|
39
|
-
var packageWithSetParamArgument = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
|
|
40
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
41
|
-
}, false, false, true, null, 'temp_param.xml', null, false, false, true);
|
|
42
|
-
console.log(` * PACKAGE WITh SET PARAMS: ${packageWithSetParamArgument}`);
|
|
43
|
-
if (checkParametersIfPresent(packageWithSetParamArgument, ['-setParamFile=temp_param.xml', "-dest:contentPath=\"'webapp_name'\"", '-enableRule:DoNotDelete'])) {
|
|
44
|
-
console.log('ARGUMENTS WITH SET PARAMS PASSED');
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
throw Error('ARGUMENTS WITH SET PARAMS FAILED');
|
|
48
|
-
}
|
|
49
|
-
var folderPackageArgument = msdeployUtility.getMSDeployCmdArgs('c:/package/folder', 'webapp_name', {
|
|
50
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
51
|
-
}, true, false, true, null, null, null, true, true, true);
|
|
52
|
-
console.log(` * ARGUMENT WITh FOLDER AS PACKAGE: ${folderPackageArgument}`);
|
|
53
|
-
if (checkParametersIfPresent(folderPackageArgument, [
|
|
54
|
-
"-source:IisApp=\"'c:/package/folder'\"",
|
|
55
|
-
" -dest:iisApp=\"'webapp_name'\""
|
|
56
|
-
])) {
|
|
57
|
-
console.log('ARGUMENT WITH FOLDER PACKAGE PASSED');
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw Error('ARGUMENT WITH FOLDER PACKAGE FAILED');
|
|
61
|
-
}
|
|
62
|
-
var packageWithExcludeAppDataArgument = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
|
|
63
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
64
|
-
}, false, true, true, null, null, null, false, false, true);
|
|
65
|
-
console.log(` * ARGUMENT WITh FOLDER AS PACKAGE: ${packageWithExcludeAppDataArgument}`);
|
|
66
|
-
if (checkParametersIfPresent(packageWithExcludeAppDataArgument, ['-skip:Directory=App_Data'])) {
|
|
67
|
-
console.log('ARGUMENT WITH EXCLUDE APP DATA PASSED');
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
throw new Error('ARGUMENT WITH EXCLUDE APP DATA FAILED');
|
|
71
|
-
}
|
|
72
|
-
var warDeploymentArgument = msdeployUtility.getMSDeployCmdArgs('package.war', 'webapp_name', {
|
|
73
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
74
|
-
}, false, true, true, null, null, null, false, false, true);
|
|
75
|
-
console.log(` * ARGUMENT WITh WAR FILE AS PACKAGE: ${warDeploymentArgument}`);
|
|
76
|
-
if (checkParametersIfPresent(warDeploymentArgument, [
|
|
77
|
-
" -source:contentPath=\"'package.war'\"",
|
|
78
|
-
" -dest:contentPath=\"'/site/webapps/package.war'\""
|
|
79
|
-
])) {
|
|
80
|
-
console.log('ARGUMENT WITH WAR PACKAGE PASSED');
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
throw new Error('ARGUMENT WITH WAR PACKAGE FAILED');
|
|
84
|
-
}
|
|
85
|
-
var overrideRetryArgument = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
|
|
86
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
87
|
-
}, false, true, true, null, null, '-retryAttempts:11 -retryInterval:5000', false, false, true);
|
|
88
|
-
console.log(` * ARGUMENTS WITH WAR FILE: ${overrideRetryArgument}`);
|
|
89
|
-
if (checkParametersIfPresent(overrideRetryArgument, ['-retryAttempts:11', '-retryInterval:5000'])) {
|
|
90
|
-
console.log('ARGUMENT WITH OVERRIDE RETRY FLAG PASSED');
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
throw new Error('ARGUMENT WITH OVERRIDE RETRY FLAG FAILED');
|
|
94
|
-
}
|
|
95
|
-
// msdeployutility getWebDeployErrorCode
|
|
96
|
-
for (var errorMessage in errorMessages) {
|
|
97
|
-
if (msdeployUtility.getWebDeployErrorCode(errorMessage) != errorMessages[errorMessage]) {
|
|
98
|
-
throw new Error('MSDEPLOY getWebDeployErrorCode failed');
|
|
65
|
+
function checkParametersNotPresent(argumentString, argumentCheckArray) {
|
|
66
|
+
for (var argument of argumentCheckArray) {
|
|
67
|
+
if (argumentString.indexOf(argument) !== -1) {
|
|
68
|
+
assert.strictEqual(argumentString.indexOf(argument), -1, `Argument ${argument} found in ${argumentString}`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function createDefaultPublishProfile() {
|
|
73
|
+
return {
|
|
74
|
+
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443',
|
|
75
|
+
userName: '$webapp_name',
|
|
76
|
+
userPWD: 'webapp_password'
|
|
77
|
+
};
|
|
99
78
|
}
|
|
100
79
|
}
|
|
101
|
-
|
|
80
|
+
exports.runGetMSDeployCmdArgsTests = runGetMSDeployCmdArgsTests;
|
|
81
|
+
function runGetWebDeployErrorCodeTests() {
|
|
82
|
+
it("Should return proper error messages", () => {
|
|
83
|
+
const errorMessages = {
|
|
84
|
+
'ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER': 'ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER',
|
|
85
|
+
"An error was encountered when processing operation 'Delete Directory' on 'D:\\home\\site\\wwwroot\\app_data\\jobs\\continous'": "WebJobsInProgressIssue",
|
|
86
|
+
"Cannot delete file main.dll. Error code: FILE_IN_USE": "FILE_IN_USE",
|
|
87
|
+
"transport connection": "transport connection",
|
|
88
|
+
"error code: ERROR_CONNECTION_TERMINATED": "ERROR_CONNECTION_TERMINATED"
|
|
89
|
+
};
|
|
90
|
+
for (var errorMessage in errorMessages) {
|
|
91
|
+
assert.strictEqual(msdeployutility_1.getWebDeployErrorCode(errorMessage), errorMessages[errorMessage]);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
exports.runGetWebDeployErrorCodeTests = runGetWebDeployErrorCodeTests;
|
|
@@ -1,128 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var errorMessages = {
|
|
4
|
-
'ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER': 'ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER',
|
|
5
|
-
"An error was encountered when processing operation 'Delete Directory' on 'D:\\home\\site\\wwwroot\\app_data\\jobs\\continous'": "WebJobsInProgressIssue",
|
|
6
|
-
"Cannot delete file main.dll. Error code: FILE_IN_USE": "FILE_IN_USE",
|
|
7
|
-
"transport connection": "transport connection",
|
|
8
|
-
"error code: ERROR_CONNECTION_TERMINATED": "ERROR_CONNECTION_TERMINATED"
|
|
9
|
-
}
|
|
1
|
+
import assert = require("assert");
|
|
2
|
+
import { getMSDeployCmdArgs, getWebDeployErrorCode } from "../msdeployutility";
|
|
10
3
|
|
|
11
|
-
function checkParametersIfPresent(argumentString: string, argumentCheckArray: Array<string>) {
|
|
12
|
-
for(var argument of argumentCheckArray) {
|
|
13
|
-
if(argumentString.indexOf(argument) == -1) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
4
|
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
5
|
|
|
21
|
-
|
|
22
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
23
|
-
}, true, false, true, null, null, null, true, false, false);
|
|
6
|
+
export function runGetMSDeployCmdArgsTests() {
|
|
24
7
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
" -setParam:name=\"'IIS Web Application Name'\",value=\"'webapp_name'\"", '-enableRule:AppOffline']) && defaultMSBuildPackageArgument.indexOf('-setParamFile') == -1) {
|
|
29
|
-
console.log("MSBUILD DEFAULT PARAMS PASSED");
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
throw new Error('MSBUILD PACKAGE DEFAULT PARAMS FAILED');
|
|
33
|
-
}
|
|
8
|
+
it('Should produce default valid args', () => {
|
|
9
|
+
const profile = createDefaultPublishProfile();
|
|
10
|
+
const args = getMSDeployCmdArgs('package.zip', 'webapp_name', profile, true, false, true, null, null, null, true, false, false);
|
|
34
11
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
12
|
+
const expectedArgs = [
|
|
13
|
+
"-source:package=\"'package.zip'\"",
|
|
14
|
+
"-dest:auto,ComputerName=\"'https://http://webapp_name.scm.azurewebsites.net:443/msdeploy.axd?site=webapp_name'\",UserName=\"'$webapp_name'\",Password=\"'webapp_password'\",AuthType=\"'Basic'\"",
|
|
15
|
+
"-setParam:name=\"'IIS Web Application Name'\",value=\"'webapp_name'\"",
|
|
16
|
+
"-enableRule:AppOffline"];
|
|
38
17
|
|
|
39
|
-
|
|
40
|
-
if(checkParametersIfPresent(tokenAuthMSBuildPackageArgument, ["AuthType=\"'Bearer'\""])) {
|
|
41
|
-
console.log("MSBUILD TOKEN AUTH PARAMS PASSED");
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
throw new Error('MSBUILD TOKEN AUTH PARAMS FAILED');
|
|
45
|
-
}
|
|
18
|
+
const notExpectedArgs = ["-setParamFile"];
|
|
46
19
|
|
|
20
|
+
checkParametersIfPresent(args, expectedArgs);
|
|
21
|
+
checkParametersNotPresent(args, notExpectedArgs);
|
|
22
|
+
});
|
|
47
23
|
|
|
48
|
-
var packageWithSetParamArgument: string = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
|
|
49
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
50
|
-
}, false, false, true, null, 'temp_param.xml', null, false, false, true);
|
|
51
24
|
|
|
25
|
+
it('Should produce valid args with token auth', () => {
|
|
26
|
+
const profile = createDefaultPublishProfile();
|
|
27
|
+
const args = getMSDeployCmdArgs('package.zip', 'webapp_name', profile, true, false, true, null, null, null, true, false, false, "Bearer");
|
|
28
|
+
checkParametersIfPresent(args, ["AuthType=\"'Bearer'\""]);
|
|
29
|
+
});
|
|
52
30
|
|
|
53
|
-
console.log(` * PACKAGE WITh SET PARAMS: ${packageWithSetParamArgument}`);
|
|
54
31
|
|
|
32
|
+
it('Should produce valid args with parameter file', () => {
|
|
33
|
+
const profile = createDefaultPublishProfile();
|
|
34
|
+
const args = getMSDeployCmdArgs('package.zip', 'webapp_name', profile, false, false, true, null, 'temp_param.xml', null, false, false, true);
|
|
55
35
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw Error('ARGUMENTS WITH SET PARAMS FAILED');
|
|
61
|
-
}
|
|
36
|
+
const expectedArgs = ['-setParamFile=temp_param.xml', "-dest:contentPath=\"'webapp_name'\"", '-enableRule:DoNotDelete'];
|
|
37
|
+
checkParametersIfPresent(args, expectedArgs);
|
|
38
|
+
});
|
|
62
39
|
|
|
63
|
-
var folderPackageArgument: string = msdeployUtility.getMSDeployCmdArgs('c:/package/folder', 'webapp_name', {
|
|
64
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
65
|
-
}, true, false, true, null, null, null, true, true, true);
|
|
66
40
|
|
|
67
|
-
|
|
68
|
-
if(checkParametersIfPresent(folderPackageArgument, [
|
|
69
|
-
"-source:IisApp=\"'c:/package/folder'\"",
|
|
70
|
-
" -dest:iisApp=\"'webapp_name'\""
|
|
71
|
-
])) {
|
|
72
|
-
console.log('ARGUMENT WITH FOLDER PACKAGE PASSED');
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
throw Error('ARGUMENT WITH FOLDER PACKAGE FAILED');
|
|
76
|
-
}
|
|
41
|
+
it('Should produce valid args with folder package', () => {
|
|
77
42
|
|
|
43
|
+
const profile = createDefaultPublishProfile();
|
|
44
|
+
const args: string = getMSDeployCmdArgs('c:/package/folder', 'webapp_name', profile, true, false, true, null, null, null, true, true, true);
|
|
78
45
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
46
|
+
const expectedArgs = [
|
|
47
|
+
"-source:IisApp=\"'c:/package/folder'\"",
|
|
48
|
+
" -dest:iisApp=\"'webapp_name'\""
|
|
49
|
+
];
|
|
50
|
+
checkParametersIfPresent(args, expectedArgs);
|
|
51
|
+
});
|
|
82
52
|
|
|
83
|
-
console.log(` * ARGUMENT WITh FOLDER AS PACKAGE: ${packageWithExcludeAppDataArgument}`);
|
|
84
53
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
else {
|
|
89
|
-
throw new Error('ARGUMENT WITH EXCLUDE APP DATA FAILED');
|
|
90
|
-
}
|
|
54
|
+
it('Should produce valid args with exclude data', () => {
|
|
55
|
+
const profile = createDefaultPublishProfile();
|
|
56
|
+
const args: string = getMSDeployCmdArgs('package.zip', 'webapp_name', profile, false, true, true, null, null, null, false, false, true);
|
|
91
57
|
|
|
58
|
+
checkParametersIfPresent(args, ['-skip:Directory=App_Data']);
|
|
59
|
+
});
|
|
92
60
|
|
|
93
|
-
var warDeploymentArgument: string = msdeployUtility.getMSDeployCmdArgs('package.war', 'webapp_name', {
|
|
94
|
-
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
|
|
95
|
-
}, false, true, true, null, null, null, false, false, true);
|
|
96
61
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
" -dest:contentPath=\"'/site/webapps/package.war'\""
|
|
101
|
-
])) {
|
|
102
|
-
console.log('ARGUMENT WITH WAR PACKAGE PASSED');
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
throw new Error('ARGUMENT WITH WAR PACKAGE FAILED');
|
|
106
|
-
}
|
|
62
|
+
it("Should produce valid args with war file", () => {
|
|
63
|
+
const profile = createDefaultPublishProfile();
|
|
64
|
+
const args = getMSDeployCmdArgs('package.war', 'webapp_name', profile, false, true, true, null, null, null, false, false, true);
|
|
107
65
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
66
|
+
checkParametersIfPresent(args, [
|
|
67
|
+
" -source:contentPath=\"'package.war'\"",
|
|
68
|
+
" -dest:contentPath=\"'/site/webapps/package.war'\""
|
|
69
|
+
]);
|
|
70
|
+
});
|
|
111
71
|
|
|
112
|
-
|
|
72
|
+
it("Should override retry arguments", () => {
|
|
73
|
+
const profile = createDefaultPublishProfile();
|
|
74
|
+
const args = getMSDeployCmdArgs('package.zip', 'webapp_name', profile, false, true, true, null, null, '-retryAttempts:11 -retryInterval:5000', false, false, true);
|
|
113
75
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
76
|
+
checkParametersIfPresent(args, ['-retryAttempts:11', '-retryInterval:5000']);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
function checkParametersIfPresent(argumentString: string, argumentCheckArray: string[]): void {
|
|
80
|
+
for (const argument of argumentCheckArray) {
|
|
81
|
+
if (argumentString.indexOf(argument) === -1) {
|
|
82
|
+
assert.strictEqual(argumentString.indexOf(argument), -1, `Argument ${argument} not found in ${argumentString}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
120
86
|
|
|
121
|
-
|
|
122
|
-
for(var
|
|
123
|
-
|
|
124
|
-
|
|
87
|
+
function checkParametersNotPresent(argumentString: string, argumentCheckArray: string[]): void {
|
|
88
|
+
for (var argument of argumentCheckArray) {
|
|
89
|
+
if (argumentString.indexOf(argument) !== -1) {
|
|
90
|
+
assert.strictEqual(argumentString.indexOf(argument), -1, `Argument ${argument} found in ${argumentString}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function createDefaultPublishProfile(): { publishUrl: string, userName: string, userPWD: string } {
|
|
96
|
+
return {
|
|
97
|
+
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443',
|
|
98
|
+
userName: '$webapp_name',
|
|
99
|
+
userPWD: 'webapp_password'
|
|
100
|
+
};
|
|
125
101
|
}
|
|
126
102
|
}
|
|
127
103
|
|
|
128
|
-
|
|
104
|
+
export function runGetWebDeployErrorCodeTests(): void {
|
|
105
|
+
it("Should return proper error messages", () => {
|
|
106
|
+
|
|
107
|
+
const errorMessages = {
|
|
108
|
+
'ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER': 'ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER',
|
|
109
|
+
"An error was encountered when processing operation 'Delete Directory' on 'D:\\home\\site\\wwwroot\\app_data\\jobs\\continous'": "WebJobsInProgressIssue",
|
|
110
|
+
"Cannot delete file main.dll. Error code: FILE_IN_USE": "FILE_IN_USE",
|
|
111
|
+
"transport connection": "transport connection",
|
|
112
|
+
"error code: ERROR_CONNECTION_TERMINATED": "ERROR_CONNECTION_TERMINATED"
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (var errorMessage in errorMessages) {
|
|
116
|
+
assert.strictEqual(getWebDeployErrorCode(errorMessage), errorMessages[errorMessage]);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function runL1JSONVarSubWithCommentsTests(): void;
|
|
@@ -1,51 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var jsonSubUtil = require('azure-pipelines-tasks-webdeployment-common/jsonvariablesubstitutionutility.js');
|
|
3
|
+
exports.runL1JSONVarSubWithCommentsTests = void 0;
|
|
5
4
|
const fs = require("fs");
|
|
6
5
|
const path = require("path");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
const assert = require("assert");
|
|
7
|
+
const jsonvariablesubstitutionutility_1 = require("../jsonvariablesubstitutionutility");
|
|
8
|
+
function runL1JSONVarSubWithCommentsTests() {
|
|
9
|
+
it("Should substitute variables in JSON with comments", (done) => {
|
|
10
|
+
const envVarObject = jsonvariablesubstitutionutility_1.createEnvTree([
|
|
11
|
+
{ name: 'dataSourceBindings.0.target', value: 'AppServiceName', secret: false },
|
|
12
|
+
{ name: 'name', value: 'App Service Deploy', secret: false },
|
|
13
|
+
{ name: 'Hello.World', value: 'Hello World', secret: false },
|
|
14
|
+
{ name: 'dataSourceBindings.1.parameters.WebAppName', value: 'App Service Name params', secret: false },
|
|
15
|
+
{ name: 'messages.Invalidwebapppackageorfolderpathprovided', value: 'Invalidwebapppackageorfolderpathprovided', secret: true }
|
|
16
|
+
]);
|
|
17
|
+
const fileContent = fs.readFileSync(path.join(__dirname, 'L1JSONVarSub', 'JSONWithComments.json'), 'utf-8');
|
|
18
|
+
const jsonContent = jsonvariablesubstitutionutility_1.stripJsonComments(fileContent);
|
|
19
|
+
const jsonObject = JSON.parse(jsonContent);
|
|
20
|
+
jsonvariablesubstitutionutility_1.substituteJsonVariable(jsonObject, envVarObject);
|
|
21
|
+
assert.strictEqual(jsonObject['dataSourceBindings']['0']['target'], 'AppServiceName', 'Should have substituted target variable');
|
|
22
|
+
assert.strictEqual(jsonObject['name'], 'App Service Deploy', 'Should have substituted name variable');
|
|
23
|
+
assert.strictEqual(jsonObject['Hello']['World'], 'Hello World', 'Should have substituted Hello.World variable');
|
|
24
|
+
assert.strictEqual(jsonObject['dataSourceBindings']['1']['parameters']['WebAppName'], 'App Service Name params', 'Should have substituted WebAppName variable');
|
|
25
|
+
assert.strictEqual(jsonObject['messages']['Invalidwebapppackageorfolderpathprovided'], 'Invalidwebapppackageorfolderpathprovided', 'Should have substituted Invalidwebapppackageorfolderpathprovided variable');
|
|
26
|
+
done();
|
|
27
|
+
});
|
|
28
|
+
it("Should throw exception for invalid JSON with comments", (done) => {
|
|
29
|
+
const fileContent = fs.readFileSync(path.join(__dirname, 'L1JSONVarSub', 'InvalidJSONWithComments.json'), 'utf-8');
|
|
30
|
+
const jsonContent = jsonvariablesubstitutionutility_1.stripJsonComments(fileContent);
|
|
31
|
+
console.log(jsonContent);
|
|
32
|
+
assert.throws(() => JSON.parse(jsonContent), "Parse is expected to throw an error");
|
|
33
|
+
done();
|
|
34
|
+
});
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
var fileContent = fs.readFileSync(path.join(__dirname, 'L1JSONVarSub', 'InvalidJSONWithComments.json'), 'utf-8');
|
|
38
|
-
var jsonContent = jsonSubUtil.stripJsonComments(fileContent);
|
|
39
|
-
try {
|
|
40
|
-
var jsonObject = JSON.parse(jsonContent);
|
|
41
|
-
throw new Error('JSON VAR SUB FAIL #6');
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
console.log("INVALID JSON COMMENTS TESTS PASSED");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function validate() {
|
|
48
|
-
validateJSONWithComments();
|
|
49
|
-
validateInvalidJSONWithComments();
|
|
50
|
-
}
|
|
51
|
-
exports.validate = validate;
|
|
36
|
+
exports.runL1JSONVarSubWithCommentsTests = runL1JSONVarSubWithCommentsTests;
|
|
@@ -1,52 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var jsonObject = JSON.parse(jsonContent);
|
|
42
|
-
throw new Error('JSON VAR SUB FAIL #6');
|
|
43
|
-
}
|
|
44
|
-
catch(error) {
|
|
45
|
-
console.log("INVALID JSON COMMENTS TESTS PASSED");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function validate() {
|
|
50
|
-
validateJSONWithComments();
|
|
51
|
-
validateInvalidJSONWithComments();
|
|
52
|
-
}
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as assert from 'assert';
|
|
4
|
+
|
|
5
|
+
import { createEnvTree, stripJsonComments, substituteJsonVariable } from "../jsonvariablesubstitutionutility";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export function runL1JSONVarSubWithCommentsTests(): void {
|
|
9
|
+
|
|
10
|
+
it("Should substitute variables in JSON with comments", (done: Mocha.Done) => {
|
|
11
|
+
const envVarObject = createEnvTree([
|
|
12
|
+
{ name: 'dataSourceBindings.0.target', value: 'AppServiceName', secret: false },
|
|
13
|
+
{ name: 'name', value: 'App Service Deploy', secret: false },
|
|
14
|
+
{ name: 'Hello.World', value: 'Hello World', secret: false },
|
|
15
|
+
{ name: 'dataSourceBindings.1.parameters.WebAppName', value: 'App Service Name params', secret: false },
|
|
16
|
+
{ name: 'messages.Invalidwebapppackageorfolderpathprovided', value: 'Invalidwebapppackageorfolderpathprovided', secret: true }
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
const fileContent: string = fs.readFileSync(path.join(__dirname, 'L1JSONVarSub', 'JSONWithComments.json'), 'utf-8');
|
|
20
|
+
const jsonContent: string = stripJsonComments(fileContent);
|
|
21
|
+
const jsonObject = JSON.parse(jsonContent);
|
|
22
|
+
substituteJsonVariable(jsonObject, envVarObject);
|
|
23
|
+
|
|
24
|
+
assert.strictEqual(jsonObject['dataSourceBindings']['0']['target'], 'AppServiceName', 'Should have substituted target variable');
|
|
25
|
+
assert.strictEqual(jsonObject['name'], 'App Service Deploy', 'Should have substituted name variable');
|
|
26
|
+
assert.strictEqual(jsonObject['Hello']['World'], 'Hello World', 'Should have substituted Hello.World variable');
|
|
27
|
+
assert.strictEqual(jsonObject['dataSourceBindings']['1']['parameters']['WebAppName'], 'App Service Name params', 'Should have substituted WebAppName variable');
|
|
28
|
+
assert.strictEqual(jsonObject['messages']['Invalidwebapppackageorfolderpathprovided'], 'Invalidwebapppackageorfolderpathprovided', 'Should have substituted Invalidwebapppackageorfolderpathprovided variable');
|
|
29
|
+
|
|
30
|
+
done();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("Should throw exception for invalid JSON with comments", (done: Mocha.Done) => {
|
|
34
|
+
const fileContent = fs.readFileSync(path.join(__dirname, 'L1JSONVarSub', 'InvalidJSONWithComments.json'), 'utf-8');
|
|
35
|
+
const jsonContent = stripJsonComments(fileContent);
|
|
36
|
+
console.log(jsonContent);
|
|
37
|
+
assert.throws(() => JSON.parse(jsonContent), "Parse is expected to throw an error");
|
|
38
|
+
done();
|
|
39
|
+
});
|
|
40
|
+
}
|
package/Tests/L1JsonVarSub.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function runL1JsonVarSubTests(): void;
|