Skip to content

Remove checked-in test.keystore and generate it dynamically during tests #10922

Description

@jonathanpeppers

Problem

The file src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/test.keystore is a binary keystore checked into the repository. This triggers credential scanning warnings because the keystore and its passwords (android / mykey) are committed to source control.

While this is a harmless test-only keystore, it creates ongoing compliance noise and suppression maintenance.

Proposed Solution

Delete test.keystore from the repo and generate it dynamically at test time using keytool:

keytool -genkeypair -v -keystore test.keystore -alias mykey -keyalg RSA -keysize 2048 -validity 10000 -storepass android -keypass android -dname "CN=Test, OU=Test, O=Test, L=Test, ST=Test, C=US"

Files that need updating:

  1. ResourceData.cs - GetKeystore() helper that loads test.keystore as an embedded resource. Change to generate a keystore on-the-fly or from a shared test fixture.
  2. KeyToolTests.cs - GetValidKeyStore() extracts the embedded keystore to a temp file. Change to generate it.
  3. InstallTests.cs - ChangeKeystoreRedeploy and TestAndroidStoreKey tests add test.keystore as a BuildItem with BinaryContent. Change to use a dynamically generated keystore.
  4. build-tools/scripts/TestApks.targets - DeployTestAabs target references the keystore by full path on disk. Change to generate before use.
  5. .gdn/.gdnsuppress - Remove the suppression entry for test.keystore since the file will no longer exist.
  6. Xamarin.ProjectTools.csproj - Remove the embedded resource entry for test.keystore.

Approach

A helper method (e.g., in ResourceData.cs or a new test utility) could generate a keystore once per test run into a temp directory, and all consumers reference it from there. This keeps the same test coverage while eliminating the checked-in credential.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions