Add test for missing certificate with AllowMissingDependencies
Add a test that verifies that that missing certificate path inserted when AllowMissingDependencies is set uses a well formed extension that won't trip up sign_target_files_apks. Fixes: 259861670 Test: TestCertificates Change-Id: I00656809698aed5f9d3aaadaecda9848d2882223
This commit is contained in:
@@ -1490,6 +1490,7 @@ func TestCertificates(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
bp string
|
bp string
|
||||||
|
allowMissingDependencies bool
|
||||||
certificateOverride string
|
certificateOverride string
|
||||||
expectedCertSigningFlags string
|
expectedCertSigningFlags string
|
||||||
expectedCertificate string
|
expectedCertificate string
|
||||||
@@ -1505,7 +1506,7 @@ func TestCertificates(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
certificateOverride: "",
|
certificateOverride: "",
|
||||||
expectedCertSigningFlags: "",
|
expectedCertSigningFlags: "",
|
||||||
expectedCertificate: "build/make/target/product/security/testkey.x509.pem build/make/target/product/security/testkey.pk8",
|
expectedCertificate: "build/make/target/product/security/testkey",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "module certificate property",
|
name: "module certificate property",
|
||||||
@@ -1524,7 +1525,7 @@ func TestCertificates(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
certificateOverride: "",
|
certificateOverride: "",
|
||||||
expectedCertSigningFlags: "",
|
expectedCertSigningFlags: "",
|
||||||
expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8",
|
expectedCertificate: "cert/new_cert",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "path certificate property",
|
name: "path certificate property",
|
||||||
@@ -1538,7 +1539,7 @@ func TestCertificates(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
certificateOverride: "",
|
certificateOverride: "",
|
||||||
expectedCertSigningFlags: "",
|
expectedCertSigningFlags: "",
|
||||||
expectedCertificate: "build/make/target/product/security/expiredkey.x509.pem build/make/target/product/security/expiredkey.pk8",
|
expectedCertificate: "build/make/target/product/security/expiredkey",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "certificate overrides",
|
name: "certificate overrides",
|
||||||
@@ -1557,7 +1558,7 @@ func TestCertificates(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
certificateOverride: "foo:new_certificate",
|
certificateOverride: "foo:new_certificate",
|
||||||
expectedCertSigningFlags: "",
|
expectedCertSigningFlags: "",
|
||||||
expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8",
|
expectedCertificate: "cert/new_cert",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "certificate signing flags",
|
name: "certificate signing flags",
|
||||||
@@ -1578,7 +1579,7 @@ func TestCertificates(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
certificateOverride: "",
|
certificateOverride: "",
|
||||||
expectedCertSigningFlags: "--lineage lineage.bin --rotation-min-sdk-version 32",
|
expectedCertSigningFlags: "--lineage lineage.bin --rotation-min-sdk-version 32",
|
||||||
expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8",
|
expectedCertificate: "cert/new_cert",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "cert signing flags from filegroup",
|
name: "cert signing flags from filegroup",
|
||||||
@@ -1604,7 +1605,20 @@ func TestCertificates(t *testing.T) {
|
|||||||
`,
|
`,
|
||||||
certificateOverride: "",
|
certificateOverride: "",
|
||||||
expectedCertSigningFlags: "--lineage lineage.bin --rotation-min-sdk-version 32",
|
expectedCertSigningFlags: "--lineage lineage.bin --rotation-min-sdk-version 32",
|
||||||
expectedCertificate: "cert/new_cert.x509.pem cert/new_cert.pk8",
|
expectedCertificate: "cert/new_cert",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "missing with AllowMissingDependencies",
|
||||||
|
bp: `
|
||||||
|
android_app {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
certificate: ":new_certificate",
|
||||||
|
sdk_version: "current",
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
expectedCertificate: "out/soong/.intermediates/foo/android_common/missing",
|
||||||
|
allowMissingDependencies: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1616,17 +1630,32 @@ func TestCertificates(t *testing.T) {
|
|||||||
if test.certificateOverride != "" {
|
if test.certificateOverride != "" {
|
||||||
variables.CertificateOverrides = []string{test.certificateOverride}
|
variables.CertificateOverrides = []string{test.certificateOverride}
|
||||||
}
|
}
|
||||||
|
if test.allowMissingDependencies {
|
||||||
|
variables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
android.FixtureModifyContext(func(ctx *android.TestContext) {
|
||||||
|
ctx.SetAllowMissingDependencies(test.allowMissingDependencies)
|
||||||
}),
|
}),
|
||||||
).RunTestWithBp(t, test.bp)
|
).RunTestWithBp(t, test.bp)
|
||||||
|
|
||||||
foo := result.ModuleForTests("foo", "android_common")
|
foo := result.ModuleForTests("foo", "android_common")
|
||||||
|
|
||||||
signapk := foo.Output("foo.apk")
|
certificate := foo.Module().(*AndroidApp).certificate
|
||||||
signCertificateFlags := signapk.Args["certificates"]
|
android.AssertPathRelativeToTopEquals(t, "certificates key", test.expectedCertificate+".pk8", certificate.Key)
|
||||||
android.AssertStringEquals(t, "certificates flags", test.expectedCertificate, signCertificateFlags)
|
// The sign_target_files_apks and check_target_files_signatures
|
||||||
|
// tools require that certificates have a .x509.pem extension.
|
||||||
|
android.AssertPathRelativeToTopEquals(t, "certificates pem", test.expectedCertificate+".x509.pem", certificate.Pem)
|
||||||
|
|
||||||
certSigningFlags := signapk.Args["flags"]
|
signapk := foo.Output("foo.apk")
|
||||||
android.AssertStringEquals(t, "cert signing flags", test.expectedCertSigningFlags, certSigningFlags)
|
if signapk.Rule != android.ErrorRule {
|
||||||
|
signCertificateFlags := signapk.Args["certificates"]
|
||||||
|
expectedFlags := certificate.Pem.String() + " " + certificate.Key.String()
|
||||||
|
android.AssertStringEquals(t, "certificates flags", expectedFlags, signCertificateFlags)
|
||||||
|
|
||||||
|
certSigningFlags := signapk.Args["flags"]
|
||||||
|
android.AssertStringEquals(t, "cert signing flags", test.expectedCertSigningFlags, certSigningFlags)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user