Search in sources :

Example 6 with SignerCapabilities

use of com.android.apksig.SigningCertificateLineage.SignerCapabilities in project apksig by venshine.

the class SigningCertificateLineageTest method testCapabilitiesAreNotUpdatedWithDefaultValues.

@Test
public void testCapabilitiesAreNotUpdatedWithDefaultValues() throws Exception {
    // This file contains the lineage with the first two rsa-2048 signers with the first signer
    // having all of the capabilities set to false.
    SigningCertificateLineage lineage = Resources.toSigningCertificateLineage(getClass(), "rsa-2048-lineage-no-capabilities-first-signer");
    List<Boolean> expectedCapabilityValues = Arrays.asList(false, false, false, false, false);
    SignerConfig oldSignerConfig = Resources.toLineageSignerConfig(getClass(), FIRST_RSA_2048_SIGNER_RESOURCE_NAME);
    SignerCapabilities oldSignerCapabilities = lineage.getSignerCapabilities(oldSignerConfig);
    assertExpectedCapabilityValues(oldSignerCapabilities, expectedCapabilityValues);
    // The builder is called directly to ensure all of the capabilities are set to the default
    // values and the caller configured flags are not modified in this SignerCapabilities.
    SignerCapabilities newCapabilities = new SignerCapabilities.Builder().build();
    lineage.updateSignerCapabilities(oldSignerConfig, newCapabilities);
    SignerCapabilities updatedCapabilities = lineage.getSignerCapabilities(oldSignerConfig);
    assertExpectedCapabilityValues(updatedCapabilities, expectedCapabilityValues);
}
Also used : SignerConfig(com.android.apksig.SigningCertificateLineage.SignerConfig) SignerCapabilities(com.android.apksig.SigningCertificateLineage.SignerCapabilities) Test(org.junit.Test)

Aggregations

SignerCapabilities (com.android.apksig.SigningCertificateLineage.SignerCapabilities)6 SignerConfig (com.android.apksig.SigningCertificateLineage.SignerConfig)5 Test (org.junit.Test)5 File (java.io.File)2 SigningCertificateLineage (com.android.apksig.SigningCertificateLineage)1 RandomAccessFile (java.io.RandomAccessFile)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1