2021-09-13 13:31:43 +02:00
|
|
|
import static org.hamcrest.Matchers.*
|
|
|
|
import static org.junit.Assert.assertThat
|
2019-01-30 18:19:19 +02:00
|
|
|
|
2020-09-24 13:47:20 +02:00
|
|
|
import org.junit.After
|
2018-06-20 11:46:28 +02:00
|
|
|
import org.junit.Before
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import org.junit.rules.ExpectedException
|
|
|
|
import org.junit.rules.RuleChain
|
|
|
|
|
2020-09-24 13:47:20 +02:00
|
|
|
import com.sap.piper.Utils
|
2018-06-29 10:11:46 +02:00
|
|
|
import com.sap.piper.cm.ChangeManagement
|
|
|
|
import com.sap.piper.cm.ChangeManagementException
|
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
import hudson.AbortException
|
2018-06-20 11:46:28 +02:00
|
|
|
import util.BasePiperTest
|
2018-07-13 13:27:21 +02:00
|
|
|
import util.JenkinsCredentialsRule
|
2018-06-20 11:46:28 +02:00
|
|
|
import util.JenkinsLoggingRule
|
2018-08-31 10:22:43 +02:00
|
|
|
import util.JenkinsReadYamlRule
|
2021-09-13 13:31:43 +02:00
|
|
|
import util.JenkinsStepRule
|
2018-06-20 11:46:28 +02:00
|
|
|
import util.Rules
|
|
|
|
|
|
|
|
public class TransportRequestUploadFileTest extends BasePiperTest {
|
|
|
|
|
|
|
|
private ExpectedException thrown = new ExpectedException()
|
2019-01-22 10:25:42 +02:00
|
|
|
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
|
2019-01-22 10:22:15 +02:00
|
|
|
private JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
|
2018-06-20 11:46:28 +02:00
|
|
|
|
|
|
|
@Rule
|
|
|
|
public RuleChain ruleChain = Rules.getCommonRules(this)
|
|
|
|
.around(thrown)
|
2018-08-31 10:22:43 +02:00
|
|
|
.around(new JenkinsReadYamlRule(this))
|
2019-01-22 10:25:42 +02:00
|
|
|
.around(stepRule)
|
2019-01-22 10:22:15 +02:00
|
|
|
.around(loggingRule)
|
2018-07-13 13:27:21 +02:00
|
|
|
.around(new JenkinsCredentialsRule(this)
|
|
|
|
.withCredentials('CM', 'anonymous', '********'))
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2018-07-13 15:13:58 +02:00
|
|
|
private Map cmUtilReceivedParams = [:]
|
2018-06-20 11:46:28 +02:00
|
|
|
|
|
|
|
@Before
|
|
|
|
public void setup() {
|
|
|
|
|
2018-07-13 15:13:58 +02:00
|
|
|
cmUtilReceivedParams.clear()
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2018-07-17 09:21:56 +02:00
|
|
|
nullScript.commonPipelineEnvironment.configuration = [general:
|
|
|
|
[changeManagement:
|
2018-06-20 11:46:28 +02:00
|
|
|
[
|
2018-06-28 16:24:14 +02:00
|
|
|
credentialsId: 'CM',
|
2018-09-28 14:06:06 +02:00
|
|
|
type: 'SOLMAN',
|
2018-06-28 16:24:14 +02:00
|
|
|
endpoint: 'https://example.org/cm'
|
2018-06-20 11:46:28 +02:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
2020-09-24 13:47:20 +02:00
|
|
|
Utils.metaClass.echo = { def m -> }
|
|
|
|
}
|
|
|
|
|
|
|
|
@After
|
|
|
|
public void tearDown() {
|
|
|
|
Utils.metaClass = null
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-09-24 14:06:48 +02:00
|
|
|
public void changeDocumentIdNotProvidedSOLMANTest() {
|
|
|
|
|
|
|
|
// we expect the failure only for SOLMAN (which is the default).
|
|
|
|
// Use case for CTS without change document id is checked by the
|
|
|
|
// straight forward test case for CTS
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2018-07-12 08:54:04 +02:00
|
|
|
thrown.expect(IllegalArgumentException)
|
2020-09-30 14:29:46 +02:00
|
|
|
thrown.expectMessage("Change document id not provided (parameter: 'changeDocumentId' provided to the step call or via commit history).")
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2018-07-10 15:15:54 +02:00
|
|
|
ChangeManagement cm = new ChangeManagement(nullScript) {
|
|
|
|
String getChangeDocumentId(
|
|
|
|
String from,
|
|
|
|
String to,
|
|
|
|
String pattern,
|
|
|
|
String format
|
|
|
|
) {
|
|
|
|
throw new ChangeManagementException('Cannot retrieve changeId from git commits.')
|
2018-07-12 13:55:01 +02:00
|
|
|
}
|
2018-07-10 15:15:54 +02:00
|
|
|
}
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript, transportRequestId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm)
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void transportRequestIdNotProvidedTest() {
|
|
|
|
|
2018-07-12 13:55:01 +02:00
|
|
|
ChangeManagement cm = new ChangeManagement(nullScript) {
|
|
|
|
String getTransportRequestId(
|
|
|
|
String from,
|
|
|
|
String to,
|
|
|
|
String pattern,
|
|
|
|
String format
|
|
|
|
) {
|
|
|
|
throw new ChangeManagementException('Cannot retrieve transport request id from git commits.')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-12 08:54:04 +02:00
|
|
|
thrown.expect(IllegalArgumentException)
|
2020-09-30 14:29:46 +02:00
|
|
|
thrown.expectMessage("Transport request id not provided (parameter: 'transportRequestId' provided to the step call or via commit history).")
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', applicationId: 'app', filePath: '/path', cmUtils: cm)
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-09-24 14:06:48 +02:00
|
|
|
public void applicationIdNotProvidedSOLMANTest() {
|
|
|
|
|
|
|
|
// we expect the failure only for SOLMAN (which is the default).
|
|
|
|
// Use case for CTS without applicationId is checked by the
|
|
|
|
// straight forward test case for CTS
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2018-07-12 08:54:04 +02:00
|
|
|
thrown.expect(IllegalArgumentException)
|
|
|
|
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR applicationId")
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '001', filePath: '/path')
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void filePathNotProvidedTest() {
|
|
|
|
|
2018-07-12 08:54:04 +02:00
|
|
|
thrown.expect(IllegalArgumentException)
|
|
|
|
thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR filePath")
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript, changeDocumentId: '001', transportRequestId: '001', applicationId: 'app')
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-01-30 15:53:34 +02:00
|
|
|
public void uploadFileToTransportRequestSOLMANFailureTest() {
|
2018-06-20 11:46:28 +02:00
|
|
|
|
|
|
|
thrown.expect(AbortException)
|
2018-06-29 10:11:46 +02:00
|
|
|
thrown.expectMessage("Exception message")
|
|
|
|
|
2021-09-16 13:18:03 +02:00
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
2021-09-13 13:31:43 +02:00
|
|
|
throw new AbortException('Exception message')
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
2018-06-29 10:11:46 +02:00
|
|
|
changeDocumentId: '001',
|
|
|
|
transportRequestId: '001',
|
|
|
|
applicationId: 'app',
|
|
|
|
filePath: '/path',
|
2021-09-13 13:31:43 +02:00
|
|
|
changeManagement: [
|
|
|
|
type: 'SOLMAN',
|
|
|
|
endpoint: 'https://example.org/cm',
|
|
|
|
clientOpts: '--client opts'
|
|
|
|
],
|
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2018-09-24 14:06:48 +02:00
|
|
|
public void uploadFileToTransportRequestCTSSuccessTest() {
|
|
|
|
|
2020-10-21 12:04:11 +02:00
|
|
|
loggingRule.expect("[INFO] Uploading application 'myApp' to transport request '002'.")
|
|
|
|
loggingRule.expect("[INFO] Application 'myApp' has been successfully uploaded to transport request '002'.")
|
2018-09-24 14:06:48 +02:00
|
|
|
|
2021-09-16 13:18:03 +02:00
|
|
|
def calledWithParameters,
|
|
|
|
calledWithStepName,
|
|
|
|
calledWithMetadata,
|
|
|
|
calledWithCredentials
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
calledWithStepName = stepName
|
|
|
|
calledWithMetadata = metaData
|
|
|
|
calledWithCredentials = creds
|
|
|
|
})
|
2018-09-24 14:06:48 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
2020-10-21 12:04:11 +02:00
|
|
|
changeManagement: [
|
|
|
|
type: 'CTS',
|
|
|
|
client: '001',
|
|
|
|
cts: [
|
|
|
|
osDeployUser: 'node2',
|
|
|
|
deployToolDependencies: ['@ui5/cli', '@sap/ux-ui5-tooling', '@ui5/logger', '@ui5/fs', '@dummy/foo'],
|
|
|
|
npmInstallOpts: ['--verbose'],
|
|
|
|
]
|
|
|
|
],
|
|
|
|
applicationName: 'myApp',
|
|
|
|
applicationDescription: 'the description',
|
|
|
|
abapPackage: 'myPackage',
|
2018-09-24 14:06:48 +02:00
|
|
|
transportRequestId: '002',
|
2021-09-16 13:18:03 +02:00
|
|
|
credentialsId: 'CM')
|
|
|
|
|
|
|
|
assertThat(calledWithStepName, is('transportRequestUploadCTS'))
|
|
|
|
assertThat(calledWithParameters.transportRequestId, is('002'))
|
|
|
|
assertThat(calledWithParameters.endpoint, is('https://example.org/cm'))
|
|
|
|
assertThat(calledWithParameters.client, is('001'))
|
|
|
|
assertThat(calledWithParameters.applicationName, is('myApp'))
|
|
|
|
assertThat(calledWithParameters.description, is('the description'))
|
|
|
|
assertThat(calledWithParameters.abapPackage, is('myPackage'))
|
|
|
|
assertThat(calledWithParameters.osDeployUser, is('node2'))
|
|
|
|
assertThat(calledWithParameters.deployToolDependencies, is(['@ui5/cli', '@sap/ux-ui5-tooling', '@ui5/logger', '@ui5/fs', '@dummy/foo']))
|
|
|
|
assertThat(calledWithParameters.npmInstallOpts, is(['--verbose']))
|
|
|
|
assertThat(calledWithParameters.deployConfigFile, is('ui5-deploy.yaml'))
|
|
|
|
assertThat(calledWithParameters.uploadCredentialsId, is('CM'))
|
2018-09-24 14:06:48 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 10:29:43 +02:00
|
|
|
@Test
|
|
|
|
public void uploadFileToTransportRequestCTSDockerParams() {
|
|
|
|
|
|
|
|
loggingRule.expect("[INFO] Uploading application 'myApp' to transport request '002'.")
|
|
|
|
loggingRule.expect("[INFO] Application 'myApp' has been successfully uploaded to transport request '002'.")
|
|
|
|
|
|
|
|
def calledWithParameters
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
})
|
|
|
|
|
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
|
|
|
changeManagement: [
|
|
|
|
type: 'CTS',
|
|
|
|
client: '001',
|
|
|
|
cts: [
|
|
|
|
osDeployUser: 'node2',
|
|
|
|
deployToolDependencies: ['@ui5/cli', '@sap/ux-ui5-tooling', '@ui5/logger', '@ui5/fs', '@dummy/foo'],
|
|
|
|
npmInstallOpts: ['--verbose'],
|
|
|
|
nodeDocker: [
|
|
|
|
image: 'ctsImage',
|
|
|
|
options: ['-o1', 'opt1', '-o2', 'opt2'],
|
|
|
|
envVars: [env1: 'env1', env2: 'env2'],
|
|
|
|
pullImage: false,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
],
|
|
|
|
applicationName: 'myApp',
|
|
|
|
applicationDescription: 'the description',
|
|
|
|
abapPackage: 'myPackage',
|
|
|
|
transportRequestId: '002',
|
|
|
|
credentialsId: 'CM')
|
|
|
|
|
|
|
|
assertThat(calledWithParameters.dockerImage, is('ctsImage'))
|
|
|
|
assertThat(calledWithParameters.dockerOptions, is(['-o1', 'opt1', '-o2', 'opt2']))
|
|
|
|
assertThat(calledWithParameters.dockerEnvVars, is([env1: 'env1', env2: 'env2']))
|
|
|
|
assertThat(calledWithParameters.dockerPullImage, is(false))
|
|
|
|
}
|
|
|
|
|
2019-01-30 18:19:19 +02:00
|
|
|
@Test
|
|
|
|
public void uploadFileToTransportRequestRFCSanityChecksTest() {
|
|
|
|
|
|
|
|
thrown.expect(IllegalArgumentException)
|
|
|
|
thrown.expectMessage(allOf(
|
|
|
|
containsString('NO VALUE AVAILABLE FOR'),
|
|
|
|
containsString('applicationUrl'),
|
|
|
|
containsString('developmentInstance'),
|
|
|
|
containsString('developmentClient'),
|
|
|
|
containsString('applicationDescription'),
|
|
|
|
containsString('abapPackage'),
|
2019-02-07 09:26:31 +02:00
|
|
|
containsString('applicationName')))
|
2019-01-30 18:19:19 +02:00
|
|
|
|
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
|
|
|
transportRequestId: '123456', //no sanity check, can be read from git history
|
|
|
|
changeManagement: [type: 'RFC'],
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-12-14 16:24:03 +02:00
|
|
|
@Test
|
|
|
|
public void uploadFileToTransportRequestRFCSuccessTest() {
|
|
|
|
|
2021-09-13 14:14:38 +02:00
|
|
|
def calledWithParameters,
|
|
|
|
calledWithStepName,
|
|
|
|
calledWithMetadata,
|
|
|
|
calledWithCredentials
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
calledWithStepName = stepName
|
|
|
|
calledWithMetadata = metaData
|
|
|
|
calledWithCredentials = creds
|
|
|
|
}
|
|
|
|
)
|
2018-12-14 16:24:03 +02:00
|
|
|
|
2019-01-30 17:57:25 +02:00
|
|
|
nullScript.commonPipelineEnvironment.configuration =
|
|
|
|
[general:
|
|
|
|
[changeManagement:
|
|
|
|
[
|
|
|
|
endpoint: 'https://example.org/rfc'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2019-01-29 16:23:27 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
2019-01-30 11:16:38 +02:00
|
|
|
applicationUrl: 'http://example.org/blobstore/xyz.zip',
|
2019-02-14 10:36:51 +02:00
|
|
|
codePage: 'UTF-9',
|
2019-02-14 14:51:24 +02:00
|
|
|
acceptUnixStyleLineEndings: true,
|
2018-12-14 16:24:03 +02:00
|
|
|
transportRequestId: '123456',
|
2019-02-07 11:11:22 +02:00
|
|
|
changeManagement: [
|
|
|
|
type: 'RFC',
|
2019-02-07 12:46:45 +02:00
|
|
|
rfc: [
|
|
|
|
developmentClient: '002',
|
|
|
|
developmentInstance: '001'
|
|
|
|
]
|
|
|
|
],
|
2019-02-07 09:26:31 +02:00
|
|
|
applicationName: '42',
|
2018-12-14 16:24:03 +02:00
|
|
|
applicationDescription: 'Lorem ipsum',
|
2019-01-30 17:57:25 +02:00
|
|
|
abapPackage: 'XYZ',
|
2021-09-13 14:14:38 +02:00
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
2018-12-14 16:24:03 +02:00
|
|
|
|
2021-09-13 14:14:38 +02:00
|
|
|
assertThat(calledWithStepName, is('transportRequestUploadRFC'))
|
|
|
|
assertThat(calledWithParameters.applicationName, is('42'))
|
|
|
|
assertThat(calledWithParameters.applicationUrl, is('http://example.org/blobstore/xyz.zip'))
|
|
|
|
assertThat(calledWithParameters.endpoint, is('https://example.org/rfc'))
|
|
|
|
assertThat(calledWithParameters.uploadCredentialsId, is('CM'))
|
|
|
|
assertThat(calledWithParameters.instance, is('001'))
|
|
|
|
assertThat(calledWithParameters.client, is('002'))
|
|
|
|
assertThat(calledWithParameters.applicationDescription, is('Lorem ipsum'))
|
|
|
|
assertThat(calledWithParameters.abapPackage, is('XYZ'))
|
|
|
|
assertThat(calledWithParameters.codePage, is('UTF-9'))
|
|
|
|
assertThat(calledWithParameters.acceptUnixStyleLineEndings, is(true))
|
|
|
|
assertThat(calledWithParameters.failUploadOnWarning, is(true))
|
|
|
|
assertThat(calledWithParameters.transportRequestId, is('123456'))
|
2019-01-30 17:57:25 +02:00
|
|
|
}
|
2018-12-14 16:24:03 +02:00
|
|
|
|
2019-01-30 18:27:27 +02:00
|
|
|
@Test
|
|
|
|
public void uploadFileToTransportRequestRFCUploadFailsTest() {
|
|
|
|
|
|
|
|
thrown.expect(AbortException)
|
|
|
|
thrown.expectMessage('upload failed')
|
|
|
|
|
2021-09-13 14:14:38 +02:00
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
throw new AbortException('upload failed')
|
2019-01-30 18:27:27 +02:00
|
|
|
}
|
2021-09-13 14:14:38 +02:00
|
|
|
)
|
2019-01-30 18:27:27 +02:00
|
|
|
|
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
|
|
|
applicationUrl: 'http://example.org/blobstore/xyz.zip',
|
2019-02-14 10:36:51 +02:00
|
|
|
codePage: 'UTF-9',
|
2019-02-14 14:51:24 +02:00
|
|
|
acceptUnixStyleLineEndings: true,
|
2019-01-30 18:27:27 +02:00
|
|
|
transportRequestId: '123456',
|
2019-02-07 11:11:22 +02:00
|
|
|
changeManagement: [
|
|
|
|
type: 'RFC',
|
2019-02-07 12:46:45 +02:00
|
|
|
rfc: [
|
2019-02-12 14:44:09 +02:00
|
|
|
docker: [
|
|
|
|
image: 'rfc',
|
|
|
|
options: [],
|
|
|
|
envVars: [:],
|
2019-02-18 17:59:44 +02:00
|
|
|
pullImage: false,
|
2019-02-12 14:44:09 +02:00
|
|
|
],
|
2019-02-07 12:46:45 +02:00
|
|
|
developmentClient: '002',
|
|
|
|
developmentInstance: '001',
|
|
|
|
]
|
2019-02-07 11:11:22 +02:00
|
|
|
],
|
2019-02-07 09:26:31 +02:00
|
|
|
applicationName: '42',
|
2019-01-30 18:27:27 +02:00
|
|
|
applicationDescription: 'Lorem ipsum',
|
|
|
|
abapPackage: 'XYZ',
|
2021-09-13 14:14:38 +02:00
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
2019-01-30 18:27:27 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 10:29:43 +02:00
|
|
|
@Test
|
|
|
|
public void uploadFileToTransportRequestRFCDockerParams() {
|
|
|
|
|
|
|
|
def calledWithParameters
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
|
|
|
applicationUrl: 'http://example.org/blobstore/xyz.zip',
|
|
|
|
codePage: 'UTF-9',
|
|
|
|
acceptUnixStyleLineEndings: true,
|
|
|
|
transportRequestId: '123456',
|
|
|
|
changeManagement: [
|
|
|
|
type: 'RFC',
|
|
|
|
endpoint: 'https://example.org/cm',
|
|
|
|
rfc: [
|
|
|
|
developmentClient: '002',
|
|
|
|
developmentInstance: '001',
|
|
|
|
docker: [
|
|
|
|
image: 'rfcImage',
|
|
|
|
options: ['-o1', 'opt1', '-o2', 'opt2'],
|
|
|
|
envVars: [env1: 'env1', env2: 'env2'],
|
|
|
|
pullImage: false,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
],
|
|
|
|
applicationName: '42',
|
|
|
|
applicationDescription: 'Lorem ipsum',
|
|
|
|
abapPackage: 'XYZ',
|
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(calledWithParameters.dockerImage, is('rfcImage'))
|
|
|
|
assertThat(calledWithParameters.dockerOptions, is(['-o1', 'opt1', '-o2', 'opt2']))
|
|
|
|
assertThat(calledWithParameters.dockerEnvVars, is([env1: 'env1', env2: 'env2']))
|
|
|
|
assertThat(calledWithParameters.dockerPullImage, is(false))
|
|
|
|
}
|
|
|
|
|
2018-09-24 14:06:48 +02:00
|
|
|
@Test
|
|
|
|
public void uploadFileToTransportRequestSOLMANSuccessTest() {
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2019-01-22 10:22:15 +02:00
|
|
|
loggingRule.expect("[INFO] Uploading file '/path' to transport request '002' of change document '001'.")
|
|
|
|
loggingRule.expect("[INFO] File '/path' has been successfully uploaded to transport request '002' of change document '001'.")
|
2021-09-16 13:18:03 +02:00
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
def calledWithParameters,
|
|
|
|
calledWithStepName,
|
|
|
|
calledWithMetadata,
|
|
|
|
calledWithCredentials
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
calledWithStepName = stepName
|
|
|
|
calledWithMetadata = metaData
|
|
|
|
calledWithCredentials = creds
|
2018-07-13 15:13:58 +02:00
|
|
|
}
|
2021-09-13 13:31:43 +02:00
|
|
|
)
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
2018-07-13 14:40:29 +02:00
|
|
|
changeDocumentId: '001',
|
2018-07-13 15:13:58 +02:00
|
|
|
transportRequestId: '002',
|
2018-07-13 14:40:29 +02:00
|
|
|
applicationId: 'app',
|
2018-07-13 15:13:58 +02:00
|
|
|
filePath: '/path',
|
2021-09-13 13:31:43 +02:00
|
|
|
changeManagement: [
|
|
|
|
type: 'SOLMAN',
|
|
|
|
endpoint: 'https://example.org/cm',
|
|
|
|
clientOpts: '--client opts'
|
|
|
|
],
|
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
2018-07-13 15:13:58 +02:00
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
assertThat(calledWithStepName, is('transportRequestUploadSOLMAN'))
|
|
|
|
assertThat(calledWithParameters.changeDocumentId, is('001'))
|
|
|
|
assertThat(calledWithParameters.transportRequestId, is('002'))
|
|
|
|
assertThat(calledWithParameters.applicationId, is('app'))
|
|
|
|
assertThat(calledWithParameters.filePath, is('/path'))
|
|
|
|
assertThat(calledWithParameters.endpoint, is('https://example.org/cm'))
|
|
|
|
assertThat(calledWithParameters.cmClientOpts, is('--client opts'))
|
|
|
|
assertThat(calledWithParameters.uploadCredentialsId, is('CM'))
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|
2018-07-13 15:13:58 +02:00
|
|
|
|
2018-08-03 12:41:50 +02:00
|
|
|
@Test
|
2019-01-30 15:53:34 +02:00
|
|
|
public void uploadFileToTransportRequestSOLMANSuccessApplicationIdFromConfigurationTest() {
|
2018-08-03 12:41:50 +02:00
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
def calledWithParameters,
|
|
|
|
calledWithStepName,
|
|
|
|
calledWithMetadata,
|
|
|
|
calledWithCredentials
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
calledWithStepName = stepName
|
|
|
|
calledWithMetadata = metaData
|
|
|
|
calledWithCredentials = creds
|
|
|
|
}
|
|
|
|
)
|
2021-09-16 13:18:03 +02:00
|
|
|
|
2018-08-03 12:41:50 +02:00
|
|
|
nullScript.commonPipelineEnvironment.configuration.put(['steps',
|
|
|
|
[transportRequestUploadFile:
|
|
|
|
[applicationId: 'AppIdfromConfig']]])
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(
|
2018-08-03 12:41:50 +02:00
|
|
|
script: nullScript,
|
|
|
|
changeDocumentId: '001',
|
|
|
|
transportRequestId: '002',
|
|
|
|
filePath: '/path',
|
2021-09-13 13:31:43 +02:00
|
|
|
changeManagement: [
|
|
|
|
type: 'SOLMAN',
|
|
|
|
endpoint: 'https://example.org/cm',
|
|
|
|
clientOpts: '--client opts'
|
|
|
|
],
|
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
2018-08-03 12:41:50 +02:00
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
assertThat(calledWithParameters.applicationId, is('AppIdfromConfig'))
|
2018-08-03 12:41:50 +02:00
|
|
|
}
|
|
|
|
|
2018-07-31 15:43:25 +02:00
|
|
|
@Test
|
2019-01-30 15:53:34 +02:00
|
|
|
public void uploadFileToTransportRequestSOLMANFilePathFromParameters() {
|
2018-07-31 15:43:25 +02:00
|
|
|
|
|
|
|
// this one is not used when file path is provided via signature
|
|
|
|
nullScript.commonPipelineEnvironment.setMtarFilePath('/path2')
|
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
def calledWithParameters,
|
|
|
|
calledWithStepName,
|
|
|
|
calledWithMetadata,
|
|
|
|
calledWithCredentials
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
calledWithStepName = stepName
|
|
|
|
calledWithMetadata = metaData
|
|
|
|
calledWithCredentials = creds
|
2018-07-31 15:43:25 +02:00
|
|
|
}
|
2021-09-13 13:31:43 +02:00
|
|
|
)
|
2018-07-31 15:43:25 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
2018-07-31 15:43:25 +02:00
|
|
|
changeDocumentId: '001',
|
|
|
|
transportRequestId: '002',
|
|
|
|
applicationId: 'app',
|
2021-09-13 13:31:43 +02:00
|
|
|
filePath: '/pathByParam',
|
|
|
|
changeManagement: [
|
|
|
|
type: 'SOLMAN',
|
|
|
|
endpoint: 'https://example.org/cm',
|
|
|
|
clientOpts: '--client opts'
|
|
|
|
],
|
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
2018-07-31 15:43:25 +02:00
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
assertThat(calledWithParameters.filePath, is('/pathByParam'))
|
2018-07-31 15:43:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2019-01-30 15:53:34 +02:00
|
|
|
public void uploadFileToTransportRequestSOLMANFilePathFromCommonPipelineEnvironment() {
|
2018-07-31 15:43:25 +02:00
|
|
|
|
|
|
|
// this one is used since there is nothing in the signature
|
|
|
|
nullScript.commonPipelineEnvironment.setMtarFilePath('/path2')
|
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
def calledWithParameters,
|
|
|
|
calledWithStepName,
|
|
|
|
calledWithMetadata,
|
|
|
|
calledWithCredentials
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
calledWithStepName = stepName
|
|
|
|
calledWithMetadata = metaData
|
|
|
|
calledWithCredentials = creds
|
2018-07-31 15:43:25 +02:00
|
|
|
}
|
2021-09-13 13:31:43 +02:00
|
|
|
)
|
2018-07-31 15:43:25 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
2018-07-31 15:43:25 +02:00
|
|
|
changeDocumentId: '001',
|
|
|
|
transportRequestId: '002',
|
|
|
|
applicationId: 'app',
|
2021-09-13 13:31:43 +02:00
|
|
|
changeManagement: [
|
|
|
|
type: 'SOLMAN',
|
|
|
|
endpoint: 'https://example.org/cm',
|
|
|
|
clientOpts: '--client opts'
|
|
|
|
],
|
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
2018-06-20 11:46:28 +02:00
|
|
|
|
2021-09-13 13:31:43 +02:00
|
|
|
assertThat(calledWithParameters.filePath, is('/path2'))
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|
2018-07-13 15:13:58 +02:00
|
|
|
|
2021-09-21 10:29:43 +02:00
|
|
|
@Test
|
|
|
|
public void uploadFileToTransportRequestSOLMANDockerParams() {
|
|
|
|
|
|
|
|
// this one is used since there is nothing in the signature
|
|
|
|
nullScript.commonPipelineEnvironment.setMtarFilePath('/path2')
|
|
|
|
|
|
|
|
def calledWithParameters
|
|
|
|
|
|
|
|
helper.registerAllowedMethod('piperExecuteBin', [Map, String, String, List], {
|
|
|
|
params, stepName, metaData, creds ->
|
|
|
|
calledWithParameters = params
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
|
|
|
changeDocumentId: '001',
|
|
|
|
transportRequestId: '002',
|
|
|
|
applicationId: 'app',
|
|
|
|
filePath: '/pathByParam',
|
|
|
|
changeManagement: [
|
|
|
|
type: 'SOLMAN',
|
|
|
|
endpoint: 'https://example.org/cm',
|
|
|
|
clientOpts: '--client opts',
|
|
|
|
solman: [
|
|
|
|
docker: [
|
|
|
|
image: 'solmanImage',
|
|
|
|
options: ['-o1', 'opt1', '-o2', 'opt2'],
|
|
|
|
envVars: [env1: 'env1', env2: 'env2'],
|
|
|
|
pullImage: false,
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
credentialsId: 'CM'
|
|
|
|
)
|
|
|
|
|
|
|
|
assertThat(calledWithParameters.dockerImage, is('solmanImage'))
|
|
|
|
assertThat(calledWithParameters.dockerOptions, is(['-o1', 'opt1', '-o2', 'opt2']))
|
|
|
|
assertThat(calledWithParameters.dockerEnvVars, is([env1: 'env1', env2: 'env2']))
|
|
|
|
assertThat(calledWithParameters.dockerPullImage, is(false))
|
|
|
|
}
|
|
|
|
|
2018-09-18 14:49:06 +02:00
|
|
|
@Test
|
|
|
|
public void invalidBackendTypeTest() {
|
|
|
|
thrown.expect(AbortException)
|
2018-12-14 16:24:03 +02:00
|
|
|
thrown.expectMessage('Invalid backend type: \'DUMMY\'. Valid values: [SOLMAN, CTS, RFC, NONE]. ' +
|
2018-09-18 14:49:06 +02:00
|
|
|
'Configuration: \'changeManagement/type\'.')
|
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
2018-09-18 14:49:06 +02:00
|
|
|
applicationId: 'app',
|
|
|
|
filePath: '/path',
|
|
|
|
changeManagement: [type: 'DUMMY'])
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-28 13:45:26 +02:00
|
|
|
@Test
|
|
|
|
public void cmIntegrationSwichtedOffTest() {
|
|
|
|
|
2019-01-22 10:22:15 +02:00
|
|
|
loggingRule.expect('[INFO] Change management integration intentionally switched off.')
|
2018-09-28 13:45:26 +02:00
|
|
|
|
2019-01-22 10:25:42 +02:00
|
|
|
stepRule.step.transportRequestUploadFile(script: nullScript,
|
2018-09-28 13:45:26 +02:00
|
|
|
changeManagement: [type: 'NONE'])
|
|
|
|
}
|
|
|
|
|
2018-06-20 11:46:28 +02:00
|
|
|
}
|