diff options
author | Jaewoong Jung <jungjw@google.com> | 2019-01-18 14:27:16 -0800 |
---|---|---|
committer | Jaewoong Jung <jungjw@google.com> | 2019-01-24 14:55:58 +0000 |
commit | 2ad817c65d80d2ab4b9cb851cff8d8c3982b663d (patch) | |
tree | db9a37385a0ef75fe0d0cbdfc701c85d91ff5363 /java/app_test.go | |
parent | 9d085dea9e59bd863b75115d1a528b6867ed4562 (diff) | |
download | android_build_soong-2ad817c65d80d2ab4b9cb851cff8d8c3982b663d.tar.gz android_build_soong-2ad817c65d80d2ab4b9cb851cff8d8c3982b663d.tar.bz2 android_build_soong-2ad817c65d80d2ab4b9cb851cff8d8c3982b663d.zip |
Enable certificate overrides with product vars.
Currently it is only for android_app, though it can be easily ported to
apex.
The make-side change will be made later, along with a real application.
Bug: 122957760
Test: app_test.go
Change-Id: I41f0be84f8b9f93e9518a16160e10eaa649388cd
Diffstat (limited to 'java/app_test.go')
-rw-r--r-- | java/app_test.go | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/java/app_test.go b/java/app_test.go index f6476dc6..9e2bc234 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -454,3 +454,89 @@ func TestJNI(t *testing.T) { }) } } + +func TestCertificates(t *testing.T) { + testCases := []struct { + name string + bp string + certificateOverride string + expected string + }{ + { + name: "default", + bp: ` + android_app { + name: "foo", + srcs: ["a.java"], + } + `, + certificateOverride: "", + expected: "build/target/product/security/testkey.x509.pem build/target/product/security/testkey.pk8", + }, + { + name: "module certificate property", + bp: ` + android_app { + name: "foo", + srcs: ["a.java"], + certificate: ":new_certificate" + } + + android_app_certificate { + name: "new_certificate", + certificate: "cert/new_cert", + } + `, + certificateOverride: "", + expected: "cert/new_cert.x509.pem cert/new_cert.pk8", + }, + { + name: "path certificate property", + bp: ` + android_app { + name: "foo", + srcs: ["a.java"], + certificate: "expiredkey" + } + `, + certificateOverride: "", + expected: "build/target/product/security/expiredkey.x509.pem build/target/product/security/expiredkey.pk8", + }, + { + name: "certificate overrides", + bp: ` + android_app { + name: "foo", + srcs: ["a.java"], + certificate: "expiredkey" + } + + android_app_certificate { + name: "new_certificate", + certificate: "cert/new_cert", + } + `, + certificateOverride: "foo:new_certificate", + expected: "cert/new_cert.x509.pem cert/new_cert.pk8", + }, + } + + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + config := testConfig(nil) + if test.certificateOverride != "" { + config.TestProductVariables.CertificateOverrides = []string{test.certificateOverride} + } + ctx := testAppContext(config, test.bp, nil) + + run(t, ctx, config) + foo := ctx.ModuleForTests("foo", "android_common") + + signapk := foo.Output("foo.apk") + signFlags := signapk.Args["certificates"] + if test.expected != signFlags { + t.Errorf("Incorrect signing flags, expected: %q, got: %q", test.expected, signFlags) + } + }) + } +} |