Skip to content

Commit 7f11d5f

Browse files
authored
Merge branch 'main' into feat/mcp-list-include-data
2 parents a216e5f + b15780a commit 7f11d5f

34 files changed

Lines changed: 1236 additions & 34 deletions

‎.github/workflows/acceptance.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
- name: Set up Go
102102
uses: actions/setup-go@v3
103103
with:
104-
go-version: "1.26.10"
104+
go-version: "1.26.11"
105105

106106
- name: Run Go Acceptance Tests (slice ${{ matrix.slice }})
107107
# 30m, not 12m: slice 0 timed out at exactly 720s once the MCP tests
@@ -133,7 +133,7 @@ jobs:
133133
- name: Set up Go
134134
uses: actions/setup-go@v3
135135
with:
136-
go-version: "1.26.10"
136+
go-version: "1.26.11"
137137

138138
- name: Run telemetry acceptance tests
139139
run: go test -tags=telemetry ./test/acceptance/... -v -timeout 12m

‎.github/workflows/outpost-live.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set up Go
3131
uses: actions/setup-go@v3
3232
with:
33-
go-version: "1.26.10"
33+
go-version: "1.26.11"
3434

3535
# The tests skip themselves when the key is absent, which is right for a
3636
# developer machine and wrong here: a missing secret would turn this job

‎.github/workflows/release.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Set up Go
2525
uses: actions/setup-go@v5
2626
with:
27-
go-version: 1.26.10
27+
go-version: 1.26.11
2828
- name: Run GoReleaser
2929
uses: goreleaser/goreleaser-action@v5
3030
with:
@@ -56,7 +56,7 @@ jobs:
5656
- name: Set up Go
5757
uses: actions/setup-go@v5
5858
with:
59-
go-version: 1.26.10
59+
go-version: 1.26.11
6060
- name: Run GoReleaser
6161
uses: goreleaser/goreleaser-action@v5
6262
with:
@@ -76,7 +76,7 @@ jobs:
7676
- name: Set up Go
7777
uses: actions/setup-go@v5
7878
with:
79-
go-version: 1.26.10
79+
go-version: 1.26.11
8080
- name: Run GoReleaser
8181
uses: goreleaser/goreleaser-action@v5
8282
with:
@@ -151,7 +151,7 @@ jobs:
151151
- name: Set up Go
152152
uses: actions/setup-go@v5
153153
with:
154-
go-version: 1.26.10
154+
go-version: 1.26.11
155155

156156
- name: Build npm binaries with GoReleaser
157157
uses: goreleaser/goreleaser-action@v5

‎.github/workflows/test-npm-build.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Go
1717
uses: actions/setup-go@v5
1818
with:
19-
go-version: 1.26.10
19+
go-version: 1.26.11
2020

2121
- name: Set up Node.js
2222
uses: actions/setup-node@v4

‎.github/workflows/test.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up Go
3030
uses: actions/setup-go@v5
3131
with:
32-
go-version: 1.26.10
32+
go-version: 1.26.11
3333
- name: Run unit tests
3434
run: go test -short ./pkg/...
3535
# `go test` runs a reduced vet suite (printf, bools, atomic and a few
@@ -52,7 +52,7 @@ jobs:
5252
- name: Set up Go
5353
uses: actions/setup-go@v5
5454
with:
55-
go-version: 1.26.10
55+
go-version: 1.26.11
5656
- name: Run govulncheck
5757
# Pinned rather than @latest: a new govulncheck release could change
5858
# behaviour or fail this job with no change to the repo. Bump
@@ -72,7 +72,7 @@ jobs:
7272
- name: Set up Go
7373
uses: actions/setup-go@v5
7474
with:
75-
go-version: 1.26.10
75+
go-version: 1.26.11
7676
- name: Run GoReleaser
7777
uses: goreleaser/goreleaser-action@v5
7878
with:
@@ -122,7 +122,7 @@ jobs:
122122
- name: Set up Go
123123
uses: actions/setup-go@v5
124124
with:
125-
go-version: 1.26.10
125+
go-version: 1.26.11
126126
- name: Run GoReleaser
127127
uses: goreleaser/goreleaser-action@v5
128128
with:
@@ -141,7 +141,7 @@ jobs:
141141
- name: Set up Go
142142
uses: actions/setup-go@v5
143143
with:
144-
go-version: 1.26.10
144+
go-version: 1.26.11
145145
- name: Run GoReleaser
146146
uses: goreleaser/goreleaser-action@v5
147147
with:

‎REFERENCE.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ hookdeck gateway connection create [flags]
386386
| `--destination-path-forwarding-disabled` | `string` | Disable path forwarding for HTTP destinations (true/false) |
387387
| `--destination-rate-limit` | `int` | Rate limit for destination (requests per period) (default "0") |
388388
| `--destination-rate-limit-period` | `string` | Rate limit period (second, minute, hour, concurrent) |
389-
| `--destination-type` | `string` | Destination type (CLI, HTTP, MOCK) |
389+
| `--destination-type` | `string` | Destination type (CLI, HTTP, MOCK_API) |
390390
| `--destination-url` | `string` | URL for HTTP destinations |
391391
| `--name` | `string` | Connection name (required) |
392392
| `--output` | `string` | Output format (json) |
@@ -645,7 +645,7 @@ hookdeck gateway connection upsert <name> [flags]
645645
| `--destination-path-forwarding-disabled` | `string` | Disable path forwarding for HTTP destinations (true/false) |
646646
| `--destination-rate-limit` | `int` | Rate limit for destination (requests per period) (default "0") |
647647
| `--destination-rate-limit-period` | `string` | Rate limit period (second, minute, hour, concurrent) |
648-
| `--destination-type` | `string` | Destination type (CLI, HTTP, MOCK) |
648+
| `--destination-type` | `string` | Destination type (CLI, HTTP, MOCK_API) |
649649
| `--destination-url` | `string` | URL for HTTP destinations |
650650
| `--dry-run` | `bool` | Preview changes without applying them |
651651
| `--output` | `string` | Output format (json) |

‎pkg/cmd/connection_create.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func newConnectionCreateCmd() *connectionCreateCmd {
168168

169169
// Destination inline creation flags
170170
cc.cmd.Flags().StringVar(&cc.destinationName, "destination-name", "", "Destination name for inline creation")
171-
cc.cmd.Flags().StringVar(&cc.destinationType, "destination-type", "", "Destination type (CLI, HTTP, MOCK)")
171+
cc.cmd.Flags().StringVar(&cc.destinationType, "destination-type", "", "Destination type (CLI, HTTP, MOCK_API)")
172172
cc.cmd.Flags().StringVar(&cc.destinationDescription, "destination-description", "", "Destination description")
173173
cc.cmd.Flags().StringVar(&cc.destinationURL, "destination-url", "", "URL for HTTP destinations")
174174
cc.cmd.Flags().StringVar(&cc.destinationCliPath, "destination-cli-path", "/", "CLI path for CLI destinations (default: /)")

‎pkg/cmd/connection_upsert.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func newConnectionUpsertCmd() *connectionUpsertCmd {
9494

9595
// Destination inline creation flags
9696
cu.cmd.Flags().StringVar(&cu.destinationName, "destination-name", "", "Destination name for inline creation")
97-
cu.cmd.Flags().StringVar(&cu.destinationType, "destination-type", "", "Destination type (CLI, HTTP, MOCK)")
97+
cu.cmd.Flags().StringVar(&cu.destinationType, "destination-type", "", "Destination type (CLI, HTTP, MOCK_API)")
9898
cu.cmd.Flags().StringVar(&cu.destinationDescription, "destination-description", "", "Destination description")
9999
cu.cmd.Flags().StringVar(&cu.destinationURL, "destination-url", "", "URL for HTTP destinations")
100100
cu.cmd.Flags().StringVar(&cu.destinationCliPath, "destination-cli-path", "", "CLI path for CLI destinations (default: / for new connections)")

‎pkg/cmd/mfa_setup_link.go‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package cmd
2+
3+
import (
4+
"errors"
5+
"net/http"
6+
"net/url"
7+
"strings"
8+
9+
"github.com/hookdeck/hookdeck-cli/pkg/hookdeck"
10+
)
11+
12+
// withMFASetupLink returns the error's message, followed by the dashboard link
13+
// to set up MFA when the API refused the request because the organization
14+
// requires it.
15+
func withMFASetupLink(err error, dashboardBaseURL string) string {
16+
message := err.Error()
17+
if link := mfaSetupLink(err, dashboardBaseURL); link != "" {
18+
message += "\nSet it up here: " + link
19+
}
20+
return message
21+
}
22+
23+
// mfaSetupLink returns the link to set up MFA, or "" when err isn't the API's
24+
// MFA refusal. The API sends a dashboard path such as
25+
// "/setup-mfa?organization_id=org_123". Only that path is used, joined to the
26+
// CLI's own dashboard address, so an error response can't point the user to
27+
// another site.
28+
func mfaSetupLink(err error, dashboardBaseURL string) string {
29+
var apiErr *hookdeck.APIError
30+
if !errors.As(err, &apiErr) || apiErr.StatusCode != http.StatusForbidden {
31+
return ""
32+
}
33+
if !strings.HasPrefix(apiErr.Redirect, "/setup-mfa") {
34+
return ""
35+
}
36+
37+
base, parseErr := url.Parse(dashboardBaseURL)
38+
if parseErr != nil || base.Scheme == "" || base.Host == "" {
39+
return ""
40+
}
41+
ref, parseErr := url.Parse(apiErr.Redirect)
42+
if parseErr != nil || ref.IsAbs() || ref.Host != "" {
43+
return ""
44+
}
45+
46+
resolved := base.ResolveReference(ref)
47+
if resolved.Scheme != base.Scheme || resolved.Host != base.Host {
48+
return ""
49+
}
50+
return resolved.String()
51+
}

‎pkg/cmd/mfa_setup_link_test.go‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package cmd
2+
3+
import (
4+
"errors"
5+
"fmt"
6+
"net/http"
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
11+
"github.com/hookdeck/hookdeck-cli/pkg/hookdeck"
12+
)
13+
14+
const testDashboard = "https://dashboard.hookdeck.com"
15+
16+
func mfaRefusal(redirect string) error {
17+
return &hookdeck.APIError{
18+
StatusCode: http.StatusForbidden,
19+
Message: "Acme requires multi-factor authentication. Please set up MFA to continue.",
20+
Redirect: redirect,
21+
}
22+
}
23+
24+
func TestWithMFASetupLinkAddsTheDashboardLink(t *testing.T) {
25+
got := withMFASetupLink(mfaRefusal("/setup-mfa?organization_id=org_1"), testDashboard)
26+
27+
assert.Equal(t, "error: Acme requires multi-factor authentication. Please set up MFA to continue.\n"+
28+
"Set it up here: https://dashboard.hookdeck.com/setup-mfa?organization_id=org_1", got)
29+
}
30+
31+
func TestMFASetupLinkFindsAWrappedRefusal(t *testing.T) {
32+
err := fmt.Errorf("listing sources: %w", mfaRefusal("/setup-mfa?organization_id=org_1"))
33+
34+
assert.Equal(t, "https://dashboard.hookdeck.com/setup-mfa?organization_id=org_1", mfaSetupLink(err, testDashboard))
35+
}
36+
37+
func TestMFASetupLinkUsesTheCLIsDashboard(t *testing.T) {
38+
assert.Equal(t, "http://tokens.localhost/setup-mfa?organization_id=org_1",
39+
mfaSetupLink(mfaRefusal("/setup-mfa?organization_id=org_1"), "http://tokens.localhost"))
40+
}
41+
42+
// The CLI only ever links to its own dashboard, whatever the response says.
43+
func TestMFASetupLinkIgnoresAnythingButASetupPath(t *testing.T) {
44+
cases := map[string]error{
45+
"another site": mfaRefusal("https://evil.example.com/setup-mfa"),
46+
"another site, no host": mfaRefusal("//evil.example.com/setup-mfa"),
47+
"another page": mfaRefusal("/billing"),
48+
"no redirect": mfaRefusal(""),
49+
"not a 403": &hookdeck.APIError{
50+
StatusCode: http.StatusUnauthorized,
51+
Redirect: "/setup-mfa?organization_id=org_1",
52+
},
53+
"not an API error": errors.New("boom"),
54+
}
55+
for name, err := range cases {
56+
t.Run(name, func(t *testing.T) {
57+
assert.Empty(t, mfaSetupLink(err, testDashboard))
58+
assert.Equal(t, err.Error(), withMFASetupLink(err, testDashboard))
59+
})
60+
}
61+
}

0 commit comments

Comments
 (0)