@@ -37,8 +37,8 @@ func TestRedact(t *testing.T) {
37
37
}{
38
38
// Redacting non-error values.
39
39
40
- {123 , `< int>` },
41
- {"secret" , `< string>` },
40
+ {123 , `int:<redacted >` },
41
+ {"secret" , `string:<redacted >` },
42
42
43
43
// Redacting SafeMessagers.
44
44
@@ -47,24 +47,24 @@ func TestRedact(t *testing.T) {
47
47
{mySafeError {}, `hello` },
48
48
{& werrFmt {mySafeError {}, "unseen" },
49
49
`safedetails_test.mySafeError: hello
50
- wrapper: < *safedetails_test.werrFmt>` },
50
+ *safedetails_test.werrFmt:<redacted >` },
51
51
52
52
// Redacting errors.
53
53
54
54
// Unspecial cases, get redacted.
55
- {errors .New ("secret" ), `< *errors.errorString>` },
55
+ {errors .New ("secret" ), `*errors.errorString:<redacted >` },
56
56
57
57
// Stack trace in error retrieves some info about the context.
58
58
{withstack .WithStack (errors .New ("secret" )),
59
- `< path>: < *errors.errorString>
60
- wrapper: < *withstack.withStack>
61
- (more details:)
59
+ `... path...: *errors.errorString:<redacted >
60
+ *withstack.withStack:<redacted >
61
+ (more details about this error :)
62
62
github.com/cockroachdb/errors/safedetails_test.TestRedact
63
- < path>
63
+ ... path...
64
64
testing.tRunner
65
- < path>
65
+ ... path...
66
66
runtime.goexit
67
- < path> ` },
67
+ ... path... ` },
68
68
69
69
// Special cases, unredacted.
70
70
{os .ErrInvalid , `*errors.errorString: invalid argument` },
@@ -83,22 +83,22 @@ runtime.goexit
83
83
`*runtime.TypeAssertionError: interface conversion: interface {} is nil, not int` },
84
84
85
85
{errSentinel , // explodes if Error() called
86
- `< struct { error }>` },
86
+ `struct { error }:<redacted >` },
87
87
88
88
{& werrFmt {& werrFmt {os .ErrClosed , "unseen" }, "unsung" },
89
89
`*errors.errorString: file already closed
90
- wrapper: < *safedetails_test.werrFmt>
91
- wrapper: < *safedetails_test.werrFmt>` },
90
+ *safedetails_test.werrFmt:<redacted >
91
+ *safedetails_test.werrFmt:<redacted >` },
92
92
93
93
// Special cases, get partly redacted.
94
94
95
95
{os .NewSyscallError ("rename" , os .ErrNotExist ),
96
96
`*errors.errorString: file does not exist
97
- wrapper: *os.SyscallError: rename` },
97
+ *os.SyscallError: rename` },
98
98
99
99
{& os.PathError {Op : "rename" , Path : "secret" , Err : os .ErrNotExist },
100
100
`*errors.errorString: file does not exist
101
- wrapper: *os.PathError: rename` },
101
+ *os.PathError: rename` },
102
102
103
103
{& os.LinkError {
104
104
Op : "moo" ,
@@ -107,23 +107,23 @@ wrapper: *os.PathError: rename`},
107
107
Err : os .ErrNotExist ,
108
108
},
109
109
`*errors.errorString: file does not exist
110
- wrapper: *os.LinkError: moo <redacted> <redacted>` },
110
+ *os.LinkError: moo <redacted> <redacted>` },
111
111
112
112
{& net.OpError {
113
113
Op : "write" ,
114
114
Net : "tcp" ,
115
115
Source : & net.IPAddr {IP : net .IP ("sensitive-source" )},
116
116
Addr : & net.IPAddr {IP : net .IP ("sensitive-addr" )},
117
117
Err : errors .New ("not safe" ),
118
- }, `< *errors.errorString>
119
- wrapper: *net.OpError: write tcp<redacted>-> <redacted>` },
118
+ }, `*errors.errorString:<redacted >
119
+ *net.OpError: write tcp <redacted> -> <redacted>` },
120
120
}
121
121
122
122
tt := testutils.T {T : t }
123
123
124
124
for _ , tc := range testData {
125
125
s := safedetails .Redact (tc .obj )
126
- s = fileref .ReplaceAllString (s , "< path> " )
126
+ s = fileref .ReplaceAllString (s , "... path... " )
127
127
128
128
tt .CheckStringEqual (s , tc .expected )
129
129
}
0 commit comments