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
24 changes: 12 additions & 12 deletions devenv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/jwtinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix typo in the VALIDATION_URL example.

Line 73 uses oicd-sample-id, which looks like a typo (oidc-sample-id) in user-facing help text.

Suggested patch
-  export VALIDATION_URL="https://oidc.sample.url/oicd-sample-id/.well-known/jwks.json"
+  export VALIDATION_URL="https://oidc.sample.url/oidc-sample-id/.well-known/jwks.json"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export VALIDATION_URL="https://oidc.sample.url/oicd-sample-id/.well-known/jwks.json"
export VALIDATION_URL="https://oidc.sample.url/oidc-sample-id/.well-known/jwks.json"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cmd/jwtinfo.go` at line 73, Update the example value for
VALIDATION_URL in internal/cmd/jwtinfo.go to fix the typo "oicd-sample-id" ->
"oidc-sample-id" so the user-facing help text shows the correct OIDC path;
locate the constant or example assignment referencing VALIDATION_URL and replace
the misspelled segment while preserving the rest of the URL string.


# Read a JWT token from a local file
https-wrench jwtinfo --token-file /var/run/secrets/kubernetes.io/serviceaccount/token
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cmd

import (
_ "embed"
"fmt"
"os"

"github.com/gookit/goutil/dump"
Expand Down Expand Up @@ -49,7 +50,7 @@ Examples:
}

if showSampleConfig {
cmd.Print(sampleYamlConfig)
fmt.Fprint(cmd.OutOrStdout(), sampleYamlConfig)
return
}

Expand Down
30 changes: 30 additions & 0 deletions internal/cmd/requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
10 changes: 10 additions & 0 deletions internal/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,18 @@ 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()

_, err := LoadConfig()
Expand Down
Loading