[tests] Use existing 'SecIdentity.Import' API instead of manually trying to do the same thing.#24432
[tests] Use existing 'SecIdentity.Import' API instead of manually trying to do the same thing.#24432rolfbjarne merged 4 commits intomainfrom
Conversation
…ing to do the same thing.
Hopefully fixes:
MonoTouchFixtures.CoreWlan.CWKeychainTests
[FAIL] TrySetWiFiEAPIdentityTest : ImportPkcs12
Expected: Success
But was: DuplicateItem
at MonoTouchFixtures.Security.IdentityTest.GetIdentity() in /Users/builder/azdo/_work/1/s/macios/tests/monotouch-test/Security/IdentityTest.cs:line 25
at MonoTouchFixtures.CoreWlan.CWKeychainTests.TrySetWiFiEAPIdentityTest() in /Users/builder/azdo/_work/1/s/macios/tests/monotouch-test/CoreWlan/CWKeychainTests.cs:line 94
Because 'SecImportExport.ImportPkcs12' will by default on macOS import into an
existing keychain (and is thus subject to 'DuplicateItem' problems); while
'SecIdentity.Import' will try to avoid using an existing keychain if
possible (which it is on macOS 15+, or all other platforms).
There was a problem hiding this comment.
Pull request overview
This PR simplifies test code for creating a SecIdentity instance by replacing manual SecImportExport.ImportPkcs12 calls with the higher-level SecIdentity.Import API. This change addresses test flakiness caused by DuplicateItem errors on macOS, where SecImportExport.ImportPkcs12 imports into the default keychain by default, leading to duplicate entries across test runs.
Key Changes:
- Replaced 6 lines of manual PKCS#12 import code with a single call to
SecIdentity.Import - Eliminates explicit NSDictionary/NSString setup and error handling from test helper method
- Leverages
SecIdentity.Import's built-in platform handling (uses in-memory keychain on macOS 15+)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #8e53f39] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #8e53f39] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #8e53f39] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #8e53f39] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #8e53f39] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [CI Build #8e53f39] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #8e53f39] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #8e53f39] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
🚀 [CI Build #8e53f39] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 117 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Hopefully fixes:
Because 'SecImportExport.ImportPkcs12' will by default on macOS import into an
existing keychain (and is thus subject to 'DuplicateItem' problems); while
'SecIdentity.Import' will try to avoid using an existing keychain if
possible (which it is on macOS 15+, or all other platforms).