Remove checked-in test.keystore and generate it dynamically during tests - #10923
Conversation
- Delete test.keystore binary from Resources/Base/ - Update ResourceData.GetKeystore() to generate keystore via keytool - Add ResourceData.GenerateKeystore() shared helper - Update KeyToolTests.GetValidKeyStore() to use AndroidCreateDebugKey task - Update TestApks.targets to generate keystore via Exec before DeployTestAabs - Remove test.keystore suppression from .gdn/.gdnsuppress Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
…s directly Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
jonathanpeppers
left a comment
There was a problem hiding this comment.
🤖 AI Review Summary
Verdict:
Found 1 issue across 5 changed files.
⚠️ MSBuild targets:_KeytoolPathuses hardcoded backslash\but the target is cross-platform (TestApks.targets:224)
CI Status
Linux build ✅ passed. Mac and Windows builds still in progress — review will need re-validation once CI completes.
What's Good
- 👍 Thread-safe caching in
ResourceData.GetKeystore()with properlock+ null check pattern - 👍
GenerateKeystore()exposed as a reusable public helper with sensible defaults - 👍
KeyToolTests.cscorrectly uses theAndroidCreateDebugKeyMSBuild task (the system under test) to generate its test keystore - 👍
!Existsguard on the<Exec>prevents redundant regeneration - 👍 Proper cleanup of temp keystore in
finallyblock - 👍 Good error reporting with stderr capture in
GenerateKeystore() - 👍 Signature change from
GetKeystore(string)→GetKeystore()is safe — all 3 callers inInstallTests.csuse the parameterless form - 👍
.csprojdoesn't need updating — the wildcardResources\**\*glob naturally stops matching the deleted file
Review generated by android-reviewer from review guidelines.
There was a problem hiding this comment.
Pull request overview
This PR removes the checked-in test.keystore binary (which triggers credential scanning) and replaces it with keystore generation at test time to eliminate ongoing suppression maintenance.
Changes:
- Removed
test.keystorefromXamarin.ProjectToolsresources. - Updated
ResourceData.GetKeystore()to generate and cache a keystore dynamically viakeytool. - Updated test/build flows to generate keystores on demand (unit tests via
AndroidCreateDebugKey, AAB deploy via MSBuildExec), and removed the related.gdnsuppression.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ResourceData.cs |
Replaces embedded keystore loading with on-the-fly keystore generation and caching. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/KeyToolTests.cs |
Generates a valid keystore for tests using AndroidCreateDebugKey instead of an embedded resource. |
build-tools/scripts/TestApks.targets |
Generates test.keystore at build/test time for AAB deployment rather than relying on a repo file. |
.gdn/.gdnsuppress |
Removes the suppression entry that was only needed for the checked-in keystore. |
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/test.keystore |
Deleted binary keystore from the repository. |
The default keystore format varies by JDK version (JKS before JDK 9, PKCS12 from JDK 9+). Explicitly specifying -storetype pkcs12 ensures consistent behavior regardless of the JDK version used. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot there is one test failure: I think we can just update the assertion. |
Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
... Updated the assertion in 0937840. The PKCS12 format produces |
Binary
test.keystorechecked into the repo triggers credential scanning warnings requiring ongoing suppression maintenance. Replace with dynamic generation at test time.Changes
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/test.keystoreResourceData.cs—GetKeystore()now generates a keystore viakeytoolprocess, cached per test run with thread-safe locking. AddedGenerateKeystore()public helper.KeyToolTests.cs—GetValidKeyStore()usesAndroidCreateDebugKeytask instead of extracting the embedded resourceTestApks.targets—DeployTestAabsgenerates keystore into$(IntermediateOutputPath)viaExeckeytool, gated by!Existscondition. Platform-aware keytool path via$(HostOS)..gdn/.gdnsuppress— Remove the now-unnecessary test.keystore suppression entryKeystore generation
All generated keystores use the same parameters as the original:
Callers of
ResourceData.GetKeystore()(e.g.,InstallTests.cs) required no changes — the method signature is preserved, only the backing implementation changed from embedded resource to dynamic generation.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.