Documentation ¶
Index ¶
- Constants
- Variables
- func AddConfigJsonOption(configJsonName string) utils.HostOption
- func AddKeyOption(keyName, certName string) utils.HostOption
- func AddKeyPairs(dir, keyName, certName string) error
- func AddPlugin(pluginPath string) utils.HostOption
- func AddTrustPolicyOption(trustpolicyName string) utils.HostOption
- func AddTrustStoreOption(namedstore string, srcCertPath string) utils.HostOption
- func AuthOption(username, password string) utils.HostOption
- func BaseOptions() []utils.HostOption
- func BaseOptionsWithExperimental() []utils.HostOption
- func CreateNotationDirOption() utils.HostOption
- func EnableExperimental() utils.HostOption
- func Host(options []utils.HostOption, fn CoreTestFunc)
- func HostInGithubAction(options []utils.HostOption, fn CoreTestFunc)
- func HostWithOCILayout(options []utils.HostOption, fn OCILayoutTestFunc)
- func OldNotation(options ...utils.HostOption) *utils.ExecOpts
- func Opts(options ...utils.HostOption) []utils.HostOption
- func TestLoginOptions() []utils.HostOption
- type Artifact
- type CoreTestFunc
- type ExternalKey
- type KeySuite
- type OCILayout
- type OCILayoutTestFunc
- type Registry
- type SigningKeys
- type X509KeyPair
Constants ¶
const ( NotationDirName = "notation" TrustPolicyName = "trustpolicy.json" TrustStoreDirName = "truststore" TrustStoreTypeCA = "ca" PluginDirName = "plugins" PluginName = "e2e-plugin" ConfigJsonName = "config.json" )
const ( SigningKeysFileName = "signingkeys.json" LocalKeysDirName = "localkeys" LocalConfigJsonsDirName = "configjsons" )
const ArtifactTypeNotation = "application/vnd.cncf.notary.signature"
Variables ¶
var ( // NotationBinPath is the notation binary path. NotationBinPath string // NotationOldBinPath is the path of an old version notation binary for // testing forward compatibility. NotationOldBinPath string NotationE2EPluginPath string NotationE2EPluginTarGzPath string NotationE2EMaliciousPluginArchivePath string NotationE2EConfigPath string NotationE2ELocalKeysDir string NotationE2ETrustPolicyDir string NotationE2EConfigJsonDir string )
var ( OCILayoutPath string TestRepoUri string TestTag string RegistryStoragePath string )
var TestRegistry = Registry{}
Functions ¶
func AddConfigJsonOption ¶
func AddConfigJsonOption(configJsonName string) utils.HostOption
AddConfigJsonOption adds a valid config.json for testing.
func AddKeyOption ¶
func AddKeyOption(keyName, certName string) utils.HostOption
AddKeyOption adds the test signingkeys.json, key and cert files to the notation directory.
func AddKeyPairs ¶
AddKeyPairs creates the signingkeys.json file and the localkeys directory with e2e.key and e2e.crt
func AddPlugin ¶
func AddPlugin(pluginPath string) utils.HostOption
AddPlugin adds a pluginkeys.json config file and installs an e2e-plugin.
func AddTrustPolicyOption ¶
func AddTrustPolicyOption(trustpolicyName string) utils.HostOption
AddTrustPolicyOption adds a valid trust policy for testing.
func AddTrustStoreOption ¶
func AddTrustStoreOption(namedstore string, srcCertPath string) utils.HostOption
AddTrustStoreOption adds the test cert to the trust store.
func AuthOption ¶
func AuthOption(username, password string) utils.HostOption
AuthOption sets the auth environment variables for notation.
func BaseOptions ¶
func BaseOptions() []utils.HostOption
BaseOptions returns a list of base Options for a valid notation. testing environment.
func BaseOptionsWithExperimental ¶
func BaseOptionsWithExperimental() []utils.HostOption
func CreateNotationDirOption ¶
func CreateNotationDirOption() utils.HostOption
CreateNotationDirOption creates the notation directory in temp user dir.
func EnableExperimental ¶
func EnableExperimental() utils.HostOption
EnableExperimental enables experimental features.
func Host ¶
func Host(options []utils.HostOption, fn CoreTestFunc)
Host creates a virtualized notation testing host by modify the "XDG_CONFIG_HOME" environment variable of the Executor.
options is the required testing environment options fn is the callback function containing the testing logic.
func HostInGithubAction ¶
func HostInGithubAction(options []utils.HostOption, fn CoreTestFunc)
HostInGithubAction only run the test in GitHub Actions.
The booting script will setup TLS reverse proxy and TLS certificate for Github Actions environment.
func HostWithOCILayout ¶
func HostWithOCILayout(options []utils.HostOption, fn OCILayoutTestFunc)
HostWithOCILayout creates a virtualized notation testing host by modify the "XDG_CONFIG_HOME" environment variable of the Executor. It generates isolated OCI layout in the testing host.
options is the required testing environment options fn is the callback function containing the testing logic.
func OldNotation ¶
func OldNotation(options ...utils.HostOption) *utils.ExecOpts
OldNotation create an old version notation ExecOpts in a VirtualHost for testing forward compatibility.
func Opts ¶
func Opts(options ...utils.HostOption) []utils.HostOption
Opts is a grammar sugar to generate a list of HostOption.
func TestLoginOptions ¶
func TestLoginOptions() []utils.HostOption
TestLoginOptions returns the BaseOptions with removing AuthOption and adding ConfigOption. testing environment.
Types ¶
type Artifact ¶
type Artifact struct { *Registry // Repo is the repository name. Repo string // Tag is the tag of the artifact. Tag string // Digest is the digest of the artifact. Digest string }
Artifact describes an artifact in a repository.
func GenerateArtifact ¶
GenerateArtifact generates a new artifact with a new repository by copying the source repository in the OCILayoutPath to be a new repository.
func (*Artifact) DomainReferenceWithDigest ¶
DomainReferenceWithDigest returns the <domainHost>/<Repository>@<alg>:<digest> for testing --insecure-registry flag and TLS request.
func (*Artifact) ReferenceWithDigest ¶
ReferenceWithDigest returns the <registryHost>/<Repository>@<alg>:<digest>
func (*Artifact) ReferenceWithTag ¶
ReferenceWithTag returns the <registryHost>/<Repository>:<Tag>
func (*Artifact) SignatureDescriptors ¶
func (r *Artifact) SignatureDescriptors() ([]ocispec.Descriptor, error)
SignatureManifest returns the manifest of the artifact.
type CoreTestFunc ¶
type CoreTestFunc func(notation *utils.ExecOpts, artifact *Artifact, vhost *utils.VirtualHost)
CoreTestFunc is the test function running in a VirtualHost.
notation is an Executor isolated by $XDG_CONFIG_HOME. artifact is a generated artifact in a new repository. vhost is the VirtualHost instance.
type ExternalKey ¶
type ExternalKey struct { ID string `json:"id,omitempty"` PluginName string `json:"pluginName,omitempty"` PluginConfig map[string]string `json:"pluginConfig,omitempty"` }
ExternalKey contains the necessary information to delegate the signing operation to the named plugin.
type KeySuite ¶
type KeySuite struct { Name string `json:"name"` *X509KeyPair *ExternalKey }
KeySuite is a named key suite.
type OCILayout ¶
type OCILayout struct { // Path is the path of the OCI layout directory. Path string // Tag is the tag of artifact in the OCI layout. Tag string // Digest is the digest of artifact in the OCI layout. Digest string }
OCILayout is a OCI layout directory for
func GenerateOCILayout ¶
GenerateOCILayout creates a new OCI layout in a temporary directory.
func (*OCILayout) ReferenceWithDigest ¶
ReferenceWithDigest returns the reference with digest.
func (*OCILayout) ReferenceWithTag ¶
ReferenceWithTag returns the reference with tag.
type OCILayoutTestFunc ¶
type OCILayoutTestFunc func(notation *utils.ExecOpts, ocilayout *OCILayout, vhost *utils.VirtualHost)
OCILayoutTestFunc is the test function running in a VirtualHost with isolated OCI layout for each test case.
notation is an Executor isolated by $XDG_CONFIG_HOME. vhost is the VirtualHost instance.
type Registry ¶
type Registry struct { // Host is the registry host. Host string // Username is the username to access the registry. Username string // Password is the password to access the registry. Password string // DomainHost is a registry host, separate from localhost, used for testing // the --insecure-registry flag. // // If the host is localhost, Notation connects via plain HTTP. For // non-localhost hosts, Notation defaults to HTTPS. However, users can // enforce HTTP by setting the --insecure-registry flag. DomainHost string }
func (*Registry) CreateArtifact ¶
CreateArtifact copies a local OCI layout to the registry to create a new artifact with a new repository.
srcRepoName is the repo name in ./testdata/registry/oci_layout folder. destRepoName is the repo name to be created in the registry.
type SigningKeys ¶
SigningKeys reflects the signingkeys.json file.
type X509KeyPair ¶
type X509KeyPair struct { KeyPath string `json:"keyPath"` CertificatePath string `json:"certPath"` }
X509KeyPair contains the paths of a public/private key pair files.