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

Plugin integration with verification workflow #101

Merged
merged 14 commits into from
Aug 19, 2022
69 changes: 57 additions & 12 deletions internal/mock/mocks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package mock

import _ "embed"
import (
_ "embed"
nsigner "github.com/notaryproject/notation-core-go/signer"
)

import (
"context"
Expand All @@ -20,6 +23,9 @@ var MockCaInvalidSigEnv []byte
//go:embed testdata/sa_valid_sig_env.json
var MockSaValidSigEnv []byte

//go:embed testdata/ca_plugin_sig_env.json
var MockCaPluginSigEnv []byte // extended attributes are "SomeKey":"SomeValue", "io.cncf.notary.verificationPlugin":"plugin-name"

//go:embed testdata/sa_invalid_sig_env.json
var MockSaInvalidSigEnv []byte

Expand All @@ -29,16 +35,30 @@ var MockCaExpiredSigEnv []byte
//go:embed testdata/sa_expired_sig_env.json
var MockSaExpiredSigEnv []byte

//go:embed testdata/sa_plugin_sig_env.json
var MockSaPluginSigEnv []byte // extended attributes are "SomeKey":"SomeValue", "io.cncf.notary.verificationPlugin":"plugin-name"

var (
SampleArtifactUri = "registry.acme-rockets.io/software/net-monitor@sha256:73c803930ea3ba1e54bc25c2bdc53edd0284c62ed651fe7b00369da519a3c333"
SampleDigest = digest.FromString("sha256:73c803930ea3ba1e54bc25c2bdc53edd0284c62ed651fe7b00369da519a3c333")
Annotations = map[string]string{"key": "value"}
SampleArtifactUri = "registry.acme-rockets.io/software/net-monitor@sha256:60043cf45eaebc4c0867fea485a039b598f52fd09fd5b07b0b2d2f88fad9d74e"
SampleDigest = digest.Digest("sha256:60043cf45eaebc4c0867fea485a039b598f52fd09fd5b07b0b2d2f88fad9d74e")
Annotations = map[string]string{"key": "value"}
ImageDescriptor = notation.Descriptor{
MediaType: "application/vnd.docker.distribution.manifest.v2+json",
Digest: SampleDigest,
Size: 528,
Annotations: nil,
}
JwsSigEnvDescriptor = notation.Descriptor{
MediaType: "application/jose+json",
Digest: SampleDigest,
Size: 100,
Annotations: Annotations,
}
PluginExtendedCriticalAttribute = nsigner.Attribute{
Key: "SomeKey",
Critical: true,
Value: "SomeValue",
}
)

type Repository struct {
Expand All @@ -52,7 +72,7 @@ type Repository struct {

func NewRepository() Repository {
return Repository{
ResolveResponse: JwsSigEnvDescriptor,
ResolveResponse: ImageDescriptor,
ListSignatureManifestsResponse: []registry.SignatureManifest{{
Blob: JwsSigEnvDescriptor,
Annotations: Annotations,
Expand All @@ -77,15 +97,40 @@ func (t Repository) PutSignatureManifest(ctx context.Context, signature []byte,
return notation.Descriptor{}, registry.SignatureManifest{}, nil
}

type PluginManager struct{}
type PluginManager struct {
PluginCapabilities []plugin.Capability
GetPluginError error
PluginRunnerLoadError error
PluginRunnerExecuteResponse interface{}
PluginRunnerExecuteError error
}

type PluginRunner struct {
Response interface{}
Error error
}

func NewPluginManager() PluginManager {
return PluginManager{}
func (pr PluginRunner) Run(ctx context.Context, req plugin.Request) (interface{}, error) {
return pr.Response, pr.Error
}

func (t PluginManager) Get(ctx context.Context, name string) (*manager.Plugin, error) {
return nil, nil
func (pm PluginManager) Get(ctx context.Context, name string) (*manager.Plugin, error) {
return &manager.Plugin{
Metadata: plugin.Metadata{
Name: "plugin-name",
Description: "for mocking in unit tests",
Version: "1.0.0",
URL: ".",
SupportedContractVersions: []string{"1.0"},
Capabilities: pm.PluginCapabilities,
},
Path: ".",
Err: nil,
}, pm.GetPluginError
}
func (t PluginManager) Runner(name string) (plugin.Runner, error) {
return nil, nil
func (pm PluginManager) Runner(name string) (plugin.Runner, error) {
return PluginRunner{
Response: pm.PluginRunnerExecuteResponse,
Error: pm.PluginRunnerExecuteError,
}, pm.PluginRunnerLoadError
}
8 changes: 4 additions & 4 deletions internal/mock/testdata/ca_expired_sig_env.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"payload": "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YMA4GA1UdDwEB/wQEAwICBDATBgNVHSUEDDAKBggrBgEFBQcDAzASBgNVHRMBAf8ECDAGAQH/AgEBMB0GA1UdDgQWBBS5FZjt9UsEPkcKrStrnjSpTq4kDTANBgkqhkiG9w0BAQsFAAOCAYEAKtxfv12LzM85bxOMp5++pIDa6eMcBaurYbAM2yC9B6LuHf0JGeFdNqt4Fw38Ajooj2vWMWBrARVEZRVqTC5+ZSN2meGBXBXlT4n8FdEdmv+05iwVYdmDFp8FKeoOZZZF23u+r2OrazJo1ufWmoSI2P0lEfZQQFQElltWu3QH+OLOWXJmB7KbLKyheelGK5XhtAYYapRdW4sKJ398ybpv5C1oALCcTwoSmvH8wW5J4/gjmhKICYh2goMauf0lesdxj+0His7E8blOWrUmfOB5dp73XawLKcd/UxHN8zAPC08LDL9NMcihn3ZHKi7/dtkiV2iSaDPD1ChSGdqfXIysYqOhYoktgAfBZ43CWnqQhgB8NezRKdOStYC3P2AGJW18irxxTRp2CO+gnXEcyhyr+cvyf0j8MkRSaHLXzjIrECu8BUitB6sKughdN13fs5t5SIiO6foeFdvIpZFFKO8s+4oTOSDCos2WFoC+8TZS6r583OtFLmywl1HRgQkobGgw"
],
"io.cncf.notary.SigningAgent": "Notation/1.0.0"
},
"signature": "mj-c1cVKCDUl9811YMvY5uRweSL1JeRBAVreAHJoBfULmbF2pMB3vVQOKYkY2rDnlUIqIrh6GiBG65tgr0ZCXeGvGWvL651FtCXhqwx3sJpqOLmoxZMV_Nbom0VBoQWAyyPNCn5j0Z4Gp8o4KMsbv2DseIC9nsli9VZaNJkXU2rLZquQALYUI-InxsHM2hCjo-HG_U9zZlm9XH4bZl9fDIg-O-Id78JBP2ugdn2WW4XshFmWJiuJbHN59gDaW5HPHzPpj1VvUS-sScKTm3juH2fImgyysgtX2uw8c79sEf4uO007cVgHXrKeSwtNiDP3qQZaEzHCHcFsucUQKTIz1dcA519s3rYFAMegL-Ki8Vv-OGVQwIc_17zCrQl0QklFZCRvwdEGkKPysPmZ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