Skip to content

Commit 216076f

Browse files
authored
fix ntlm tests on platforms with broken gssapi (#123055)
... and use our own managed implementation instead. fixes #111639 contributes to #122371
1 parent d8182b2 commit 216076f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static partial class PlatformDetection
1818
public static bool IsLinux => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
1919
public static bool IsOpenSUSE => IsDistroAndVersion("opensuse");
2020
public static bool IsUbuntu => IsDistroAndVersion("ubuntu");
21+
public static bool IsUbuntu26 => IsDistroAndVersion("ubuntu", 26);
2122
public static bool IsUbuntu24 => IsDistroAndVersion("ubuntu", 24);
2223
public static bool IsUbuntu24OrHigher => IsDistroAndVersionOrHigher("ubuntu", 24);
2324
public static bool IsDebian => IsDistroAndVersion("debian");

src/libraries/System.Net.Security/tests/UnitTests/NegotiateAuthenticationTests.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,23 @@ namespace System.Net.Security.Tests
1717
{
1818
public class NegotiateAuthenticationTests
1919
{
20-
private static bool IsNtlmAvailable => Capability.IsNtlmInstalled() || OperatingSystem.IsAndroid() || OperatingSystem.IsTvOS();
20+
// Ubuntu 24 and 26 ship with broekn gss-ntlmssp 1.2
21+
private static bool UseManagedNtlm => PlatformDetection.IsUbuntu24 || PlatformDetection.IsUbuntu26;
22+
private static bool IsNtlmAvailable => UseManagedNtlm || Capability.IsNtlmInstalled() || OperatingSystem.IsAndroid() || OperatingSystem.IsTvOS();
2123
private static bool IsNtlmUnavailable => !IsNtlmAvailable;
2224

2325
private static NetworkCredential s_testCredentialRight = new NetworkCredential("rightusername", "rightpassword");
2426
private static NetworkCredential s_testCredentialWrong = new NetworkCredential("rightusername", "wrongpassword");
2527
private static readonly byte[] s_Hello = "Hello"u8.ToArray();
2628

29+
static NegotiateAuthenticationTests()
30+
{
31+
if (UseManagedNtlm)
32+
{
33+
AppContext.SetSwitch("System.Net.Security.UseManagedNtlm", true);
34+
}
35+
}
36+
2737
[Fact]
2838
public void Constructor_Overloads_Validation()
2939
{
@@ -85,7 +95,6 @@ public void Package_Supported_NTLM()
8595
}
8696

8797
[ConditionalFact(nameof(IsNtlmUnavailable))]
88-
[ActiveIssue("https://github.com/dotnet/runtime/issues/111639", typeof(PlatformDetection), nameof(PlatformDetection.IsUbuntu24OrHigher))]
8998
public void Package_Unsupported_NTLM()
9099
{
91100
NegotiateAuthenticationClientOptions clientOptions = new NegotiateAuthenticationClientOptions { Package = "NTLM", Credential = s_testCredentialRight, TargetName = "HTTP/foo" };

0 commit comments

Comments
 (0)