mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-30 05:59:39 +02:00
Fix chars in checkmarx test, improve development.md (#1154)
* Fix chars in test * Update DEVELOPMENT.md * Update DEVELOPMENT.md * Update DEVELOPMENT.md
This commit is contained in:
parent
cead027bfb
commit
3139255312
@ -7,6 +7,7 @@
|
||||
1. [Generating step framework](#generating-step-framework)
|
||||
1. [Logging](#logging)
|
||||
1. [Error handling](#error-handling)
|
||||
1. [Debugging](#debugging)
|
||||
|
||||
## Getting started
|
||||
|
||||
@ -168,3 +169,31 @@ We use [github.com/pkg/errors](https://github.com/pkg/errors) for that.
|
||||
Unit tests are done using basic `golang` means.
|
||||
|
||||
Additionally we encourage you to use [github.com/stretchr/testify/assert](https://github.com/stretchr/testify/assert) in order to have slimmer assertions if you like.
|
||||
|
||||
## Debugging
|
||||
|
||||
Debugging can be initiated with VS code fairly easily. Compile the binary with spcific compiler flags to turn off optimizations `go build -gcflags "all=-N -l" -o piper.exe`.
|
||||
|
||||
Modify the `launch.json` located in folder `.vscode` of your project root to point with `program` exatly to the binary that you just built with above command - must be an absolute path. In addition add any arguments required for the execution of the Piper step to `args`. What is separated with a blank on the command line must go into a separate string.
|
||||
|
||||
```javascript
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "exec",
|
||||
"program": "C:/CF@HCP/git/jenkins-library-public/piper.exe",
|
||||
"env": {},
|
||||
"args": ["checkmarxExecuteScan", "--password", "abcd", "--username", "1234", "--projectName", "testProject4711", "--serverUrl", "https://cx.wdf.sap.corp/"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Finally set your breakpoints and use the `Launch` button in the VS code UI to start debugging.
|
||||
|
@ -229,9 +229,9 @@ func TestZipFolder(t *testing.T) {
|
||||
t.Run("zip files", func(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "test zip files")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temporary directory")
|
||||
t.Fatal("Failed to create temporary directory")
|
||||
}
|
||||
// clean up tmp dir
|
||||
// clean up tmp dir
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
ioutil.WriteFile(filepath.Join(dir, "abcd.go"), []byte{byte(1), byte(2), byte(3)}, 0700)
|
||||
@ -275,9 +275,9 @@ func TestGetDetailedResults(t *testing.T) {
|
||||
</CxXMLResults>`)}
|
||||
dir, err := ioutil.TempDir("", "test detailed results")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temporary directory")
|
||||
t.Fatal("Failed to create temporary directory")
|
||||
}
|
||||
// clean up tmp dir
|
||||
// clean up tmp dir
|
||||
defer os.RemoveAll(dir)
|
||||
result := getDetailedResults(sys, filepath.Join(dir, "abc.xml"), 2635)
|
||||
assert.Equal(t, "2", result["ProjectId"], "Project ID incorrect")
|
||||
@ -294,9 +294,9 @@ func TestRunScan(t *testing.T) {
|
||||
options := checkmarxExecuteScanOptions{ProjectName: "TestExisting", VulnerabilityThresholdUnit: "absolute", FullScanCycle: "2", Incremental: true, FullScansScheduled: true, Preset: "10048", TeamID: "16", VulnerabilityThresholdEnabled: true, GeneratePdfReport: true}
|
||||
workspace, err := ioutil.TempDir("", "workspace1")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
}
|
||||
// clean up tmp dir
|
||||
// clean up tmp dir
|
||||
defer os.RemoveAll(workspace)
|
||||
|
||||
influx := checkmarxExecuteScanInflux{}
|
||||
@ -312,9 +312,9 @@ func TestRunScanWOtherCycle(t *testing.T) {
|
||||
options := checkmarxExecuteScanOptions{VulnerabilityThresholdUnit: "percentage", FullScanCycle: "3", Incremental: true, FullScansScheduled: true, Preset: "SAP_JS_Default", TeamID: "16", VulnerabilityThresholdEnabled: true, GeneratePdfReport: true}
|
||||
workspace, err := ioutil.TempDir("", "workspace2")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
}
|
||||
// clean up tmp dir
|
||||
// clean up tmp dir
|
||||
defer os.RemoveAll(workspace)
|
||||
|
||||
influx := checkmarxExecuteScanInflux{}
|
||||
@ -330,9 +330,9 @@ func TestRunScanForPullRequest(t *testing.T) {
|
||||
options := checkmarxExecuteScanOptions{PullRequestName: "Test_PR-19", ProjectName: "Test_PR-19", VulnerabilityThresholdUnit: "percentage", FullScanCycle: "3", Incremental: true, FullScansScheduled: true, Preset: "SAP_JS_Default", TeamID: "16", VulnerabilityThresholdEnabled: true, GeneratePdfReport: true, AvoidDuplicateProjectScans: false}
|
||||
workspace, err := ioutil.TempDir("", "workspace3")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
}
|
||||
// clean up tmp dir
|
||||
// clean up tmp dir
|
||||
defer os.RemoveAll(workspace)
|
||||
|
||||
influx := checkmarxExecuteScanInflux{}
|
||||
@ -348,9 +348,9 @@ func TestRunScanForPullRequestProjectNew(t *testing.T) {
|
||||
options := checkmarxExecuteScanOptions{PullRequestName: "PR-17", ProjectName: "Test_PR-19", VulnerabilityThresholdUnit: "percentage", FullScanCycle: "3", Incremental: true, FullScansScheduled: true, Preset: "10048", TeamName: "OpenSource/Cracks/15", VulnerabilityThresholdEnabled: true, GeneratePdfReport: true}
|
||||
workspace, err := ioutil.TempDir("", "workspace4")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
}
|
||||
// clean up tmp dir
|
||||
// clean up tmp dir
|
||||
defer os.RemoveAll(workspace)
|
||||
|
||||
influx := checkmarxExecuteScanInflux{}
|
||||
@ -386,9 +386,9 @@ func TestRunScanHighViolationPercentage(t *testing.T) {
|
||||
options := checkmarxExecuteScanOptions{VulnerabilityThresholdUnit: "percentage", VulnerabilityThresholdResult: "FAILURE", VulnerabilityThresholdHigh: 100, FullScanCycle: "10", FullScansScheduled: true, Preset: "10048", TeamID: "16", VulnerabilityThresholdEnabled: true, GeneratePdfReport: true}
|
||||
workspace, err := ioutil.TempDir("", "workspace5")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
}
|
||||
// clean up tmp dir
|
||||
// clean up tmp dir
|
||||
defer os.RemoveAll(workspace)
|
||||
|
||||
influx := checkmarxExecuteScanInflux{}
|
||||
@ -430,9 +430,9 @@ func TestRunScanHighViolationAbsolute(t *testing.T) {
|
||||
options := checkmarxExecuteScanOptions{VulnerabilityThresholdUnit: "absolute", VulnerabilityThresholdResult: "FAILURE", VulnerabilityThresholdLow: 1, FullScanCycle: "10", FullScansScheduled: true, Preset: "10048", TeamID: "16", VulnerabilityThresholdEnabled: true, GeneratePdfReport: true}
|
||||
workspace, err := ioutil.TempDir("", "workspace6")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
t.Fatal("Failed to create temporary workspace directory")
|
||||
}
|
||||
// clean up tmp dir
|
||||
// clean up tmp dir
|
||||
defer os.RemoveAll(workspace)
|
||||
|
||||
influx := checkmarxExecuteScanInflux{}
|
||||
|
Loading…
x
Reference in New Issue
Block a user