@@ -22,7 +22,9 @@ import (
2222// Note: Since the actual commands use fmt.Println (which writes to os.Stdout)
2323// instead of cmd.OutOrStdout(), we need to temporarily redirect os.Stdout
2424// to capture the output.
25- func executeCommand (cmd * cobra.Command , args ... string ) (output string , err error ) {
25+ //
26+ //nolint:unused // Shared test helper used across multiple test files
27+ func executeCommand (cmd * cobra.Command , args ... string ) (string , error ) {
2628 // Create a pipe to capture stdout
2729 oldStdout := os .Stdout
2830 r , w , _ := os .Pipe ()
@@ -35,7 +37,7 @@ func executeCommand(cmd *cobra.Command, args ...string) (output string, err erro
3537 cmd .SetArgs (args )
3638
3739 // Execute the command
38- err = cmd .Execute ()
40+ err : = cmd .Execute ()
3941
4042 // Restore stdout
4143 _ = w .Close ()
@@ -54,6 +56,7 @@ func executeCommand(cmd *cobra.Command, args ...string) (output string, err erro
5456
5557// registerEncodeFlags registers all encoding-related flags on a command.
5658// This mimics the flag registration done in root.go for encode commands.
59+ //nolint:unused // Shared test helper used across multiple test files
5760func registerEncodeFlags (cmd * cobra.Command ) {
5861 cmd .Flags ().StringP ("payload" , "p" , "" , "JSON payload" )
5962 cmd .Flags ().StringP ("secret" , "s" , "" , "HMAC secret" )
@@ -70,6 +73,7 @@ func registerEncodeFlags(cmd *cobra.Command) {
7073
7174// registerDecodeFlags registers all decoding-related flags on a command.
7275// This mimics the flag registration done in root.go for decode commands.
76+ //nolint:unused // Shared test helper used across multiple test files
7377func registerDecodeFlags (cmd * cobra.Command ) {
7478 cmd .Flags ().StringP ("token" , "t" , "" , "JWT token to decode" )
7579 cmd .Flags ().StringP ("secret" , "s" , "" , "HMAC secret" )
@@ -89,6 +93,7 @@ func registerDecodeFlags(cmd *cobra.Command) {
8993
9094// createTempFile creates a temporary file with given content.
9195// The file is created in t.TempDir() and will be automatically cleaned up.
96+ //nolint:unused // Shared test helper used across multiple test files
9297func createTempFile (t * testing.T , content []byte ) string {
9398 t .Helper ()
9499 tmpFile , err := os .CreateTemp (t .TempDir (), "test-*.pem" )
@@ -106,7 +111,8 @@ func createTempFile(t *testing.T, content []byte) string {
106111
107112// generateRSAKeyPair generates a test RSA key pair and returns file paths.
108113// Both private and public keys are written to temporary files in PEM format.
109- func generateRSAKeyPair (t * testing.T ) (privateKeyPath , publicKeyPath string ) {
114+ //nolint:unused // Shared test helper used across multiple test files
115+ func generateRSAKeyPair (t * testing.T ) (string , string ) {
110116 t .Helper ()
111117 privateKey , err := rsa .GenerateKey (rand .Reader , testRSAKeySize )
112118 if err != nil {
@@ -129,14 +135,15 @@ func generateRSAKeyPair(t *testing.T) (privateKeyPath, publicKeyPath string) {
129135 }
130136 publicKeyPEMBytes := pem .EncodeToMemory (publicKeyPEM )
131137
132- privateKeyPath = createTempFile (t , privateKeyBytes )
133- publicKeyPath = createTempFile (t , publicKeyPEMBytes )
138+ privateKeyPath : = createTempFile (t , privateKeyBytes )
139+ publicKeyPath : = createTempFile (t , publicKeyPEMBytes )
134140 return privateKeyPath , publicKeyPath
135141}
136142
137143// generateECDSAKeyPair generates a test ECDSA key pair for the given curve.
138144// Both private and public keys are written to temporary files in PEM format.
139- func generateECDSAKeyPair (t * testing.T , curve elliptic.Curve ) (privateKeyPath , publicKeyPath string ) {
145+ //nolint:unused // Shared test helper used across multiple test files
146+ func generateECDSAKeyPair (t * testing.T , curve elliptic.Curve ) (string , string ) {
140147 t .Helper ()
141148 privateKey , err := ecdsa .GenerateKey (curve , rand .Reader )
142149 if err != nil {
@@ -163,18 +170,20 @@ func generateECDSAKeyPair(t *testing.T, curve elliptic.Curve) (privateKeyPath, p
163170 }
164171 publicKeyPEMBytes := pem .EncodeToMemory (publicKeyPEM )
165172
166- privateKeyPath = createTempFile (t , privateKeyPEMBytes )
167- publicKeyPath = createTempFile (t , publicKeyPEMBytes )
173+ privateKeyPath : = createTempFile (t , privateKeyPEMBytes )
174+ publicKeyPath : = createTempFile (t , publicKeyPEMBytes )
168175 return privateKeyPath , publicKeyPath
169176}
170177
171178// createInvalidPEMFile creates a file with invalid PEM content for testing error handling.
179+ //nolint:unused // Shared test helper used across multiple test files
172180func createInvalidPEMFile (t * testing.T ) string {
173181 t .Helper ()
174182 return createTempFile (t , []byte ("invalid pem content" ))
175183}
176184
177185// createWrongTypePEMFile creates a PEM file with wrong type for testing error handling.
186+ //nolint:unused // Shared test helper used across multiple test files
178187func createWrongTypePEMFile (t * testing.T , pemType string ) string {
179188 t .Helper ()
180189 block := & pem.Block {
@@ -185,6 +194,7 @@ func createWrongTypePEMFile(t *testing.T, pemType string) string {
185194}
186195
187196// createMalformedRSAKeyFile creates a PEM file with malformed RSA key data.
197+ //nolint:unused // Shared test helper used across multiple test files
188198func createMalformedRSAKeyFile (t * testing.T ) string {
189199 t .Helper ()
190200 block := & pem.Block {
@@ -195,6 +205,7 @@ func createMalformedRSAKeyFile(t *testing.T) string {
195205}
196206
197207// createMalformedECKeyFile creates a PEM file with malformed EC key data.
208+ //nolint:unused // Shared test helper used across multiple test files
198209func createMalformedECKeyFile (t * testing.T ) string {
199210 t .Helper ()
200211 block := & pem.Block {
@@ -205,12 +216,14 @@ func createMalformedECKeyFile(t *testing.T) string {
205216}
206217
207218// getNonExistentPath returns a path that doesn't exist for testing file not found errors.
219+ //nolint:unused // Shared test helper used across multiple test files
208220func getNonExistentPath (t * testing.T ) string {
209221 t .Helper ()
210222 return filepath .Join (t .TempDir (), "nonexistent.pem" )
211223}
212224
213225// Test constants used across multiple test files.
226+ //nolint:unused // Shared test constants used across multiple test files
214227const (
215228 // testRSAKeySize is the RSA key size used for test key generation (2048 bits).
216229 testRSAKeySize = 2048
0 commit comments