Skip to content

Commit 42a69a4

Browse files
committed
Fixing some tests in Linux and skipping some in Open SUSE given it doesn't yet have libldap installed
1 parent cf49452 commit 42a69a4

17 files changed

+158
-110
lines changed

src/libraries/System.DirectoryServices.Protocols/src/System.DirectoryServices.Protocols.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<AssemblyName>System.DirectoryServices.Protocols</AssemblyName>
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -40,6 +40,7 @@
4040
<Compile Include="System\DirectoryServices\Protocols\Interop\SafeHandles.cs" />
4141
</ItemGroup>
4242
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
43+
<Compile Include="System\DirectoryServices\Protocols\common\BerConverter.Windows.cs" />
4344
<Compile Include="System\DirectoryServices\Protocols\Interop\LdapPal.Windows.cs" />
4445
<Compile Include="System\DirectoryServices\Protocols\ldap\LdapConnection.Windows.cs" />
4546
<Compile Include="System\DirectoryServices\Protocols\ldap\LdapSessionOptions.Windows.cs" />
@@ -55,6 +56,7 @@
5556
</Compile>
5657
</ItemGroup>
5758
<ItemGroup Condition="'$(TargetsLinux)' == 'true'">
59+
<Compile Include="System\DirectoryServices\Protocols\common\BerConverter.Linux.cs" />
5860
<Compile Include="System\DirectoryServices\Protocols\Interop\LdapPal.Linux.cs" />
5961
<Compile Include="System\DirectoryServices\Protocols\ldap\LdapConnection.Linux.cs" />
6062
<Compile Include="System\DirectoryServices\Protocols\ldap\LdapSessionOptions.Linux.cs" />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Collections;
6+
7+
namespace System.DirectoryServices.Protocols
8+
{
9+
public static partial class BerConverter
10+
{
11+
private static unsafe int DecodeBitStringHelper(ArrayList resultList, SafeBerHandle berElement)
12+
{
13+
// Windows doesn't really decode BitStrings correctly, and wldap32 will internally treat it as 'O' Octet string.
14+
// In order to match behavior, in Linux we will interpret 'B' as 'O' when passing the call to libldap.
15+
16+
int error = 0;
17+
// return berval
18+
byte[] byteArray = DecodingByteArrayHelper(berElement, 'O', ref error);
19+
if (!LdapPal.IsBerDecodeError(error))
20+
{
21+
// add result to the list
22+
resultList.Add(byteArray);
23+
}
24+
25+
return error;
26+
}
27+
}
28+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Collections;
6+
using System.Diagnostics;
7+
using System.Runtime.InteropServices;
8+
9+
namespace System.DirectoryServices.Protocols
10+
{
11+
public static partial class BerConverter
12+
{
13+
private static unsafe int DecodeBitStringHelper(ArrayList resultList, SafeBerHandle berElement)
14+
{
15+
int error;
16+
// return a bitstring and its length
17+
IntPtr ptrResult = IntPtr.Zero;
18+
int length = 0;
19+
error = LdapPal.BerScanfBitstring(berElement, "B", ref ptrResult, ref length);
20+
21+
if (!LdapPal.IsBerDecodeError(error))
22+
{
23+
byte[] byteArray = null;
24+
if (ptrResult != IntPtr.Zero)
25+
{
26+
byteArray = new byte[length];
27+
Marshal.Copy(ptrResult, byteArray, 0, length);
28+
}
29+
resultList.Add(byteArray);
30+
}
31+
else
32+
Debug.WriteLine("ber_scanf for format character 'B' failed");
33+
34+
// no need to free memory as wldap32 returns the original pointer instead of a duplicating memory pointer that
35+
// needs to be freed
36+
return error;
37+
}
38+
}
39+
}

src/libraries/System.DirectoryServices.Protocols/src/System/DirectoryServices/Protocols/common/BerConverter.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Collections;
56
using System.Diagnostics;
6-
using System.Globalization;
77
using System.Runtime.InteropServices;
8-
using System.Collections;
98
using System.Text;
10-
using System.Runtime.CompilerServices;
119

1210
namespace System.DirectoryServices.Protocols
1311
{
14-
public static class BerConverter
12+
public static partial class BerConverter
1513
{
1614
public static byte[] Encode(string format, params object[] value)
1715
{
@@ -363,26 +361,7 @@ internal static unsafe object[] TryDecode(string format, byte[] value, out bool
363361
}
364362
else if (fmt == 'B')
365363
{
366-
// return a bitstring and its length
367-
IntPtr ptrResult = IntPtr.Zero;
368-
int length = 0;
369-
error = LdapPal.BerScanfBitstring(berElement, "B", ref ptrResult, ref length);
370-
371-
if (!LdapPal.IsBerDecodeError(error))
372-
{
373-
byte[] byteArray = null;
374-
if (ptrResult != IntPtr.Zero)
375-
{
376-
byteArray = new byte[length];
377-
Marshal.Copy(ptrResult, byteArray, 0, length);
378-
}
379-
resultList.Add(byteArray);
380-
}
381-
else
382-
Debug.WriteLine("ber_scanf for format character 'B' failed");
383-
384-
// no need to free memory as wldap32 returns the original pointer instead of a duplicating memory pointer that
385-
// needs to be freed
364+
error = DecodeBitStringHelper(resultList, berElement);
386365
}
387366
else if (fmt == 'v')
388367
{

src/libraries/System.DirectoryServices.Protocols/tests/AsqRequestControlTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace System.DirectoryServices.Protocols.Tests
99
{
10+
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsOpenSUSE))]
1011
public class AsqRequestControlTests
1112
{
1213
[Fact]

src/libraries/System.DirectoryServices.Protocols/tests/BerConverterTests.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,37 @@
77

88
namespace System.DirectoryServices.Protocols.Tests
99
{
10+
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsOpenSUSE))]
1011
public class BerConverterTests
1112
{
12-
public static bool RunningOnWindows => Environment.OSVersion.Platform == PlatformID.Win32NT;
13-
1413
public static IEnumerable<object[]> Encode_TestData()
1514
{
1615
yield return new object[] { "", null, new byte[0] };
1716
yield return new object[] { "", new object[10], new byte[0] };
1817
yield return new object[] { "b", new object[] { true, false, true, false }, new byte[] { 1, 1, 255 } };
1918

20-
if (RunningOnWindows)
19+
if (PlatformDetection.IsWindows)
2120
{
2221
yield return new object[] { "{", new object[] { "a" }, new byte[] { 48, 0, 0, 0, 0, 0 } }; // This format is not supported by Linux OpenLDAP
2322
}
24-
yield return new object[] { "{}", new object[] { "a" }, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 0 } : new byte[] { 48, 0 } };
25-
if (RunningOnWindows)
23+
yield return new object[] { "{}", new object[] { "a" }, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 0 } : new byte[] { 48, 0 } };
24+
if (PlatformDetection.IsWindows)
2625
{
2726
yield return new object[] { "[", new object[] { "a" }, new byte[] { 49, 0, 0, 0, 0, 0 } }; // This format is not supported by Linux OpenLDAP
2827
}
29-
yield return new object[] { "[]", new object[] { "a" }, (RunningOnWindows) ? new byte[] { 49, 132, 0, 0, 0, 0 } : new byte[] { 49, 0 } };
28+
yield return new object[] { "[]", new object[] { "a" }, (PlatformDetection.IsWindows) ? new byte[] { 49, 132, 0, 0, 0, 0 } : new byte[] { 49, 0 } };
3029
yield return new object[] { "n", new object[] { "a" }, new byte[] { 5, 0 } };
3130

32-
yield return new object[] { "tetie", new object[] { -1, 0, 1, 2, 3 }, (RunningOnWindows) ? new byte[] { 255, 1, 0, 1, 1, 2, 10, 1, 3 } : new byte[] { 10, 1, 0, 1, 1, 2, 10, 1, 3 } };
33-
yield return new object[] { "{tetie}", new object[] { -1, 0, 1, 2, 3 }, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 9, 255, 1, 0, 1, 1, 2, 10, 1, 3 } : new byte[] { 48, 9, 10, 1, 0, 1, 1, 2, 10, 1, 3 } };
31+
yield return new object[] { "tetie", new object[] { -1, 0, 1, 2, 3 }, (PlatformDetection.IsWindows) ? new byte[] { 255, 1, 0, 1, 1, 2, 10, 1, 3 } : new byte[] { 10, 1, 0, 1, 1, 2, 10, 1, 3 } };
32+
yield return new object[] { "{tetie}", new object[] { -1, 0, 1, 2, 3 }, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 9, 255, 1, 0, 1, 1, 2, 10, 1, 3 } : new byte[] { 48, 9, 10, 1, 0, 1, 1, 2, 10, 1, 3 } };
3433

3534
yield return new object[] { "bb", new object[] { true, false }, new byte[] { 1, 1, 255, 1, 1, 0 } };
36-
yield return new object[] { "{bb}", new object[] { true, false }, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 } : new byte[] { 48, 6, 1, 1, 255, 1, 1, 0 } };
35+
yield return new object[] { "{bb}", new object[] { true, false }, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 } : new byte[] { 48, 6, 1, 1, 255, 1, 1, 0 } };
3736

3837
yield return new object[] { "ssss", new object[] { null, "", "abc", "\0" }, new byte[] { 4, 0, 4, 0, 4, 3, 97, 98, 99, 4, 1, 0 } };
39-
yield return new object[] { "oXo", new object[] { null, new byte[] { 0, 1, 2, 255 }, new byte[0] }, (RunningOnWindows) ? new byte[] { 4, 0, 3, 4, 0, 1, 2, 255, 4, 0 } : new byte[] { 4, 0, 3, 2, 4, 0, 4, 0 } };
38+
yield return new object[] { "oXo", new object[] { null, new byte[] { 0, 1, 2, 255 }, new byte[0] }, (PlatformDetection.IsWindows) ? new byte[] { 4, 0, 3, 4, 0, 1, 2, 255, 4, 0 } : new byte[] { 4, 0, 3, 2, 4, 0, 4, 0 } };
4039
yield return new object[] { "vv", new object[] { null, new string[] { "abc", "", null } }, new byte[] { 4, 3, 97, 98, 99, 4, 0, 4, 0 } };
41-
yield return new object[] { "{vv}", new object[] { null, new string[] { "abc", "", null } }, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 9, 4, 3, 97, 98, 99, 4, 0, 4, 0 } : new byte[] { 48, 9, 4, 3, 97, 98, 99, 4, 0, 4, 0 } };
40+
yield return new object[] { "{vv}", new object[] { null, new string[] { "abc", "", null } }, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 9, 4, 3, 97, 98, 99, 4, 0, 4, 0 } : new byte[] { 48, 9, 4, 3, 97, 98, 99, 4, 0, 4, 0 } };
4241
yield return new object[] { "VVVV", new object[] { null, new byte[][] { new byte[] { 0, 1, 2, 3 }, null }, new byte[][] { new byte[0] }, new byte[0][] }, new byte[] { 4, 4, 0, 1, 2, 3, 4, 0, 4, 0 } };
4342
}
4443

@@ -120,10 +119,13 @@ public static IEnumerable<object[]> Decode_TestData()
120119
yield return new object[] { "{bb}", new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 }, new object[] { true, false } };
121120
yield return new object[] { "{OO}", new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 }, new object[] { new byte[] { 255 }, new byte[] { 0 } } };
122121
yield return new object[] { "{BB}", new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 }, new object[] { new byte[] { 255 }, new byte[] { 0 } } };
123-
yield return new object[] { "{vv}", new byte[] { 48, 132, 0, 0, 0, 9, 4, 3, 97, 98, 99, 4, 0, 4, 0 }, new object[] { null, null } };
124-
yield return new object[] { "{vv}", new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 }, new object[] { new string[] { "\x01" }, null } };
125-
yield return new object[] { "{VV}", new byte[] { 48, 132, 0, 0, 0, 9, 4, 3, 97, 98, 99, 4, 0, 4, 0 }, new object[] { null, null } };
126-
yield return new object[] { "{VV}", new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 }, new object[] { new byte[][] { new byte[] { 1 } }, null } };
122+
if (PlatformDetection.IsWindows) // vv and VV formats are not supported yet in Linux
123+
{
124+
yield return new object[] { "{vv}", new byte[] { 48, 132, 0, 0, 0, 9, 4, 3, 97, 98, 99, 4, 0, 4, 0 }, new object[] { null, null } };
125+
yield return new object[] { "{vv}", new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 }, new object[] { new string[] { "\x01" }, null } };
126+
yield return new object[] { "{VV}", new byte[] { 48, 132, 0, 0, 0, 9, 4, 3, 97, 98, 99, 4, 0, 4, 0 }, new object[] { null, null } };
127+
yield return new object[] { "{VV}", new byte[] { 48, 132, 0, 0, 0, 6, 1, 1, 255, 1, 1, 0 }, new object[] { new byte[][] { new byte[] { 1 } }, null } };
128+
}
127129
}
128130

129131
[Theory]

src/libraries/System.DirectoryServices.Protocols/tests/DirSyncRequestControlTests.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
namespace System.DirectoryServices.Protocols.Tests
99
{
10+
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsOpenSUSE))]
1011
public class DirSyncRequestControlTests
1112
{
12-
public static bool RunningOnWindows => Environment.OSVersion.Platform == PlatformID.Win32NT;
13-
1413
[Fact]
1514
public void Ctor_Default()
1615
{
@@ -23,15 +22,15 @@ public void Ctor_Default()
2322
Assert.True(control.ServerSide);
2423
Assert.Equal("1.2.840.113556.1.4.841", control.Type);
2524

26-
var expected = (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 };
25+
var expected = (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 };
2726
Assert.Equal(expected, control.GetValue());
2827
}
2928

3029
public static IEnumerable<object[]> Ctor_Cookie_Data()
3130
{
32-
yield return new object[] { null, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } };
33-
yield return new object[] { new byte[0], (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } };
34-
yield return new object[] { new byte[] { 97, 98, 99 }, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 13, 2, 1, 0, 2, 3, 16, 0, 0, 4, 3, 97, 98, 99 } : new byte[] { 48, 13, 2, 1, 0, 2, 3, 16, 0, 0, 4, 3, 97, 98, 99 } };
31+
yield return new object[] { null, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } };
32+
yield return new object[] { new byte[0], (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } };
33+
yield return new object[] { new byte[] { 97, 98, 99 }, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 13, 2, 1, 0, 2, 3, 16, 0, 0, 4, 3, 97, 98, 99 } : new byte[] { 48, 13, 2, 1, 0, 2, 3, 16, 0, 0, 4, 3, 97, 98, 99 } };
3534
}
3635

3736
[Theory]
@@ -52,9 +51,9 @@ public void Ctor_Cookie(byte[] cookie, byte[] expectedValue)
5251

5352
public static IEnumerable<object[]> Ctor_Cookie_Options_Data()
5453
{
55-
yield return new object[] { null, DirectorySynchronizationOptions.None, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } };
56-
yield return new object[] { new byte[0], DirectorySynchronizationOptions.None - 1, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 13, 2, 4, 255, 255, 255, 255, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 255, 2, 3, 16, 0, 0, 4, 0 } };
57-
yield return new object[] { new byte[] { 97, 98, 99 }, DirectorySynchronizationOptions.ObjectSecurity, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 13, 2, 1, 1, 2, 3, 16, 0, 0, 4, 3, 97, 98, 99 } : new byte[] { 48, 13, 2, 1, 1, 2, 3, 16, 0, 0, 4, 3, 97, 98, 99 } };
54+
yield return new object[] { null, DirectorySynchronizationOptions.None, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } };
55+
yield return new object[] { new byte[0], DirectorySynchronizationOptions.None - 1, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 13, 2, 4, 255, 255, 255, 255, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 255, 2, 3, 16, 0, 0, 4, 0 } };
56+
yield return new object[] { new byte[] { 97, 98, 99 }, DirectorySynchronizationOptions.ObjectSecurity, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 13, 2, 1, 1, 2, 3, 16, 0, 0, 4, 3, 97, 98, 99 } : new byte[] { 48, 13, 2, 1, 1, 2, 3, 16, 0, 0, 4, 3, 97, 98, 99 } };
5857
}
5958

6059
[Theory]
@@ -75,9 +74,9 @@ public void Ctor_Cookie_Options(byte[] cookie, DirectorySynchronizationOptions o
7574

7675
public static IEnumerable<object[]> Ctor_Cookie_Options_AttributeCount_Data()
7776
{
78-
yield return new object[] { null, DirectorySynchronizationOptions.None, 1048576, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } };
79-
yield return new object[] { new byte[0], DirectorySynchronizationOptions.None - 1, 0, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 11, 2, 4, 255, 255, 255, 255, 2, 1, 0, 4, 0 } : new byte[] { 48, 8, 2, 1, 255, 2, 1, 0, 4, 0 } };
80-
yield return new object[] { new byte[] { 97, 98, 99 }, DirectorySynchronizationOptions.ObjectSecurity, 10, (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 11, 2, 1, 1, 2, 1, 10, 4, 3, 97, 98, 99 } : new byte[] { 48, 11, 2, 1, 1, 2, 1, 10, 4, 3, 97, 98, 99 } };
77+
yield return new object[] { null, DirectorySynchronizationOptions.None, 1048576, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } : new byte[] { 48, 10, 2, 1, 0, 2, 3, 16, 0, 0, 4, 0 } };
78+
yield return new object[] { new byte[0], DirectorySynchronizationOptions.None - 1, 0, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 11, 2, 4, 255, 255, 255, 255, 2, 1, 0, 4, 0 } : new byte[] { 48, 8, 2, 1, 255, 2, 1, 0, 4, 0 } };
79+
yield return new object[] { new byte[] { 97, 98, 99 }, DirectorySynchronizationOptions.ObjectSecurity, 10, (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 11, 2, 1, 1, 2, 1, 10, 4, 3, 97, 98, 99 } : new byte[] { 48, 11, 2, 1, 1, 2, 1, 10, 4, 3, 97, 98, 99 } };
8180
}
8281

8382
[Theory]

src/libraries/System.DirectoryServices.Protocols/tests/ExtendedDNControlTests.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77

88
namespace System.DirectoryServices.Protocols.Tests
99
{
10+
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsOpenSUSE))]
1011
public class ExtendedDNControlTests
1112
{
12-
public static bool RunningOnWindows => Environment.OSVersion.Platform == PlatformID.Win32NT;
13-
1413
[Fact]
1514
public void Ctor_Default()
1615
{
@@ -20,7 +19,7 @@ public void Ctor_Default()
2019
Assert.True(control.ServerSide);
2120
Assert.Equal("1.2.840.113556.1.4.529", control.Type);
2221

23-
var expected = (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 3, 2, 1, 0 } : new byte[] { 48, 3, 2, 1, 0 };
22+
var expected = (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 3, 2, 1, 0 } : new byte[] { 48, 3, 2, 1, 0 };
2423
Assert.Equal(expected, control.GetValue());
2524
}
2625

@@ -33,7 +32,7 @@ public void Ctor_Flag()
3332
Assert.True(control.ServerSide);
3433
Assert.Equal("1.2.840.113556.1.4.529", control.Type);
3534

36-
var expected = (RunningOnWindows) ? new byte[] { 48, 132, 0, 0, 0, 3, 2, 1, 1 } : new byte[] { 48, 3, 2, 1, 1 };
35+
var expected = (PlatformDetection.IsWindows) ? new byte[] { 48, 132, 0, 0, 0, 3, 2, 1, 1 } : new byte[] { 48, 3, 2, 1, 1 };
3736
Assert.Equal(expected, control.GetValue());
3837
}
3938

src/libraries/System.DirectoryServices.Protocols/tests/LdapConnectionTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
namespace System.DirectoryServices.Protocols.Tests
1414
{
15+
[ConditionalClass(typeof(PlatformDetection), nameof(PlatformDetection.IsOpenSUSE))]
1516
public class LdapConnectionTests
1617
{
1718
[Theory]

0 commit comments

Comments
 (0)