Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrozsival committed Jun 19, 2024
1 parent 86327ef commit 49663a6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,16 @@ await LoopbackServer.CreateServerAsync(async server =>
}
}

[ConditionalFact]
[PlatformSpecific(TestPlatforms.Android)]
#if TARGETS_ANDROID
[Fact]
public async Task Android_GetCertificateFromKeyStoreViaAlias()
{
#if TARGETS_ANDROID
var options = new LoopbackServer.Options { UseSsl = true };

var (store, alias) = AndroidKeyStoreHelper.AddCertificate(Configuration.Certificates.GetClientCertificate());
(X509Store store, string alias) = AndroidKeyStoreHelper.AddCertificate(Configuration.Certificates.GetClientCertificate());
try
{
var clientCertificate = AndroidKeyStoreHelper.GetCertificateViaAlias(store, alias);
X509Certificate2 clientCertificate = AndroidKeyStoreHelper.GetCertificateViaAlias(store, alias);
Assert.True(clientCertificate.HasPrivateKey);

await LoopbackServer.CreateServerAsync(async (server, url) =>
Expand Down Expand Up @@ -247,10 +246,7 @@ await TestHelper.WhenAllCompletedOrAnyFailed(
Assert.True(AndroidKeyStoreHelper.DeleteAlias(store, alias));
store.Dispose();
}
#else
await Task.CompletedTask;
throw new SkipTestException("Android-specific test");
#endif
}
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static (X509Store, string) AddCertificate(X509Certificate2 cert)

public static X509Certificate2 GetCertificateViaAlias(X509Store store, string alias)
{
var privateKeyEntry = Interop.AndroidCrypto.X509StoreGetPrivateKeyEntry(store.StoreHandle, alias);
IntPtr privateKeyEntry = Interop.AndroidCrypto.X509StoreGetPrivateKeyEntry(store.StoreHandle, alias);
return new X509Certificate2(privateKeyEntry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<DefineConstants>$(DefineConstants);SYSNETHTTP_NO_OPENSSL;HTTP3</DefineConstants>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx</TargetFrameworks>
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-linux;$(NetCoreAppCurrent)-android;$(NetCoreAppCurrent)-browser;$(NetCoreAppCurrent)-osx</TargetFrameworks>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<EventSourceSupport Condition="'$(TestNativeAot)' == 'true'">true</EventSourceSupport>
</PropertyGroup>
Expand All @@ -29,7 +29,7 @@
<WasmXHarnessTestsTimeout>01:15:00</WasmXHarnessTestsTimeout>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetsAndroid)' == 'true'">
<PropertyGroup Condition="'$(TargetPlatformIdentifier)' == 'android'">
<DefineConstants>$(DefineConstants);TARGETS_ANDROID</DefineConstants>
</PropertyGroup>

Expand Down Expand Up @@ -237,7 +237,7 @@
<Compile Include="ImpersonatedAuthTests.cs" />
</ItemGroup>
<!-- Linux specific files -->
<ItemGroup Condition="('$(TargetPlatformIdentifier)' == 'linux' and '$(TargetsAndroid)' != 'true') or '$(TargetPlatformIdentifier)' == 'browser'">
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'linux' or '$(TargetPlatformIdentifier)' == 'browser'">
<Compile Include="$(CommonPath)Interop\Linux\Interop.Libraries.cs"
Link="Common\Interop\Linux\Interop.Libraries.cs" />
</ItemGroup>
Expand All @@ -247,7 +247,7 @@
Link="Common\Interop\OSX\Interop.Libraries.cs" />
</ItemGroup>
<!-- Android specific files -->
<ItemGroup Condition=" '$(TargetsAndroid)' == 'true' ">
<ItemGroup Condition=" '$(TargetPlatformIdentifier)' == 'android' ">
<Compile Include="AndroidKeyStoreHelper.cs" />
<Compile Include="$(CommonPath)Interop\Android\Interop.Libraries.cs"
Link="Common\Interop\Android\Interop.Libraries.cs" />
Expand Down

0 comments on commit 49663a6

Please sign in to comment.