|
6 | 6 | using System.Collections.Generic;
|
7 | 7 | using System.Linq;
|
8 | 8 | using System.Reflection;
|
| 9 | +using System.Runtime.InteropServices; |
9 | 10 | using System.Security.Cryptography.X509Certificates;
|
10 | 11 | using System.Security.Principal;
|
11 | 12 | using System.Text;
|
@@ -495,22 +496,24 @@ public override IEnumerable<Object[]> GetData(MethodInfo testMethod)
|
495 | 496 | {
|
496 | 497 | yield return new object[2] { StoreLocation.CurrentUser, CurrentUserMyPathPrefix };
|
497 | 498 | // use localmachine cert path only when current user is Admin.
|
498 |
| - if (CertificateFixture.IsAdmin) |
| 499 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && CertificateFixture.IsAdmin) |
499 | 500 | {
|
500 | 501 | yield return new object[2] { StoreLocation.LocalMachine, LocalMachineMyPathPrefix };
|
501 | 502 | }
|
502 | 503 | }
|
503 | 504 | }
|
504 | 505 |
|
| 506 | + |
505 | 507 | public class ValidCertificatePathsParameters : DataAttribute
|
506 | 508 | {
|
| 509 | + |
507 | 510 | public override IEnumerable<Object[]> GetData(MethodInfo testMethod)
|
508 | 511 | {
|
509 | 512 | yield return new object[2] { CurrentUserMyPathPrefix, StoreLocation.CurrentUser };
|
510 | 513 | yield return new object[2] { MyPathPrefix, null };
|
511 | 514 | yield return new object[2] { @"", null };
|
512 | 515 | // use localmachine cert path only when current user is Admin.
|
513 |
| - if (CertificateFixture.IsAdmin) |
| 516 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && CertificateFixture.IsAdmin) |
514 | 517 | {
|
515 | 518 | yield return new object[2] { LocalMachineMyPathPrefix, StoreLocation.LocalMachine };
|
516 | 519 | }
|
@@ -653,7 +656,7 @@ public CertificateFixture()
|
653 | 656 | AddCertificateToStore(certificate1, StoreLocation.CurrentUser);
|
654 | 657 | AddCertificateToStore(certificate2, StoreLocation.CurrentUser);
|
655 | 658 | AddCertificateToStore(certificate3, StoreLocation.CurrentUser);
|
656 |
| - if (IsAdmin) |
| 659 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && IsAdmin) |
657 | 660 | {
|
658 | 661 | AddCertificateToStore(certificate3, StoreLocation.LocalMachine);
|
659 | 662 | }
|
|
0 commit comments