support

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 38 Imported by: 0

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

Status

Implemented P9b (issue 673).

Index

Constants

View Source
const RegistryConfig = `{"architecture":"amd64","os":"linux","config":{"Labels":{"team":"matrix"}}}`

RegistryConfig is the image config blob that RegistryManifest references and PushImage stores.

Variables

View Source
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".

View Source
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.

View Source
var TestHash = authn.HashParams{MemoryKiB: 64, Time: 1, Threads: 1}

TestHash keeps server-route authentication tests fast under the race detector.

Functions

func ArtifactoryError

func ArtifactoryError(t *testing.T, rec *httptest.ResponseRecorder) (int, string)

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

func Basic(user, password string) map[string]string

Basic returns the Authorization header that authenticates as user with password over HTTP Basic, in the form Do takes.

func Bearer

func Bearer(token string) map[string]string

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

func DockerHandwrittenRoutes() map[string]bool

DockerHandwrittenRoutes excludes the generated JFrog REST operations.

func DockerRoutes

func DockerRoutes() map[string]bool

DockerRoutes is the Docker and OCI server-assembly route inventory. The standalone Docker status and principal tables each cover every route.

func GoRoutes

func GoRoutes() map[string]bool

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 HelmChart

func HelmChart(name, version string) []byte

HelmChart builds a minimal chart archive with the named version.

func HelmRoutes

func HelmRoutes() map[string]bool

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

func MavenRoutes() map[string]bool

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

func NPMGeneratedRoutes() map[string]bool

NPMGeneratedRoutes is the subset implemented by generated Artifactory operations. The root stub guard must skip these after their status rows move.

func NPMPublishBody

func NPMPublishBody(name, version string) string

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

func NPMRoutes() map[string]bool

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

func NPMTarballOf(name, version string) []byte

NPMTarballOf returns a gzipped package tarball whose only file is package/package.json, naming name and version.

func NuGetForm

func NuGetForm(pkg []byte) string

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

func NuGetPDBPackage(id string, pdb []byte) []byte

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

func NuGetPackage(id, version, more string) []byte

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

func NuGetRoutes() map[string]bool

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

func NuGetSymbolsPackage(id, version string) []byte

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

func PyPIRoutes() map[string]bool

PyPIRoutes is the implemented PyPI protocol inventory. The root server package guards registration; test/server/artifacts/pypi checks status and principals.

func RegistryManifest

func RegistryManifest(note string) string

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

func SHA256Digest(body string) string

SHA256Digest is the registry digest of a fixture body.

func Seed

func Seed(t *testing.T, db SeedStore)

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

func SeedHelmCharter(t *testing.T, db SeedStore, passwordHash []byte)

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

func TarGz(tb testing.TB, entries map[string]string) string

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

func TerraformBackendKeys(t *testing.T) *crypt.Keyring

TerraformBackendKeys is the deterministic keyring for sealed fixture state.

func TerraformBackendRepos

func TerraformBackendRepos() []repo.Config

TerraformBackendRepos is the local backend fixture shared with the root cross-format guards.

func TerraformBackendRoutes

func TerraformBackendRoutes() map[string]bool

TerraformBackendRoutes lists the native remote-state API routes. Generic item and storage routes remain covered by the root cross-format guards.

func TerraformProviderRepos

func TerraformProviderRepos() []repo.Config

TerraformProviderRepos supplies the signing-key provider fixture.

func TerraformRegistryRepos

func TerraformRegistryRepos() []repo.Config

TerraformRegistryRepos are the module registry fixture repositories shared by the root cross-format suite and the standalone Terraform route suite.

func TerraformRoutes

func TerraformRoutes() map[string]bool

TerraformRoutes is the native module/provider registry and network mirror route inventory. Backend state routes have a separate owner.

Types

type Item

type Item = model.Item

Item is a stored file or folder of a repository.

type RepoFilter

type RepoFilter = port.RepoFilter

RepoFilter selects the repositories RepoStore lists.

type RepoStore

type RepoStore = port.RepoStore

RepoStore stores repository configurations.

type SeedStore

type SeedStore interface {
	authn.SeedStore
	repos.Store
	access.Store
}

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL