Skip to content

Commit a869db0

Browse files
committed
[ACTP] drop redundant log redaction test
The recordingLogger fake implemented the whole log.Component surface for a single test whose only exercised log line is a constant string, so it could not detect a private-key leak. Key redaction is still covered by the invalid configured private key case, which asserts the error does not echo the key.
1 parent d40ad23 commit a869db0

1 file changed

Lines changed: 0 additions & 54 deletions

File tree

cmd/privateactionrunner/subcommands/ensureenrollment/command_test.go

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import (
1111
"context"
1212
"encoding/base64"
1313
"encoding/json"
14-
"fmt"
1514
"os"
1615
"path/filepath"
17-
"strings"
1816
"testing"
1917

2018
"github.com/stretchr/testify/assert"
@@ -141,22 +139,6 @@ func TestEnsureEnrollmentConfiguredIdentity(t *testing.T) {
141139
})
142140
}
143141

144-
func TestEnsureEnrollmentOutputDoesNotContainPrivateKey(t *testing.T) {
145-
privateKey := validPrivateKey(t)
146-
cfg := testConfig(t, filepath.Join(t.TempDir(), "missing.json"), map[string]interface{}{
147-
"private_action_runner.self_enroll": false,
148-
"private_action_runner.urn": validURN(),
149-
"private_action_runner.private_key": privateKey,
150-
})
151-
hostnameComp, _ := hostnamemock.NewMock("test-host")
152-
logger := &recordingLogger{}
153-
154-
err := ensureEnrollment(context.Background(), logger, cfg, hostnameComp, failIfEnrolled(t))
155-
156-
require.NoError(t, err)
157-
assert.NotContains(t, logger.String(), privateKey)
158-
}
159-
160142
func TestEnsureEnrollmentFailures(t *testing.T) {
161143
t.Run("self enrollment disabled", func(t *testing.T) {
162144
cfg := testConfig(t, filepath.Join(t.TempDir(), "missing.json"), map[string]interface{}{
@@ -249,39 +231,3 @@ func failIfEnrolled(t *testing.T) enrollAndPersistFunc {
249231
return nil, nil
250232
}
251233
}
252-
253-
type recordingLogger struct {
254-
messages []string
255-
}
256-
257-
func (l *recordingLogger) add(v ...interface{}) { l.messages = append(l.messages, fmt.Sprint(v...)) }
258-
func (l *recordingLogger) addf(format string, v ...interface{}) { l.add(fmt.Sprintf(format, v...)) }
259-
func (l *recordingLogger) Trace(v ...interface{}) { l.add(v...) }
260-
func (l *recordingLogger) Tracef(format string, v ...interface{}) {
261-
l.addf(format, v...)
262-
}
263-
func (l *recordingLogger) Debug(v ...interface{}) { l.add(v...) }
264-
func (l *recordingLogger) Debugf(format string, v ...interface{}) {
265-
l.addf(format, v...)
266-
}
267-
func (l *recordingLogger) Info(v ...interface{}) { l.add(v...) }
268-
func (l *recordingLogger) Infof(format string, v ...interface{}) {
269-
l.addf(format, v...)
270-
}
271-
func (l *recordingLogger) Warn(v ...interface{}) error { l.add(v...); return nil }
272-
func (l *recordingLogger) Warnf(format string, v ...interface{}) error {
273-
l.addf(format, v...)
274-
return nil
275-
}
276-
func (l *recordingLogger) Error(v ...interface{}) error { l.add(v...); return nil }
277-
func (l *recordingLogger) Errorf(format string, v ...interface{}) error {
278-
l.addf(format, v...)
279-
return nil
280-
}
281-
func (l *recordingLogger) Critical(v ...interface{}) error { l.add(v...); return nil }
282-
func (l *recordingLogger) Criticalf(format string, v ...interface{}) error {
283-
l.addf(format, v...)
284-
return nil
285-
}
286-
func (l *recordingLogger) Flush() {}
287-
func (l *recordingLogger) String() string { return strings.Join(l.messages, "\n") }

0 commit comments

Comments
 (0)