33package tests
44
55import (
6- "encoding/json"
7- "github.com/jfrog/jfrog-client-go/http/jfroghttpclient"
8- "github.com/jfrog/jfrog-client-go/xsc/services"
9- xscutils "github.com/jfrog/jfrog-client-go/xsc/services/utils"
10- "github.com/stretchr/testify/assert"
11- "github.com/stretchr/testify/require"
126 "net/http"
137 "net/http/httptest"
148 "os"
159 "strings"
1610 "testing"
11+
12+ "github.com/jfrog/jfrog-client-go/http/jfroghttpclient"
13+ "github.com/jfrog/jfrog-client-go/xsc/services"
14+ xscutils "github.com/jfrog/jfrog-client-go/xsc/services/utils"
15+ "github.com/stretchr/testify/assert"
16+ "github.com/stretchr/testify/require"
1717)
1818
1919const configProfileWithoutRepo = "default-test-profile"
@@ -29,13 +29,7 @@ func TestGetConfigurationProfileByName(t *testing.T) {
2929
3030 configProfile , err := configProfileService .GetConfigurationProfileByName (configProfileWithoutRepo )
3131 assert .NoError (t , err )
32-
33- profileFileContent , err := os .ReadFile ("testdata/configprofile/configProfileExample.json" )
34- assert .NoError (t , err )
35- var configProfileForComparison services.ConfigProfile
36- err = json .Unmarshal (profileFileContent , & configProfileForComparison )
37- assert .NoError (t , err )
38- assert .Equal (t , & configProfileForComparison , configProfile )
32+ assert .Equal (t , getComparisonConfigProfile (), configProfile )
3933}
4034
4135func TestGetConfigurationProfileByUrl (t * testing.T ) {
@@ -49,14 +43,60 @@ func TestGetConfigurationProfileByUrl(t *testing.T) {
4943
5044 configProfile , err := configProfileService .GetConfigurationProfileByUrl (mockServer .URL )
5145 assert .NoError (t , err )
46+ assert .Equal (t , getComparisonConfigProfile (), configProfile )
5247
53- profileFileContent , err := os .ReadFile ("testdata/configprofile/configProfileExample.json" )
54- assert .NoError (t , err )
55- var configProfileForComparison services.ConfigProfile
56- err = json .Unmarshal (profileFileContent , & configProfileForComparison )
57- assert .NoError (t , err )
58- assert .Equal (t , & configProfileForComparison , configProfile )
48+ }
5949
50+ func getComparisonConfigProfile () * services.ConfigProfile {
51+ return & services.ConfigProfile {
52+ ProfileName : "default-profile" ,
53+ GeneralConfig : services.GeneralConfig {
54+ ScannersDownloadPath : "https://repo.example.com/releases" ,
55+ GeneralExcludePatterns : []string {"*.log*" , "*.tmp*" },
56+ FailUponAnyScannerError : true ,
57+ },
58+ FrogbotConfig : services.FrogbotConfig {
59+ AggregateFixes : true ,
60+ HideSuccessBannerForNoIssues : false ,
61+ BranchNameTemplate : "frogbot-${IMPACTED_PACKAGE}-${BRANCH_NAME_HASH}" ,
62+ PrTitleTemplate : "[🐸 Frogbot] Upgrade {IMPACTED_PACKAGE} to {FIX_VERSION}" ,
63+ CommitMessageTemplate : "Upgrade {IMPACTED_PACKAGE} to {FIX_VERSION}" ,
64+ ShowSecretsAsPrComment : false ,
65+ CreateAutoFixPr : true ,
66+ IncludeVulnerabilitiesAndViolations : false ,
67+ },
68+ Modules : []services.Module {
69+ {
70+ ModuleName : "default-module" ,
71+ PathFromRoot : "." ,
72+ ScanConfig : services.ScanConfig {
73+ ScaScannerConfig : services.ScaScannerConfig {
74+ EnableScaScan : true ,
75+ ExcludePatterns : []string {"**/build/**" },
76+ },
77+ ContextualAnalysisScannerConfig : services.CaScannerConfig {
78+ EnableCaScan : true ,
79+ ExcludePatterns : []string {"**/docs/**" },
80+ },
81+ SastScannerConfig : services.SastScannerConfig {
82+ EnableSastScan : true ,
83+ ExcludePatterns : []string {"**/_test.go/**" },
84+ ExcludeRules : []string {"xss-injection" },
85+ },
86+ SecretsScannerConfig : services.SecretsScannerConfig {
87+ EnableSecretsScan : true ,
88+ ValidateSecrets : true ,
89+ ExcludePatterns : []string {"**/_test.go/**" },
90+ EnableCustomSecrets : true ,
91+ },
92+ IacScannerConfig : services.IacScannerConfig {
93+ EnableIacScan : true ,
94+ ExcludePatterns : []string {"*.tfstate" },
95+ },
96+ },
97+ },
98+ },
99+ }
60100}
61101
62102// TODO backwards compatability can be removed once old Xsc service is removed from all servers
0 commit comments