Documentation ¶
Index ¶
- Constants
- func CreateRestsMockServer(testHandler restsTestHandler) *httptest.Server
- func CreateXrayRestsMockServer(testHandler restsTestHandler) (*httptest.Server, *config.ServerDetails)
- func CreateXscRestsMockServer(t *testing.T, testHandler restsTestHandler) (*httptest.Server, *config.ServerDetails, ...)
- func GetValidationCountErrMsg(what, where string, exactMatch bool, expectedCount, actualCount int) string
- func ValidateCommandJsonOutput(t *testing.T, params ValidationParams)
- func ValidateCommandSarifOutput(t *testing.T, params ValidationParams)
- func ValidateCommandSimpleJsonOutput(t *testing.T, params ValidationParams)
- func ValidateCommandSummaryOutput(t *testing.T, params ValidationParams)
- func ValidateContent(t *testing.T, exactMatch bool, validations ...Validation) bool
- func ValidatePointersAndNotNil[T any](t *testing.T, exactMatch bool, pair PointerValidation[T]) bool
- func ValidateSarifIssuesCount(t *testing.T, params ValidationParams, report *sarif.Report)
- func ValidateSarifReport(t *testing.T, exactMatch bool, expected, actual *sarif.Report)
- func ValidateScanResponseIssuesCount(t *testing.T, params ValidationParams, content ...services.ScanResponse)
- func ValidateScanResponses(t *testing.T, exactMatch bool, expected, actual []services.ScanResponse)
- func ValidateSimpleJsonIssuesCount(t *testing.T, params ValidationParams, results formats.SimpleJsonResults)
- func ValidateSimpleJsonResults(t *testing.T, exactMatch bool, expected, actual formats.SimpleJsonResults)
- func ValidateSummaryIssuesCount(t *testing.T, params ValidationParams, results formats.ResultsSummary)
- func VerifyJsonResults(t *testing.T, content string, params ValidationParams)
- func VerifySimpleJsonResults(t *testing.T, content string, params ValidationParams)
- func XrayServer(t *testing.T, params MockServerParams) (*httptest.Server, *config.ServerDetails)
- func XscServer(t *testing.T, params MockServerParams) (*httptest.Server, *config.ServerDetails)
- type CountValidation
- type ListValidation
- type MockServerParams
- type NumberValidation
- type PointerValidation
- type StringValidation
- type Validation
- type ValidationParams
Constants ¶
const ( TestMsi = "27e175b8-e525-11ee-842b-7aa2c69b8f1f" TestScaScanId = "3d90ec4b-cf33-4846-6831-4bf9576f2235" // TestMoreInfoUrl = "https://www.jfrog.com" TestPlatformUrl = "https://test-platform-url.jfrog.io/" TestMoreInfoUrl = "https://test-more-info-url.jfrog.io/" TestConfigProfileName = "default-profile" )
const ( SastToolName = "🐸 JFrog SAST" IacToolName = "JFrog Terraform scanner" // #nosec G101 -- Not credentials. SecretsToolName = "JFrog Secrets scanner" )
const (
ErrCountFormat = "Expected%s %d %s in %s, but got %d %s."
)
Variables ¶
This section is empty.
Functions ¶
func CreateRestsMockServer ¶
Create mock server to test REST APIs. testHandler - The HTTP handler of the test
func CreateXrayRestsMockServer ¶
func CreateXrayRestsMockServer(testHandler restsTestHandler) (*httptest.Server, *config.ServerDetails)
func CreateXscRestsMockServer ¶
func CreateXscRestsMockServer(t *testing.T, testHandler restsTestHandler) (*httptest.Server, *config.ServerDetails, artifactory.ArtifactoryServicesManager)
func ValidateCommandJsonOutput ¶
func ValidateCommandJsonOutput(t *testing.T, params ValidationParams)
Validation on SCA content only (No JAS in this content) Actual (and optional Expected) content should be a slice of services.ScanResponse in the validation params
func ValidateCommandSarifOutput ¶
func ValidateCommandSarifOutput(t *testing.T, params ValidationParams)
Validate sarif report according to the expected values and issue counts in the validation params. Value/Actual content should be a *sarif.Report in the validation params If ExactResultsMatch is true, the validation will check exact values and not only the 'equal or grater' counts / existence of expected attributes. For Integration tests with JFrog API, ExactResultsMatch should be set to false.
func ValidateCommandSimpleJsonOutput ¶
func ValidateCommandSimpleJsonOutput(t *testing.T, params ValidationParams)
Validate simple-json report results according to the expected values and issue counts in the validation params. Actual/Expected content should be a formats.SimpleJsonResults in the validation params. If Expected is provided, the validation will check if the Actual content matches the expected results. If ExactResultsMatch is true, the validation will check exact values and not only the 'equal or grater' counts / existence of expected attributes. (For Integration tests with JFrog API, ExactResultsMatch should be set to false)
func ValidateCommandSummaryOutput ¶
func ValidateCommandSummaryOutput(t *testing.T, params ValidationParams)
Validate summary results according to the expected values and issue counts in the validation params. Content/Expected should be a formats.ResultsSummary in the validation params. If Expected is provided, the validation will check if the Actual content matches the expected results. If ExactResultsMatch is true, the validation will check exact values and not only the 'equal or grater' counts / existence of expected attributes. (For Integration tests with JFrog API, ExactResultsMatch should be set to false)
func ValidateContent ¶
func ValidateContent(t *testing.T, exactMatch bool, validations ...Validation) bool
ValidateContent validates the content of the given Validations. If exactMatch is true, the content must match exactly. If at least one validation fails, the function returns false and stops validating the rest of the pairs.
func ValidateSarifIssuesCount ¶
func ValidateSarifIssuesCount(t *testing.T, params ValidationParams, report *sarif.Report)
Validate sarif report according to the expected counts in the validation params. Actual content should be a *sarif.Report in the validation params. If Expected is provided, the validation will check if the Actual content matches the expected results. If ExactResultsMatch is true, the validation will check exact values and not only the 'equal or grater' counts / existence of expected attributes. (For Integration tests with JFrog API, ExactResultsMatch should be set to false)
func ValidateSarifReport ¶
func ValidateScanResponseIssuesCount ¶
func ValidateScanResponseIssuesCount(t *testing.T, params ValidationParams, content ...services.ScanResponse)
func ValidateScanResponses ¶
func ValidateScanResponses(t *testing.T, exactMatch bool, expected, actual []services.ScanResponse)
func ValidateSimpleJsonIssuesCount ¶
func ValidateSimpleJsonIssuesCount(t *testing.T, params ValidationParams, results formats.SimpleJsonResults)
Validate simple-json report results according to the expected counts in the validation params. Actual content should be a formats.SimpleJsonResults in the validation params. If Expected is provided, the validation will check if the Actual content matches the expected results. If ExactResultsMatch is true, the validation will check exact values and not only the 'equal or grater' counts / existence of expected attributes. (For Integration tests with JFrog API, ExactResultsMatch should be set to false)
func ValidateSimpleJsonResults ¶
func ValidateSimpleJsonResults(t *testing.T, exactMatch bool, expected, actual formats.SimpleJsonResults)
func ValidateSummaryIssuesCount ¶
func ValidateSummaryIssuesCount(t *testing.T, params ValidationParams, results formats.ResultsSummary)
func VerifyJsonResults ¶
func VerifyJsonResults(t *testing.T, content string, params ValidationParams)
Validate SCA content only (No JAS in this content) according to the expected values and issue counts in the validation params. Content/Expected should be a []services.ScanResponse in the validation params. If Expected is provided, the validation will check if the Actual content matches the expected results. If ExactResultsMatch is true, the validation will check exact values and not only the 'equal or grater' counts / existence of expected attributes. (For Integration tests with JFrog API, ExactResultsMatch should be set to false)
func VerifySimpleJsonResults ¶
func VerifySimpleJsonResults(t *testing.T, content string, params ValidationParams)
Validate simple-json report results according to the expected values and issue counts in the validation params. Content/Expected should be a formats.SimpleJsonResults in the validation params. If Expected is provided, the validation will check if the Actual content matches the expected results. If ExactResultsMatch is true, the validation will check exact values and not only the 'equal or grater' counts / existence of expected attributes. (For Integration tests with JFrog API, ExactResultsMatch should be set to false)
func XrayServer ¶
func XrayServer(t *testing.T, params MockServerParams) (*httptest.Server, *config.ServerDetails)
func XscServer ¶
func XscServer(t *testing.T, params MockServerParams) (*httptest.Server, *config.ServerDetails)
Types ¶
type CountValidation ¶
CountValidation validates the content of the given numbers. Not ExactMatch: The actual content must be greater or equal to the expected content.
type ListValidation ¶
ListValidation validates the content of the given lists. Not ExactMatch: The expected content must be subset of the actual content.
type MockServerParams ¶ added in v1.13.2
type NumberValidation ¶
NumberValidation validates the content of the given numbers. Not ExactMatch: The actual content must not be zero if the expected content is not zero.
type PointerValidation ¶
PointerValidation validates the content of the given pointers. Not ExactMatch: The actual content must not be nil if the expected content is not nil.
type StringValidation ¶
Validate a string content. Not ExactMatch: The actual content must not be empty if the expected content is not empty.
type Validation ¶
type Validation interface { Validate(t *testing.T, exactMatch bool) bool ErrMsgs(t *testing.T) []string }
Validation allows to validate/assert a content with expected values. Using the Validation interfaces implementations allows you to assert content for exact value or not exact match (changes base on the implementation).
type ValidationParams ¶
type ValidationParams struct { // The actual content to verify. Actual interface{} // If provided, the test will check if the content matches the expected results. Expected interface{} // If provided, the test will check exact values and not only the minimum values / existence. ExactResultsMatch bool // Expected issues for each type to check if the content has the correct amount of issues. Vulnerabilities int Licenses int SecurityViolations int LicenseViolations int OperationalViolations int Applicable int Undetermined int NotCovered int NotApplicable int MissingContext int Inactive int Sast int Iac int Secrets int }
ValidationParams holds validation/assertion parameters for tests.