Skip to content

Commit

Permalink
Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
afifi-ins committed Jul 23, 2024
1 parent ee19932 commit 7eef23d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
8 changes: 4 additions & 4 deletions azure-pipelines-arcade-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ variables:
- name: _RunAsInternal
value: false
- name: _RunWithCoreWcfService
value: true
value: false

- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- name: _RunAsPublic
Expand Down Expand Up @@ -128,6 +128,7 @@ stages:
-projects $(Build.SourcesDirectory)/eng/SendToHelix.proj
$(_TestArgs)
/p:TestJob=Windows
/p:RunWithCoreWcfService=$(_RunWithCoreWcfService)
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog
displayName: Windows - Run Helix Tests
env:
Expand All @@ -136,7 +137,6 @@ stages:
XUnitWorkItemTimeout: $(_xUnitWorkItemTimeout)
RunAsPublic: $(_RunAsPublic)
RunAsInternal: $(_RunAsInternal)
RunWithCoreWcfService: $(_RunWithCoreWcfService)
IsWindowsBuild: true

# Only build and test Linux in PR and CI builds.
Expand Down Expand Up @@ -190,14 +190,14 @@ stages:
--projects $(Build.SourcesDirectory)/eng/SendToHelix.proj
$(_TestArgs)
/p:TestJob=Linux
/p:RunWithCoreWcfService=$(_RunWithCoreWcfService)
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog
displayName: Linux - Run Helix Tests
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
ServiceHost: $(_serviceUri)
RunAsPublic: $(_RunAsPublic)
RunAsInternal: $(_RunAsInternal)
RunWithCoreWcfService: $(_RunWithCoreWcfService)
IsWindowsBuild: false

# Only build and test MacOS in PR and CI builds.
Expand Down Expand Up @@ -250,12 +250,12 @@ stages:
-projects $(Build.SourcesDirectory)/eng/SendToHelix.proj
$(_TestArgs)
/p:TestJob=MacOS
/p:RunWithCoreWcfService=$(_RunWithCoreWcfService)
/bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog
displayName: MacOS - Run Helix Tests
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
ServiceHost: $(_serviceUri)
RunAsPublic: $(_RunAsPublic)
RunAsInternal: $(_RunAsInternal)
RunWithCoreWcfService: $(_RunWithCoreWcfService)
IsWindowsBuild: false
5 changes: 2 additions & 3 deletions azure-pipelines-arcade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ variables:
- name: _RunAsInternal
value: true
- name: _RunWithCoreWcfService
value: true
value: false
- group: DotNet-Wcf-SDLValidation-Params
resources:
repositories:
Expand Down Expand Up @@ -97,15 +97,14 @@ extends:
clean: true
- script: eng\common\cibuild.cmd -configuration $(_BuildConfig) -preparemachine $(_InternalBuildArgs) $(_TestArgs) /p:Test=false
displayName: Windows Build / Publish
- powershell: eng\common\build.ps1 -configuration $(_BuildConfig) -preparemachine -ci -test -integrationTest -projects $(Build.SourcesDirectory)/eng/SendToHelix.proj $(_TestArgs) /p:TestJob=Windows /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog
- powershell: eng\common\build.ps1 -configuration $(_BuildConfig) -preparemachine -ci -test -integrationTest -projects $(Build.SourcesDirectory)/eng/SendToHelix.proj $(_TestArgs) /p:TestJob=Windows /p:RunWithCoreWcfService=$(_RunWithCoreWcfService) /bl:$(Build.SourcesDirectory)/artifacts/log/$(_BuildConfig)/SendToHelix.binlog
displayName: Windows - Run Helix Tests
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
HelixAccessToken: $(HelixApiAccessToken)
XUnitWorkItemTimeout: $(_xUnitWorkItemTimeout)
RunAsPublic: $(_RunAsPublic)
RunAsInternal: $(_RunAsInternal)
RunWithCoreWcfService: $(_RunWithCoreWcfService)
IsWindowsBuild: true
- ${{ if eq(variables._RunAsInternal, True) }}:
- template: /eng/common/templates-official/post-build/post-build.yml@self
Expand Down
8 changes: 4 additions & 4 deletions eng/SendToHelix.proj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<TestRunNamePrefix>$(AGENT_JOBNAME)</TestRunNamePrefix>
<EnableXUnitReporter>true</EnableXUnitReporter>
</PropertyGroup>

<Target Name="InstallDotNet">
<ItemGroup>
<AdditionalDotNetPackage Include="8.0.5">
Expand Down Expand Up @@ -71,10 +71,10 @@
</PropertyGroup>

<PropertyGroup>
<RunWithCoreWcfService>false</RunWithCoreWcfService>
<RunWithCoreWCFService Condition="'$(RunWithCoreWCFService)' == ''">false</RunWithCoreWCFService>
</PropertyGroup>

<PropertyGroup Condition="'$(RunWithCoreWcfService)' == 'false' AND '$(TestJob)' == 'Linux'" >
<PropertyGroup Condition="'$(RunWithCoreWcfService)' == 'false' AND '$(TestJob)' != 'Windows'" >
<HelixPreCommands>$(HelixPreCommands);chmod a+x $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);sudo -E -n $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh --service-host $(ServiceHost) --cert-file /tmp/wcfrootca.crt</HelixPreCommands>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ public class CertificateGeneratorLibrary
private static void RemoveCertificatesFromStore(StoreName storeName, StoreLocation storeLocation)
{
X509Store store = CertificateHelper.GetX509Store(storeName, storeLocation);
Console.WriteLine(" Checking StoreName '{0}'", storeName);
Console.WriteLine(" Checking StoreName '{0}', StoreLocation '{1}'", storeName, store.Location);
{
store.Open(OpenFlags.ReadWrite | OpenFlags.IncludeArchived);
if (!CertificateHelper.CurrentOperatingSystem.IsMacOS())
{
store.Open(OpenFlags.ReadWrite | OpenFlags.IncludeArchived);
}

foreach (var cert in store.Certificates.Find(X509FindType.FindByIssuerName, CertificateIssuer, false))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static X509Store GetX509Store(StoreName storeName, StoreLocation storeLoc
else if (CurrentOperatingSystem.IsMacOS())
{
// MacOS SafeKeychainHandle
GetMacOSX509Store();
store = GetMacOSX509Store();
}
return store;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ public static bool AddToStoreIfNeeded(StoreName storeName, StoreLocation storeLo
try
{
store = CertificateHelper.GetX509Store(storeName, storeLocation);

// We assume Bridge is running elevated
store.Open(OpenFlags.ReadWrite);
if (!CertificateHelper.CurrentOperatingSystem.IsMacOS())
{
store.Open(OpenFlags.ReadWrite);
}
existingCert = CertificateFromThumbprint(store, certificate.Thumbprint);
if (existingCert == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ public static X509Certificate2 CertificateFromSubject(StoreName name, StoreLocat
try
{
store = CertificateHelper.GetX509Store(name, location);
store.Open(OpenFlags.ReadOnly);
if (!store.IsOpen)
{
store.Open(OpenFlags.ReadOnly);
}
X509Certificate2Collection foundCertificates = store.Certificates.Find(X509FindType.FindBySubjectName, subjectName, validOnly: true);
return foundCertificates.Count == 0 ? null : foundCertificates[0];
}
Expand All @@ -234,7 +237,10 @@ public static X509Certificate2 CertificateFromFriendlyName(StoreName name, Store
try
{
store = CertificateHelper.GetX509Store(name, location);
store.Open(OpenFlags.ReadOnly);
if (!store.IsOpen)
{
store.Open(OpenFlags.ReadOnly);
}

X509Certificate2Collection foundCertificates = store.Certificates.Find(X509FindType.FindByIssuerName, "DO_NOT_TRUST_WcfBridgeRootCA", false);
string friendlyNameHash = CertificateGenerator.HashFriendlyNameToString(friendlyName);
Expand Down

0 comments on commit 7eef23d

Please sign in to comment.