From dd3b6de01902bf507f89351277e60b018b65ce10 Mon Sep 17 00:00:00 2001 From: Zeno Belli Date: Mon, 18 May 2026 14:30:48 +0200 Subject: [PATCH 1/4] fix(requests): sample config printed to Stderr instead of Stdout --- internal/cmd/requests.go | 3 ++- internal/cmd/requests_test.go | 30 ++++++++++++++++++++++++++++++ internal/cmd/root_test.go | 7 +++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/internal/cmd/requests.go b/internal/cmd/requests.go index 13a7e0e..e3e65f3 100644 --- a/internal/cmd/requests.go +++ b/internal/cmd/requests.go @@ -6,6 +6,7 @@ package cmd import ( _ "embed" + "fmt" "os" "github.com/gookit/goutil/dump" @@ -49,7 +50,7 @@ Examples: } if showSampleConfig { - cmd.Print(sampleYamlConfig) + fmt.Fprint(cmd.OutOrStdout(), sampleYamlConfig) return } diff --git a/internal/cmd/requests_test.go b/internal/cmd/requests_test.go index e7123a5..3a78f4a 100644 --- a/internal/cmd/requests_test.go +++ b/internal/cmd/requests_test.go @@ -147,3 +147,33 @@ func TestRequestsCmd(t *testing.T) { }) } } + +func TestRequestsCmd_ShowSampleConfigStdout(t *testing.T) { + t.Cleanup(func() { + require.NoError(t, rootCmd.Flags().Set("version", "false")) + require.NoError(t, requestsCmd.Flags().Set("ca-bundle", "")) + require.NoError(t, rootCmd.Flags().Set("config", "")) + require.NoError(t, requestsCmd.Flags().Set("show-sample-config", "false")) + rootCmd.SetArgs(nil) + }) + + stdout := new(bytes.Buffer) + stderr := new(bytes.Buffer) + + reqCmd := rootCmd + reqCmd.SetOut(stdout) + reqCmd.SetErr(stderr) + reqCmd.SetArgs([]string{"requests", "--show-sample-config"}) + + err := reqCmd.Execute() + require.NoError(t, err) + + // Verify that the output was written to stdout + gotStdout := stdout.String() + require.Contains(t, gotStdout, "https-wrench.schema.json") + require.Contains(t, gotStdout, "requests:") + + // Verify that nothing was written to stderr + gotStderr := stderr.String() + require.Empty(t, gotStderr, "Expected stderr to be empty, but got: %s", gotStderr) +} diff --git a/internal/cmd/root_test.go b/internal/cmd/root_test.go index 2c12f95..8d10de2 100644 --- a/internal/cmd/root_test.go +++ b/internal/cmd/root_test.go @@ -95,7 +95,14 @@ func TestRootCmd_LoadConfig(t *testing.T) { func TestRootCmd_Execute(t *testing.T) { t.Run("Execute empty config", func(t *testing.T) { + oldCfg := cfgFile + t.Cleanup(func() { + cfgFile = oldCfg + rootCmd.SetArgs(nil) + }) + cfgFile = "" + rootCmd.SetArgs([]string{"--config"}) initConfig() From 9b355e76f488c745af0e5d09273bc77138e58282 Mon Sep 17 00:00:00 2001 From: Zeno Belli Date: Mon, 18 May 2026 14:31:17 +0200 Subject: [PATCH 2/4] chore(jwtinfo): improve validation url example in command help --- internal/cmd/jwtinfo.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/jwtinfo.go b/internal/cmd/jwtinfo.go index a2c7488..5af823f 100644 --- a/internal/cmd/jwtinfo.go +++ b/internal/cmd/jwtinfo.go @@ -70,7 +70,7 @@ var jwtinfoCmd = &cobra.Command{ Examples: export REQ_URL="https://sample.provider/oauth/token" export REQ_VALUES="{\"login\":\"values\"}" - export VALIDATION_URL="https://url.to/jwks.json" + export VALIDATION_URL="https://oidc.sample.url/oicd-sample-id/.well-known/jwks.json" # Read a JWT token from a local file https-wrench jwtinfo --token-file /var/run/secrets/kubernetes.io/serviceaccount/token From 2f5bb8b6d234f9f5f24ee7e1ad3d4f7606ac430c Mon Sep 17 00:00:00 2001 From: Zeno Belli Date: Mon, 18 May 2026 14:31:33 +0200 Subject: [PATCH 3/4] ci: update dependecies --- devenv.lock | 24 ++++++++++++------------ go.mod | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/devenv.lock b/devenv.lock index 086b6b1..4618bef 100644 --- a/devenv.lock +++ b/devenv.lock @@ -3,11 +3,11 @@ "devenv": { "locked": { "dir": "src/modules", - "lastModified": 1777837414, - "narHash": "sha256-L7g797htlkWyFW+6Y4qibuyaVMcDaVjdBTcaPMbKPmY=", + "lastModified": 1778281489, + "narHash": "sha256-q/E8JCHXLp7+T/SfSR3vN9KjDtCi5lB0xdgh4LcEOJc=", "owner": "cachix", "repo": "devenv", - "rev": "9708ea1ebc52d6189cff09b837067daefb0bf0e7", + "rev": "23120f1b923e80a27facbeb59433688772e854ab", "type": "github" }, "original": { @@ -93,11 +93,11 @@ "nixpkgs-src": { "flake": false, "locked": { - "lastModified": 1776329215, - "narHash": "sha256-a8BYi3mzoJ/AcJP8UldOx8emoPRLeWqALZWu4ZvjPXw=", + "lastModified": 1777826146, + "narHash": "sha256-wQ/iN5Zp5VIa3ebBibijPnLyKhor+xEbDy4d0goa9Zs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b86751bc4085f48661017fa226dee99fab6c651b", + "rev": "73c703c22422b8951895a960959dbbaca7296492", "type": "github" }, "original": { @@ -109,11 +109,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1777673416, - "narHash": "sha256-5c2POKPOjU40Kh0MirOdScBLG0bu9TAuPYAtPRNZMBs=", + "lastModified": 1778003029, + "narHash": "sha256-q/nkKLDtHIyLjZpKhWk3cSK5IYsFqtMd6UtXF3ddjgA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "26ef669cffa904b6f6832ab57b77892a37c1a671", + "rev": "0c88e1f2bdb93d5999019e99cb0e61e1fe2af4c5", "type": "github" }, "original": { @@ -128,11 +128,11 @@ "nixpkgs-src": "nixpkgs-src" }, "locked": { - "lastModified": 1776852779, - "narHash": "sha256-WwO/ITisCXwyiRgtktZgv3iGhAGO+IB5Av4kKCwezR0=", + "lastModified": 1778017947, + "narHash": "sha256-Qp52wvK3Bq854SSLC8cJ6H6cokQ96qhgBHcyynRjkW8=", "owner": "cachix", "repo": "devenv-nixpkgs", - "rev": "ec3063523dcd911aeadb50faa589f237cdab5853", + "rev": "5941ed7aa58a1651f373ccfd5a106e1597ec8dd6", "type": "github" }, "original": { diff --git a/go.mod b/go.mod index 65de9e0..fbaaa18 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/gookit/goutil v0.7.4 github.com/pires/go-proxyproto v0.12.0 github.com/spf13/cobra v1.10.2 + github.com/spf13/pflag v1.0.10 github.com/spf13/viper v1.21.0 github.com/stretchr/testify v1.11.1 github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 @@ -49,7 +50,6 @@ require ( github.com/sagikazarmark/locafero v0.12.0 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect - github.com/spf13/pflag v1.0.10 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect From d2b81507572a768a78ab0088f0c6eb4261f3f77f Mon Sep 17 00:00:00 2001 From: Zeno Belli Date: Mon, 18 May 2026 14:34:39 +0200 Subject: [PATCH 4/4] fix: linting of root test --- internal/cmd/root_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/cmd/root_test.go b/internal/cmd/root_test.go index 8d10de2..f8008d5 100644 --- a/internal/cmd/root_test.go +++ b/internal/cmd/root_test.go @@ -96,12 +96,15 @@ func TestRootCmd_LoadConfig(t *testing.T) { func TestRootCmd_Execute(t *testing.T) { t.Run("Execute empty config", func(t *testing.T) { oldCfg := cfgFile + t.Cleanup(func() { cfgFile = oldCfg + rootCmd.SetArgs(nil) }) cfgFile = "" + rootCmd.SetArgs([]string{"--config"}) initConfig()