1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-16 05:16:08 +02:00

fortifyExecuteScan: Fix report download (#2244)

* Fix report download

* Update fortifyExecuteScan.go

* Update fortifyExecuteScan_test.go

* Update fortify.go

Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
This commit is contained in:
Sven Merk 2020-10-27 13:12:31 +01:00 committed by GitHub
parent d0f987c7b5
commit 9d737575aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -394,7 +394,7 @@ func generateAndDownloadQGateReport(config fortifyExecuteScanOptions, sys fortif
}
status = report.Status
}
data, err := sys.DownloadReportFile(config.ReportDownloadEndpoint, projectVersion.ID)
data, err := sys.DownloadReportFile(config.ReportDownloadEndpoint, report.ID)
if err != nil {
return []byte{}, fmt.Errorf("Failed to download Q-Gate Report: %w", err)
}

View File

@ -243,7 +243,7 @@ func (f *fortifyMock) GetReportDetails(id int64) (*models.SavedReport, error) {
func (f *fortifyMock) UploadResultFile(endpoint, file string, projectVersionID int64) error {
return nil
}
func (f *fortifyMock) DownloadReportFile(endpoint string, projectVersionID int64) ([]byte, error) {
func (f *fortifyMock) DownloadReportFile(endpoint string, reportID int64) ([]byte, error) {
return []byte("abcd"), nil
}
func (f *fortifyMock) DownloadResultFile(endpoint string, projectVersionID int64) ([]byte, error) {

View File

@ -60,7 +60,7 @@ type System interface {
GenerateQGateReport(projectID, projectVersionID, reportTemplateID int64, projectName, projectVersionName, reportFormat string) (*models.SavedReport, error)
GetReportDetails(id int64) (*models.SavedReport, error)
UploadResultFile(endpoint, file string, projectVersionID int64) error
DownloadReportFile(endpoint string, projectVersionID int64) ([]byte, error)
DownloadReportFile(endpoint string, reportID int64) ([]byte, error)
DownloadResultFile(endpoint string, projectVersionID int64) ([]byte, error)
}
@ -677,7 +677,7 @@ func (sys *SystemInstance) uploadResultFileContent(endpoint, file string, fileCo
}
// DownloadFile downloads a file from Fortify backend
func (sys *SystemInstance) downloadFile(endpoint, method, acceptType, tokenType string, projectVersionID int64) ([]byte, error) {
func (sys *SystemInstance) downloadFile(endpoint, method, acceptType, tokenType string, fileID int64) ([]byte, error) {
token, err := sys.getFileToken(tokenType)
if err != nil {
return nil, errors.Wrap(err, "Error fetching file token")
@ -690,7 +690,7 @@ func (sys *SystemInstance) downloadFile(endpoint, method, acceptType, tokenType
header.Add("Accept", acceptType)
header.Add("Content-Type", "application/form-data")
body := url.Values{
"id": {fmt.Sprintf("%v", projectVersionID)},
"id": {fmt.Sprintf("%v", fileID)},
"mat": {token.Token},
}
var response *http.Response
@ -711,8 +711,8 @@ func (sys *SystemInstance) downloadFile(endpoint, method, acceptType, tokenType
}
// DownloadReportFile downloads a report file from Fortify backend
func (sys *SystemInstance) DownloadReportFile(endpoint string, projectVersionID int64) ([]byte, error) {
data, err := sys.downloadFile(endpoint, http.MethodGet, "application/octet-stream", "REPORT_FILE", projectVersionID)
func (sys *SystemInstance) DownloadReportFile(endpoint string, reportID int64) ([]byte, error) {
data, err := sys.downloadFile(endpoint, http.MethodGet, "application/octet-stream", "REPORT_FILE", reportID)
if err != nil {
return nil, errors.Wrap(err, "Error downloading report file")
}