chore: update go tests to use our hosted trivy-db and trivy-java-db images (#2754)

There are 2 remaining exceptions that I am aware of:
1. The tests under test/blackbox/cve.bats
2. One of the cli tests checking the server attempts download of the databases
from the default url

Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
Andrei Aaron
2024-11-01 23:14:52 +02:00
committed by GitHub
parent 30ecceda8c
commit da923ae232
4 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -1070,7 +1070,7 @@ func TestServeSearchEnabled(t *testing.T) {
})
}
func TestServeSearchEnabledCVE(t *testing.T) {
func TestServeSearchEnabledDefaultCVEDB(t *testing.T) {
oldArgs := os.Args
defer func() { os.Args = oldArgs }()
@@ -319,7 +319,7 @@ func TestImageScannable(t *testing.T) {
storeController.DefaultStore = store
scanner := NewScanner(storeController, metaDB, "ghcr.io/project-zot/trivy-db",
"ghcr.io/aquasecurity/trivy-java-db", log)
"ghcr.io/project-zot/trivy-java-db", log)
Convey("Valid image should be scannable", t, func() {
result, err := scanner.IsImageFormatScannable("repo1", "valid")
@@ -352,8 +352,8 @@ func TestImageScannable(t *testing.T) {
})
}
func TestDefaultTrivyDBUrl(t *testing.T) {
Convey("Test trivy DB download from default location", t, func() {
func TestTrivyDBUrl(t *testing.T) {
Convey("Test trivy DB download", t, func() {
// Create temporary directory
rootDir := t.TempDir()
@@ -385,8 +385,11 @@ func TestDefaultTrivyDBUrl(t *testing.T) {
err = meta.ParseStorage(metaDB, storeController, log)
So(err, ShouldBeNil)
scanner := NewScanner(storeController, metaDB, "ghcr.io/aquasecurity/trivy-db",
"ghcr.io/aquasecurity/trivy-java-db", log)
// Ideally we would want to also test the default urls
// But we are getting `response status code 429: toomanyrequests` from
// `ghcr.io/aquasecurity/trivy-db` and `ghcr.io/aquasecurity/trivy-java-db`
scanner := NewScanner(storeController, metaDB, "ghcr.io/project-zot/trivy-db",
"ghcr.io/project-zot/trivy-java-db", log)
ctx := context.Background()
@@ -261,7 +261,7 @@ func TestVulnerableLayer(t *testing.T) {
So(err, ShouldBeNil)
scanner := trivy.NewScanner(storeController, metaDB, "ghcr.io/project-zot/trivy-db",
"ghcr.io/aquasecurity/trivy-java-db", log)
"ghcr.io/project-zot/trivy-java-db", log)
err = scanner.UpdateDB(context.Background())
So(err, ShouldBeNil)