2024-07-01 14:14:23 +01:00
|
|
|
//go:build e2e
|
|
|
|
|
|
2024-08-12 16:54:44 -05:00
|
|
|
package oci_test
|
2024-07-01 14:14:23 +01:00
|
|
|
|
|
|
|
|
import (
|
2024-09-09 14:22:17 +01:00
|
|
|
"context"
|
2024-07-01 14:14:23 +01:00
|
|
|
"testing"
|
|
|
|
|
|
2024-08-12 14:49:52 -05:00
|
|
|
"github.com/docker/attest/internal/test"
|
2024-09-02 16:17:50 +01:00
|
|
|
"github.com/docker/attest/oci"
|
2024-07-01 14:14:23 +01:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestRegistryAuth(t *testing.T) {
|
2024-09-02 16:17:50 +01:00
|
|
|
attIdx, err := oci.IndexFromPath(test.UnsignedTestImage(".."))
|
2024-07-01 14:14:23 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
// test cases for ecr, gcr and dockerhub
|
|
|
|
|
testCases := []struct {
|
|
|
|
|
Image string
|
|
|
|
|
}{
|
|
|
|
|
{Image: "175142243308.dkr.ecr.us-east-1.amazonaws.com/e2e-test-image:latest"},
|
|
|
|
|
{Image: "docker/image-signer-verifier-test:latest"},
|
|
|
|
|
}
|
2024-09-09 14:22:17 +01:00
|
|
|
ctx := context.Background()
|
2024-07-01 14:14:23 +01:00
|
|
|
for _, tc := range testCases {
|
|
|
|
|
t.Run(tc.Image, func(t *testing.T) {
|
2024-09-09 14:22:17 +01:00
|
|
|
err := oci.PushIndexToRegistry(ctx, attIdx.Index, tc.Image)
|
2024-07-01 14:14:23 +01:00
|
|
|
require.NoError(t, err)
|
2024-09-09 14:22:17 +01:00
|
|
|
_, err = oci.IndexFromRemote(ctx, tc.Image)
|
2024-07-01 14:14:23 +01:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|