mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-16 05:16:08 +02:00
fix(curl): Remove --insecure flag from curl when downlaoding Piper binary (#5179)
* remove --insecure flag from binary download * remove --insecure flag from binary download * adjust unit tests
This commit is contained in:
parent
10f535c8fa
commit
f044ef106d
@ -83,7 +83,7 @@ class PiperGoUtils implements Serializable {
|
||||
private boolean downloadGoBinary(url) {
|
||||
|
||||
try {
|
||||
def httpStatus = steps.sh(returnStdout: true, script: "curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out '%{http_code}' --output ${piperExecutable} '${url}'")
|
||||
def httpStatus = steps.sh(returnStdout: true, script: "curl --silent --retry 5 --retry-max-time 240 --location --write-out '%{http_code}' --output ${piperExecutable} '${url}'")
|
||||
|
||||
if (httpStatus == '200') {
|
||||
steps.sh(script: "chmod +x ${piperExecutable}")
|
||||
|
@ -63,11 +63,11 @@ class PiperGoUtilsTest extends BasePiperTest {
|
||||
})
|
||||
|
||||
shellCallRule.setReturnValue('[ -x ./piper ]', 1)
|
||||
shellCallRule.setReturnValue('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\'', '200')
|
||||
shellCallRule.setReturnValue('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\'', '200')
|
||||
|
||||
piperGoUtils.unstashPiperBin()
|
||||
assertThat(shellCallRule.shell.size(), is(4))
|
||||
assertThat(shellCallRule.shell[1].toString(), is('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\''))
|
||||
assertThat(shellCallRule.shell[1].toString(), is('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\''))
|
||||
assertThat(shellCallRule.shell[2].toString(), is('chmod +x piper'))
|
||||
assertThat(shellCallRule.shell[3].toString(), is('./piper version'))
|
||||
}
|
||||
@ -84,11 +84,11 @@ class PiperGoUtilsTest extends BasePiperTest {
|
||||
})
|
||||
|
||||
shellCallRule.setReturnValue('[ -x ./piper ]', 1)
|
||||
shellCallRule.setReturnValue('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/testTag/piper\'', '200')
|
||||
shellCallRule.setReturnValue('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/testTag/piper\'', '200')
|
||||
|
||||
piperGoUtils.unstashPiperBin()
|
||||
assertThat(shellCallRule.shell.size(), is(4))
|
||||
assertThat(shellCallRule.shell[1].toString(), is('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/testTag/piper\''))
|
||||
assertThat(shellCallRule.shell[1].toString(), is('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/testTag/piper\''))
|
||||
assertThat(shellCallRule.shell[2].toString(), is('chmod +x piper'))
|
||||
assertThat(shellCallRule.shell[3].toString(), is('./piper version'))
|
||||
}
|
||||
@ -101,8 +101,8 @@ class PiperGoUtilsTest extends BasePiperTest {
|
||||
|
||||
shellCallRule.setReturnValue('[ -x ./piper ]', 1)
|
||||
shellCallRule.setReturnValue('./piper version', "1.2.3")
|
||||
shellCallRule.setReturnValue('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/notAvailable/piper\'', '404')
|
||||
shellCallRule.setReturnValue('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\'', '200')
|
||||
shellCallRule.setReturnValue('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/notAvailable/piper\'', '404')
|
||||
shellCallRule.setReturnValue('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\'', '200')
|
||||
|
||||
// this mocks utils.unstash - mimic stash not existing
|
||||
helper.registerAllowedMethod("unstash", [String.class], { stashFileName ->
|
||||
@ -112,8 +112,8 @@ class PiperGoUtilsTest extends BasePiperTest {
|
||||
piperGoUtils.unstashPiperBin()
|
||||
assertThat(shellCallRule.shell.size(), is(5))
|
||||
assertThat(shellCallRule.shell[0].toString(), is('[ -x ./piper ]'))
|
||||
assertThat(shellCallRule.shell[1].toString(), is('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/notAvailable/piper\''))
|
||||
assertThat(shellCallRule.shell[2].toString(), is('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\''))
|
||||
assertThat(shellCallRule.shell[1].toString(), is('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/notAvailable/piper\''))
|
||||
assertThat(shellCallRule.shell[2].toString(), is('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\''))
|
||||
assertThat(shellCallRule.shell[3].toString(), is('chmod +x piper'))
|
||||
assertThat(shellCallRule.shell[4].toString(), is ('./piper version'))
|
||||
}
|
||||
@ -124,8 +124,8 @@ class PiperGoUtilsTest extends BasePiperTest {
|
||||
piperGoUtils.metaClass.getLibrariesInfo = {-> return [[name: 'piper-lib-os', version: 'notAvailable']]}
|
||||
|
||||
shellCallRule.setReturnValue('[ -x ./piper ]', 1)
|
||||
shellCallRule.setReturnValue('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/notAvailable/piper\'', '404')
|
||||
shellCallRule.setReturnValue('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\'', '500')
|
||||
shellCallRule.setReturnValue('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/notAvailable/piper\'', '404')
|
||||
shellCallRule.setReturnValue('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\'', '500')
|
||||
|
||||
helper.registerAllowedMethod("unstash", [String.class], { stashFileName ->
|
||||
return []
|
||||
@ -141,8 +141,8 @@ class PiperGoUtilsTest extends BasePiperTest {
|
||||
piperGoUtils.metaClass.getLibrariesInfo = {-> return [[name: 'piper-lib-os', version: 'notAvailable']]}
|
||||
|
||||
shellCallRule.setReturnValue('[ -x ./piper ]', 1)
|
||||
shellCallRule.setReturnValue('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/notAvailable/piper\'', '404')
|
||||
shellCallRule.setReturnValue('curl --insecure --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\'', '500')
|
||||
shellCallRule.setReturnValue('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/download/notAvailable/piper\'', '404')
|
||||
shellCallRule.setReturnValue('curl --silent --retry 5 --retry-max-time 240 --location --write-out \'%{http_code}\' --output piper \'https://github.com/SAP/jenkins-library/releases/latest/download/piper\'', '500')
|
||||
|
||||
helper.registerAllowedMethod("unstash", [String.class], { stashFileName ->
|
||||
return []
|
||||
|
Loading…
Reference in New Issue
Block a user