Documentation
¶
Overview ¶
Package support holds server-route test data and request helpers shared by independently runnable protocol test packages. Production code must not import this package.
Role ¶
Test support, outside the modules, for the server-assembly suites under test/server and for the router's guards in internal/app.
Inputs ¶
- The stores, authentication and format packages the fixtures are built from.
Outputs ¶
- The route inventory of each format (DockerRoutes, GoRoutes, HelmRoutes, MavenRoutes, NPMRoutes, NuGetRoutes, PyPIRoutes, TerraformRoutes, TerraformBackendRoutes). Each format's suite holds its status and principal tables to its inventory, and the router's guards in internal/app count those routes as covered; DockerHandwrittenRoutes and NPMGeneratedRoutes give those guards the parts they treat apart.
- Request helpers (Do, Basic, Bearer, ArtifactoryError) and seeding (Seed, over any SeedStore, with the fast TestHash and CheapHash, the hash of the shared password).
- The artifacts module's Repositories and Layouts, bound as the server binds them, for the tests of other modules that apply through them, with the artifacts record and store port those tests seed or wrap (Item, RepoFilter and RepoStore).
- Format fixtures: npm publish bodies and tarballs, NuGet packages and PDBs, Helm charts, OCI images and manifests, Terraform repositories and the backend keyring, and the gzip-compressed tar archives of Conan and CRAN (TarGz).
References ¶
- Decision 0015: docs/research/decisions/0015-testing-and-acceptance.md.
- docs/testing/server-test-ownership.md: how CI selection gives the package an owner.
- https://github.com/weaveplatform/artifactweave/issues/673
Status ¶
Implemented P9b (issue 673).
Index ¶
- Constants
- Variables
- func ArtifactoryError(t *testing.T, rec *httptest.ResponseRecorder) (int, string)
- func Basic(user, password string) map[string]string
- func Bearer(token string) map[string]string
- func Do(t *testing.T, h http.Handler, method, path string, headers map[string]string, ...) *httptest.ResponseRecorder
- func DockerHandwrittenRoutes() map[string]bool
- func DockerRoutes() map[string]bool
- func GoRoutes() map[string]bool
- func HelmChart(name, version string) []byte
- func HelmRoutes() map[string]bool
- func Layouts() artifactsapi.Layouts
- func MavenRoutes() map[string]bool
- func NPMGeneratedRoutes() map[string]bool
- func NPMPublishBody(name, version string) string
- func NPMRoutes() map[string]bool
- func NPMTarballOf(name, version string) []byte
- func NuGetForm(pkg []byte) string
- func NuGetPDBPackage(id string, pdb []byte) []byte
- func NuGetPackage(id, version, more string) []byte
- func NuGetPortablePDB() []byte
- func NuGetRoutes() map[string]bool
- func NuGetSymbolsPackage(id, version string) []byte
- func NuGetWindowsPDB() []byte
- func PushImage(t *testing.T, db registry.Store, blobs blob.Store, c repo.Config, ...)
- func PyPIRoutes() map[string]bool
- func RegistryManifest(note string) string
- func Repositories(db SeedStore) artifactsapi.Repositories
- func SHA256Digest(body string) string
- func Seed(t *testing.T, db SeedStore)
- func SeedHelmCharter(t *testing.T, db SeedStore, passwordHash []byte)
- func TarGz(tb testing.TB, entries map[string]string) string
- func TerraformBackendKeys(t *testing.T) *crypt.Keyring
- func TerraformBackendRepos() []repo.Config
- func TerraformBackendRoutes() map[string]bool
- func TerraformProviderRepos() []repo.Config
- func TerraformRegistryRepos() []repo.Config
- func TerraformRoutes() map[string]bool
- type Item
- type RepoFilter
- type RepoStore
- type SeedStore
Constants ¶
const RegistryConfig = `{"architecture":"amd64","os":"linux","config":{"Labels":{"team":"matrix"}}}`
RegistryConfig is the image config blob that RegistryManifest references and PushImage stores.
Variables ¶
var CheapHash = func() []byte { h, err := authn.HashPasswordWith(TestHash, "pw") if err != nil { panic(err) } return h }()
CheapHash is the hash of the test principals' shared password, "pw".
var RegistryLayer = SHA256Digest("registry layer")
RegistryLayer is the digest of the one layer RegistryManifest lists, the 14 bytes "registry layer". Nothing here stores that layer: a test uploads it before it pushes a manifest that needs it.
var TestHash = authn.HashParams{MemoryKiB: 64, Time: 1, Threads: 1}
TestHash keeps server-route authentication tests fast under the race detector.
Functions ¶
func ArtifactoryError ¶
ArtifactoryError returns the status and message of the error in rec's Artifactory error envelope, {"errors":[{"status":...,"message":...}]}. It fails t unless rec is application/json and holds exactly one error.
func Basic ¶
Basic returns the Authorization header that authenticates as user with password over HTTP Basic, in the form Do takes.
func Bearer ¶
Bearer returns the Authorization header that presents token as a Bearer credential, in the form Do takes.
func Do ¶
func Do( t *testing.T, h http.Handler, method, path string, headers map[string]string, body string, ) *httptest.ResponseRecorder
Do serves one request to h in process and returns the recorded response. It sets each of headers on the request and sends body, or no body at all when body is empty.
func DockerHandwrittenRoutes ¶
DockerHandwrittenRoutes excludes the generated JFrog REST operations.
func DockerRoutes ¶
DockerRoutes is the Docker and OCI server-assembly route inventory. The standalone Docker status and principal tables each cover every route.
func GoRoutes ¶
GoRoutes is the implemented Go module protocol route inventory. The root package retains registration guards while test/server/artifacts/golang runs status and principal assertions independently.
func HelmRoutes ¶
HelmRoutes is the classic Helm protocol route inventory. Helm OCI routes have their own registry package and test owner.
func Layouts ¶
func Layouts() artifactsapi.Layouts
Layouts is the artifacts module's Layouts, bound as the server binds it: the layout engine's check, which reads and writes nothing.
func MavenRoutes ¶
MavenRoutes is the route inventory asserted by the independent Maven server-assembly package. The item routes are shared with other formats; the two REST routes are Maven-specific.
func NPMGeneratedRoutes ¶
NPMGeneratedRoutes is the subset implemented by generated Artifactory operations. The root stub guard must skip these after their status rows move.
func NPMPublishBody ¶
NPMPublishBody returns the JSON body npm publish sends for name at version: the packument with the latest dist-tag, the dist shasum (SHA-1) and sha512 integrity of NPMTarballOf, and that tarball as a base64 attachment.
func NPMRoutes ¶
NPMRoutes names the implemented npm protocol and migration operations. The root registration guards and standalone npm status/matrix suites share this inventory without importing each other's test package.
func NPMTarballOf ¶
NPMTarballOf returns a gzipped package tarball whose only file is package/package.json, naming name and version.
func NuGetForm ¶
NuGetForm returns pkg as the multipart form that nuget push sends, written in the route tables' body notation: "multipart:", the boundary, a newline, then the form. The suites turn that prefix into the request's multipart/form-data Content-Type with the same boundary.
func NuGetPDBPackage ¶
NuGetPDBPackage returns a symbol package for id at version 1.0.0 that holds pdb as lib/net10.0/App.pdb, for the symbol server's indexing tests.
func NuGetPackage ¶
NuGetPackage returns a .nupkg for id at version, as an uncompressed zip: an empty _rels/.rels, the nuspec and a stand-in lib/net8.0 assembly. more is written inside the nuspec's metadata element, so a test can add elements such as packageTypes.
func NuGetPortablePDB ¶
func NuGetPortablePDB() []byte
NuGetPortablePDB returns a minimal Portable PDB that the symbol server can index. Its symbol key is 030201000504070608090A0B0C0D0E0F followed by FFFFFFFF, which stands in for the age in a Portable PDB's key.
func NuGetRoutes ¶
NuGetRoutes lists the implemented NuGet route patterns. The root package uses this inventory for registration/stub checks; test/server/artifacts/nuget runs their status and principal assertions independently.
func NuGetSymbolsPackage ¶
NuGetSymbolsPackage returns a NuGetPackage whose nuspec declares the SymbolsPackage package type, which marks a .snupkg symbol package.
func NuGetWindowsPDB ¶
func NuGetWindowsPDB() []byte
NuGetWindowsPDB returns a minimal Windows (MSF 7.00) PDB that the symbol server can index. Its symbol key is the GUID of NuGetPortablePDB's key followed by the age, 2A.
func PushImage ¶
func PushImage( t *testing.T, db registry.Store, blobs blob.Store, c repo.Config, name, tag, body string, )
PushImage stores RegistryConfig in the image and pushes an OCI manifest to the tag; RegistryLayer must already be present in the image.
func PyPIRoutes ¶
PyPIRoutes is the implemented PyPI protocol inventory. The root server package guards registration; test/server/artifacts/pypi checks status and principals.
func RegistryManifest ¶
RegistryManifest is the OCI image manifest used by the shared Docker and Helm OCI server-assembly fixtures. note varies its digest.
func Repositories ¶
func Repositories(db SeedStore) artifactsapi.Repositories
Repositories is the artifacts module's Repositories over db, bound as the server binds them, with the key pairs and projects that access reads from db. Every call takes part in a transaction of db that its context carries.
func SHA256Digest ¶
SHA256Digest is the registry digest of a fixture body.
func Seed ¶
Seed creates the built-in principals in db as a new server does (the admin user, anonymous, the readers group, the Anything and Any Remote permissions and the artifactory-build-info repository), with "pw" as the admin password, and fails t if the store refuses them. A store that is already seeded is left as it is.
func SeedHelmCharter ¶
SeedHelmCharter gives the chart-only caller rights on charts but not their provenance sidecars. Root and independent Helm matrices use the same grant.
func TarGz ¶
TarGz returns a gzip-compressed tar archive that holds one file of mode 0600 per entry, named by the entry's key and holding its value, and fails tb when the archive cannot be written. The order of the files in the archive follows map iteration, so a test must not depend on it. Conan's recipe and package archives and CRAN's source packages are archives of this shape.
func TerraformBackendKeys ¶
TerraformBackendKeys is the deterministic keyring for sealed fixture state.
func TerraformBackendRepos ¶
TerraformBackendRepos is the local backend fixture shared with the root cross-format guards.
func TerraformBackendRoutes ¶
TerraformBackendRoutes lists the native remote-state API routes. Generic item and storage routes remain covered by the root cross-format guards.
func TerraformProviderRepos ¶
TerraformProviderRepos supplies the signing-key provider fixture.
func TerraformRegistryRepos ¶
TerraformRegistryRepos are the module registry fixture repositories shared by the root cross-format suite and the standalone Terraform route suite.
func TerraformRoutes ¶
TerraformRoutes is the native module/provider registry and network mirror route inventory. Backend state routes have a separate owner.
Types ¶
type RepoFilter ¶
type RepoFilter = port.RepoFilter
RepoFilter selects the repositories RepoStore lists.
type SeedStore ¶
SeedStore is what Seed and Repositories read and write: the principals the seed creates (authn.SeedStore), and the repositories that the artifacts module's binding writes (repos.Store) with the access module's key pairs and projects that it checks (access.Store, whose access ports a test outside access may not name). Both composite stores are one, so is the router's store, and so is a fake that embeds any of them.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package agentcommon provides a production-router fixture for Agent Packages and Agent Plugins server-route suites.
|
Package agentcommon provides a production-router fixture for Agent Packages and Agent Plugins server-route suites. |
|
Package harness builds the production router for the server-assembly suites under test/server, a seeded world of users, permissions and repositories behind it, and the application runtime that serve opens.
|
Package harness builds the production router for the server-assembly suites under test/server, a seeded world of users, permissions and repositories behind it, and the application runtime that serve opens. |
|
Package registryfixture assembles the real server for registry protocol suites.
|
Package registryfixture assembles the real server for registry protocol suites. |