Skip to content

Commit 877a84f

Browse files
authored
chore: add valid pem test case #173
chore: add pem testcase
2 parents 08fef2f + 0945a39 commit 877a84f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

pkg/postprocess/pem_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package postprocess
2+
3+
import "testing"
4+
5+
func TestIsPem(t *testing.T) {
6+
type args struct {
7+
cc string
8+
}
9+
tests := []struct {
10+
name string
11+
text []byte
12+
isSecret bool
13+
}{
14+
{
15+
"Invalid private pem file",
16+
[]byte("Random Binary Data"),
17+
false,
18+
},
19+
{
20+
"Invalid private pem file",
21+
[]byte("This is not a pem file."),
22+
false,
23+
},
24+
{
25+
"Invalid private pem file",
26+
[]byte("Non-pem File"),
27+
false,
28+
},
29+
{
30+
"Valid private pem file",
31+
[]byte{45, 45, 45, 45, 45, 66, 69, 71, 73, 78, 32, 69, 78, 67, 82, 89, 80, 84, 69, 68, 32, 80, 82, 73, 86, 65, 84,
32+
69, 32, 75, 69, 89, 45, 45, 45, 45, 45, 10, 116, 101, 115, 116, 32,
33+
112, 97, 115, 115, 119, 111, 114, 100, 10, 45, 45, 45, 45, 45, 69, 78, 68, 32, 69, 78, 67,
34+
82, 89, 80, 84, 69, 68, 32, 80, 82, 73, 86, 65, 84, 69, 32, 75, 69, 89, 45, 45, 45, 45, 45},
35+
true,
36+
},
37+
}
38+
for _, tt := range tests {
39+
t.Run(tt.name, func(t *testing.T) {
40+
if got := IsPrivatePem(tt.text); got != tt.isSecret {
41+
t.Errorf("TestIsPem() = %v, want %v", got, tt.isSecret)
42+
}
43+
})
44+
}
45+
}

0 commit comments

Comments
 (0)