-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckcert_test.go
More file actions
38 lines (35 loc) · 1.09 KB
/
Copy pathcheckcert_test.go
File metadata and controls
38 lines (35 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"testing"
)
type tcase struct {
apkFile,
certFile,
vendor,
certType string
result bool
}
func TestCheckCert(t *testing.T) {
cases := []struct {
in tcase
}{
{tcase{"test/app-debug.apk", "/dev/null", "android", "release", false}},
{tcase{"/dev/null", "test/android.cert", "", "", false}},
{tcase{"/dev/random", "test/android.cert", "", "", false}},
{tcase{"test/app-debug.apk", "/dev/null", "", "", true}},
{tcase{"test/app-debug.apk", "test/android.cert", "android", "release", false}},
{tcase{"test/app-mediakey.apk", "", "android", "media", true}},
{tcase{"test/app-sharedkey.apk", "", "android", "shared", true}},
{tcase{"test/app-platformkey.apk", "", "android", "platform", true}},
{tcase{"test/app-releasekey.apk", "", "android", "release", true}},
{tcase{"test/app-unsigned.apk", "", "android", "release", false}},
}
for i, c := range cases {
fmt.Printf("Testing #%d case\n", i)
ret := Checkcert(c.in.apkFile, c.in.certFile, c.in.vendor, c.in.certType)
if ret != c.in.result {
t.Errorf("result incorrect in #%d test cases", i)
}
}
}