-
Notifications
You must be signed in to change notification settings - Fork 549
[tests] Use existing 'SecIdentity.Import' API instead of manually trying to do the same thing. #24432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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+)
✅ [CI Build #f449a5b] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #f449a5b] 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 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #f449a5b] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #f449a5b] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
💻 [CI Build #f449a5b] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #f449a5b] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
💻 [CI Build #f449a5b] 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.
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 #f449a5b] Tests on macOS arm64 - Mac Sequoia (15) failed ❌Failed tests are:
Pipeline on Agent |
🔥 [CI Build #f449a5b] Test results 🔥Test results❌ Tests failed on VSTS: test results 0 tests crashed, 2 tests failed, 115 tests passed. Failures❌ monotouch tests (macOS) [attempt 5]2 tests failed, 7 tests passed.Failed tests
Html Report (VSDrops) Download Successes✅ 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).