Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,22 @@ The release has `proxyfile-linux-amd64`, `proxyfile-linux-arm64`, `proxyfile-dar
`proxyfile-darwin-arm64`, with `checksums.txt` and `proxyfile.schema.json` beside them.

```sh
curl -fsSLO https://github.com/kitecorp/proxyfile/releases/download/v2.4.0/proxyfile-linux-amd64
curl -fsSLO https://github.com/kitecorp/proxyfile/releases/download/v2.4.0/checksums.txt
curl -fsSLO https://github.com/kitecorp/proxyfile/releases/download/v2.5.0/proxyfile-linux-amd64
curl -fsSLO https://github.com/kitecorp/proxyfile/releases/download/v2.5.0/checksums.txt
shasum -a 256 -c --ignore-missing checksums.txt
install -m 0755 proxyfile-linux-amd64 /usr/local/bin/proxyfile
```

In a Dockerfile, copy the program out of the image. The image holds `/proxyfile` and nothing else.

```dockerfile
COPY --from=ghcr.io/kitecorp/proxyfile:2.4.0 /proxyfile /usr/local/bin/proxyfile
COPY --from=ghcr.io/kitecorp/proxyfile:2.5.0 /proxyfile /usr/local/bin/proxyfile
```

With Go installed (the Go version `go.mod` names or newer):

```sh
go install github.com/kitecorp/proxyfile/v2/cmd/proxyfile@v2.4.0
go install github.com/kitecorp/proxyfile/v2/cmd/proxyfile@v2.5.0
```

## Commands
Expand Down
3 changes: 2 additions & 1 deletion conformance/battery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func runFile(t *testing.T, tg target, f file, config string, lock func(*testing.
if err != nil {
t.Fatal(err)
}
w := startWorld(t, tg, mounted, !slices.Contains(written, "tls"), bytes.Contains(source, []byte(holdAddress)), f.collector)
w := startWorld(t, tg, mounted, !slices.Contains(written, "tls"), bytes.Contains(source, []byte(holdAddress)), f.collector,
bytes.Contains(source, []byte(keysURL)))
keys := fileKeys{label: f.label, keys: written, scenarios: f.scenarios, mainRows: tg.mainRows}
limited := slices.Contains(written, "routes[].rate_limit")
// In order and never in parallel, but for the rows that overlap: a scenario's quiet and burst count on nothing else
Expand Down
7 changes: 5 additions & 2 deletions conformance/certificates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ import (
// paths the full example's tls keys and auth.jwt.ca name. client, otherCA and expired are the clients' certificates
// with their keys, kept in memory because the proxy never reads them: client is signed by the clients CA, otherCA by
// a second CA that carries the clients CA's name, so only a proxy that checks the signature refuses it, and expired by
// the clients CA with a validity that ended, so only a proxy that checks the dates refuses it.
// the clients CA with a validity that ended, so only a proxy that checks the dates refuses it. token is the run's
// token, whose keys jwt/jwks.json holds (signedToken).
type tlsFiles struct {
tls, jwt string
client, otherCA, expired tls.Certificate
token string
}

// certificates makes throwaway TLS files for one run under dir: a self-signed server certificate for localhost and
// 127.0.0.1 with its key, a clients CA, and a copy of the server certificate as the CA bundle auth.jwt.ca names.
// Folders are 0755 and files 0644 whatever the umask, because the proxy runs as an unprivileged user in its image and
// must read the mounted files; the keys are made for this run alone and removed with dir. It also makes the three
// client certificates, which stay in memory.
// client certificates, which stay in memory, and the run's token with its key set (signedToken).
func certificates(t testing.TB, dir string) tlsFiles {
files := tlsFiles{tls: filepath.Join(dir, "tls"), jwt: filepath.Join(dir, "jwt")}
for _, folder := range []string{files.tls, files.jwt} {
Expand Down Expand Up @@ -59,6 +61,7 @@ func certificates(t testing.TB, dir string) tlsFiles {
files.expired = clientCertificate(t, caCertificate, caKey, time.Now().Add(-48*time.Hour), time.Now().Add(-24*time.Hour))
otherCertificate, otherKey, _ := clientsCA(t)
files.otherCA = clientCertificate(t, otherCertificate, otherKey)
files.token = signedToken(t, files.jwt)
for path, data := range map[string][]byte{
filepath.Join(files.tls, "certificate.pem"): serverPEM,
filepath.Join(files.tls, "key.pem"): keyPEM(t, serverKey),
Expand Down
4 changes: 3 additions & 1 deletion conformance/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type echo struct {
Headers, HeaderBytes map[string]string
Body string
Trailers map[string]string
BodyBytes int64 // shop's gRPC stub's count of the body bytes it read, when asked
}

// result is what came back for one request.
Expand Down Expand Up @@ -134,8 +135,9 @@ func clientTLS(t testing.TB, files tlsFiles, certificate *tls.Certificate) *tls.
}

// send sends r to the proxy's listener and reads the whole answer, trailers included: by hand when r is raw (sendRaw),
// and otherwise through the client for its protocol.
// and otherwise through the client for its protocol. A header value that holds withToken carries the run's token there.
func (w *world) send(r request) result {
r = w.tokened(r)
if r.raw {
if r.noCertificate || r.otherCA || r.expired || r.forgedMark || r.proto == "grpc" {
panic(fmt.Sprintf("the battery sends a raw request with the client certificate and no forged mark over http/1.1 or h2, not %+v", r))
Expand Down
12 changes: 9 additions & 3 deletions conformance/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ type answer struct {
// proxy makes anew on an answer no stub wrote, such as the request id of its own 404.
made map[string]*regexp.Regexp
body string // the body the stub received; "" is not compared
// bodyBytes, on a gRPC call sent with x-stub-count-body, is how many bytes of body shop's gRPC stub must have read,
// its frames whole; 0 is not compared.
bodyBytes int64
// ownBody is the body of an answer the proxy wrote itself, such as its refusal of a browser origin; "" is not
// compared. A stub's echo is never that body, so a row that wants one also fails when a stub answered.
ownBody string
Expand Down Expand Up @@ -232,9 +235,9 @@ type answer struct {
// expression matches: the request log line of a target whose line is its own and no JSON object, which logged
// cannot read (sendRepeated reads it, as it reads counted).
lineAfter *regexp.Regexp
// asked, on a row sent in sequence, is how many questions the stub's origin check, the check
// conformance/testdata/unlisted-origins.yaml's ask_unlisted names, must receive while the row's requests are sent
// and answered (sendRepeated reads it); nil is not compared. The answer cannot show it for an origin RBAC admits
// asked, on a row sent in sequence, is how many questions the stub's origin check, the check the ask_unlisted of
// conformance/testdata/unlisted-origins.yaml and request-limit.yaml names, must receive while the row's requests are
// sent and answered (sendRepeated reads it); nil is not compared. The answer cannot show it for an origin RBAC admits
// whether or not the check was asked.
asked *int
// receivedForms holds headers the stub must have received with a value the regular expression matches, which the
Expand Down Expand Up @@ -379,6 +382,9 @@ func compare(want answer, got result, mark string) []string {
if want.body != "" && e.Body != want.body {
differ("received body: got %q, want %q", e.Body, want.body)
}
if want.bodyBytes != 0 && e.BodyBytes != want.bodyBytes {
differ("received body bytes: got %d, want %d", e.BodyBytes, want.bodyBytes)
}
if want.noTrailers && len(e.Trailers) != 0 {
differ("received trailers: got %q, want none", e.Trailers)
}
Expand Down
Loading