Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/rsa keys #59

Merged
merged 17 commits into from
Sep 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: added signImage test for RSA
A simple test locke behind an env variable to test whether an RSA key can be
used to sign a container image. In the future, this test should be an autonomous integration test
and not be connected to the busybox image created during the E2E preparation
puffitos committed Sep 15, 2024
commit 769ac73f081dc13979d3acfa137cc1688d2b31d9
25 changes: 20 additions & 5 deletions test/framework/cosign_test.go
Original file line number Diff line number Diff line change
@@ -33,22 +33,37 @@ func TestFramework_CreateRSAKeyPair(t *testing.T) {
t.Fatal("failed to create public key")
}

coPrivStat, err := os.Stat("import-cosign.key")
coPrivStat, err := os.Stat(fmt.Sprintf("%s-%s.key", tt.name, ImportKeySuffix))

if err != nil || coPrivStat.Size() == 0 {
t.Fatal("failed to create cosign private key")
}
coPubStat, err := os.Stat("import-cosign.pub")
coPubStat, err := os.Stat(fmt.Sprintf("%s-%s.pub", tt.name, ImportKeySuffix))

if err != nil || coPubStat.Size() == 0 {
t.Fatal("failed to create cosign public key")
}

// pub keys should be the same
pubBytes, err := os.ReadFile(fmt.Sprintf("%s.pub", tt.name))
if err != nil {
t.Fatal(err)
}
coPubBytes, err := os.ReadFile(fmt.Sprintf("%s-%s.pub", tt.name, ImportKeySuffix))
if err != nil {
t.Fatal(err)
}
if string(pubBytes) != string(coPubBytes) {
t.Fatal("public keys do not match. expected: ", string(pubBytes), " got: ", string(coPubBytes))
}
})
}
}

// TestFramework_SignContainer_RSA generates an RSA keypair and signs a container image
// with the private key. The key is generated using the CreateRSAKeyPair function.
func TestFramework_SignContainer_RSA(t *testing.T) {
if os.Getenv("COSIGN_INTEGRATION") == "" {
if os.Getenv("COSIGN_E2E") == "" {
t.Skip()
}

@@ -70,7 +85,7 @@ func TestFramework_SignContainer_RSA(t *testing.T) {
}

f.SignContainer(t, SignOptions{
KeyName: fmt.Sprintf("%s-%s", name, ImportKeySuffix),
Image: "busybox",
KeyPath: fmt.Sprintf("%s-%s.key", name, ImportKeySuffix),
Image: "k3d-registry.localhost:5000/busybox:first",
})
}