1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-16 11:09:33 +02:00
sap-jenkins-library/test/groovy/com/sap/piper/BashUtilsTest.groovy
Daniel Kurzynski 6e26d78047
Improve neo deploy (#440)
The following features were added:
Lock resources for deployment
New parameters: environment, vmArguments
Assert password does not start with @
Link to cloud cockpit
Only execute rolling update if app is running
Show logs if deployment failed
Restart app after normal deployment
Use neo namespace for parameters
Align parameter names with neo sdk: size, application, source
Remove vmSize check as done by the tool itself
2019-01-28 11:32:24 +01:00

48 lines
1.5 KiB
Groovy

package com.sap.piper
import org.junit.Assert
import org.junit.Test
class BashUtilsTest {
@Test
void escapeFilePath() {
// Given: A Windows-style file path C:\some\path
def input = 'C:\\some\\path'
// When we escape the string
def result = BashUtils.quoteAndEscape(input)
// Then the string is surrounded by single quotes 'C:\some\path'
def expected = "'C:\\some\\path'"
Assert.assertEquals(expected, result)
}
@Test
void escapeUri() {
// Given: An URI with single quotes values http://www.sap.com?$filter='234'
def input = "http://www.sap.com?\$filter='234'"
// When we escape the string
def result = BashUtils.quoteAndEscape(input)
// Then the input string is surrounded by single quotes and each original ' is replaced by '"'"'
// 'http://www.sap.com?$filter='"'"'234'"'"''
def expected = "'http://www.sap.com?\$filter='\"'\"'234'\"'\"''"
Assert.assertEquals(expected, result)
}
@Test
void escapePassword() {
// Given: A random generated password VQ5r\%*h"49'Ch>Jj?
def input = "VQ5r\\%*h\"49'Ch>Jj?"
// When we escape the string
def result = BashUtils.quoteAndEscape(input)
// Then the input string is surrounded by single quotes and each original ' is replaced by '"'"'
// 'VQ5r\%*h"49'"'"'Ch>Jj?'
def expected = "'VQ5r\\%*h\"49'\"'\"'Ch>Jj?'"
Assert.assertEquals(expected, result)
}
}