Skip to content

Commit b22d8cf

Browse files
committed
Add Docker login in test and fix panic on parse error
1 parent 958ee03 commit b22d8cf

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ jobs:
309309
- name: Install and Setup Dependencies
310310
uses: ./.github/actions/install-and-setup
311311

312-
- name: Docker Login
313-
if: runner.os == 'Linux'
314-
run: echo "${{ secrets.PLATFORM_ADMIN_TOKEN }}" | docker login ${{ secrets.CONTAINER_REGISTRY }} -u admin --password-stdin
315-
316312
# Test
317313
- name: Run tests
318314
run: go test ${{ env.GO_COMMON_TEST_ARGS }} --test.curation --test.enrich --ci.runId=${{ runner.os }}-sec-test

curation_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"net/http"
77
"net/http/httptest"
8+
"os/exec"
89
"path/filepath"
910
"strings"
1011
"sync"
@@ -128,6 +129,12 @@ func TestDockerCurationAudit(t *testing.T) {
128129
SetInteractive(false)
129130
assert.NoError(t, configCmd.Run())
130131

132+
loginCmd := exec.Command("docker", "login", *securityTests.ContainerRegistry, "-u", "admin", "--password-stdin")
133+
loginCmd.Stdin = strings.NewReader(*securityTests.JfrogAccessToken)
134+
if loginOutput, err := loginCmd.CombinedOutput(); err != nil {
135+
t.Skipf("Skipping Docker curation test - Docker login failed: %s", string(loginOutput))
136+
}
137+
131138
testCli := integration.GetXrayTestCli(cli.GetJfrogCliSecurityApp(), false)
132139

133140
testImage := fmt.Sprintf("%s/%s/%s", *securityTests.ContainerRegistry, "docker-curation", "ganodndentcom/drupal")
@@ -140,8 +147,10 @@ func TestDockerCurationAudit(t *testing.T) {
140147
t.Skip("Skipping Docker curation test - Docker is not running")
141148
}
142149

143-
var results []curation.PackageStatus
144150
bracketIndex := strings.Index(output, "[")
151+
require.GreaterOrEqual(t, bracketIndex, 0, "Expected JSON array in output, got: %s", output)
152+
153+
var results []curation.PackageStatus
145154
err = json.Unmarshal([]byte(output[bracketIndex:]), &results)
146155
require.NoError(t, err)
147156

0 commit comments

Comments
 (0)