Skip to content

Commit a031ed4

Browse files
committed
Fix the test
1 parent b1ce3de commit a031ed4

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

src/libraries/Common/tests/System/Net/Security/FakeNtlmServer.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public FakeNtlmServer(NetworkCredential expectedCredential)
3737
public bool TargetIsServer { get; set; } = false;
3838
public bool PreferUnicode { get; set; } = true;
3939
public bool ForceNegotiateVersion { get; set; } = true;
40-
public bool SupportsEncryption { get; set; } = true;
4140

4241
// Negotiation results
4342
public bool IsAuthenticated { get; private set; }
@@ -233,10 +232,6 @@ private byte[] GenerateChallenge(Flags flags)
233232
{
234233
flags |= Flags.NegotiateVersion;
235234
}
236-
if (!SupportsEncryption)
237-
{
238-
flags &= ~Flags.NegotiateSeal;
239-
}
240235
// Remove any unsupported flags here
241236
flags &= Flags.AllSupported;
242237

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

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,10 @@ public void NtlmIncorrectExchangeTest()
211211
Assert.False(fakeNtlmServer.IsAuthenticated);
212212
}
213213

214-
[ConditionalTheory(nameof(IsNtlmAvailable))]
215-
[InlineData(true)]
216-
[InlineData(false)]
217-
public void NtlmEncryptionTest(bool serverSupportsEncryption)
214+
[ConditionalFact(nameof(IsNtlmAvailable))]
215+
public void NtlmEncryptionTest()
218216
{
219217
using FakeNtlmServer fakeNtlmServer = new FakeNtlmServer(s_testCredentialRight);
220-
fakeNtlmServer.SupportsEncryption = serverSupportsEncryption;
221218

222219
NegotiateAuthentication ntAuth = new NegotiateAuthentication(
223220
new NegotiateAuthenticationClientOptions
@@ -239,22 +236,15 @@ public void NtlmEncryptionTest(bool serverSupportsEncryption)
239236
Assert.Equal(FakeNtlmServer.Flags.NegotiateSeal, (fakeNtlmServer.InitialClientFlags & FakeNtlmServer.Flags.NegotiateSeal));
240237

241238
byte[]? authenticateBlob = ntAuth.GetOutgoingBlob(challengeBlob, out statusCode);
239+
Assert.Equal(NegotiateAuthenticationStatusCode.Completed, statusCode);
240+
Assert.NotNull(authenticateBlob);
242241

243-
if (serverSupportsEncryption)
244-
{
245-
Assert.Equal(NegotiateAuthenticationStatusCode.Completed, statusCode);
246-
Assert.NotNull(authenticateBlob);
247-
// Validate that the NegotiateSeal flag survived the full exchange
248-
Assert.Equal(FakeNtlmServer.Flags.NegotiateSeal, (fakeNtlmServer.NegotiatedFlags & FakeNtlmServer.Flags.NegotiateSeal));
249-
250-
byte[]? empty = fakeNtlmServer.GetOutgoingBlob(authenticateBlob);
251-
Assert.Null(empty);
252-
Assert.True(fakeNtlmServer.IsAuthenticated);
253-
}
254-
else
255-
{
256-
Assert.Equal(NegotiateAuthenticationStatusCode.QopNotSupported, statusCode);
257-
}
242+
byte[]? empty = fakeNtlmServer.GetOutgoingBlob(authenticateBlob);
243+
Assert.Null(empty);
244+
Assert.True(fakeNtlmServer.IsAuthenticated);
245+
246+
// Validate that the NegotiateSeal flag survived the full exchange
247+
Assert.Equal(FakeNtlmServer.Flags.NegotiateSeal, (fakeNtlmServer.NegotiatedFlags & FakeNtlmServer.Flags.NegotiateSeal));
258248
}
259249

260250
[ConditionalFact(nameof(IsNtlmAvailable))]

0 commit comments

Comments
 (0)