public void DigestResponse_Parse_Succeeds(string challenge, List <string> keys, List <string> values) { AuthenticationHelper.DigestResponse digestResponse = new AuthenticationHelper.DigestResponse(challenge); Assert.Equal(keys.Count, digestResponse.Parameters.Count); Assert.Equal(values.Count, digestResponse.Parameters.Count); Assert.Equal(keys, digestResponse.Parameters.Keys); Assert.Equal(values, digestResponse.Parameters.Values); }
public async void DigestResponse_AuthToken_Handling(string response, bool expectedResult) { NetworkCredential credential = new NetworkCredential("foo", "bar"); AuthenticationHelper.DigestResponse digestResponse = new AuthenticationHelper.DigestResponse(response); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://microsoft.com/"); Assert.Equal(expectedResult, await AuthenticationHelper.TrySetDigestAuthToken(request, credential, digestResponse, HttpKnownHeaderNames.ProxyAuthorization).ConfigureAwait(false)); }
public async Task DigestResponse_UserName_Encoding(string username, string encodedUserName) { NetworkCredential credential = new NetworkCredential(username, "bar"); AuthenticationHelper.DigestResponse digestResponse = new AuthenticationHelper.DigestResponse("realm=\"NetCore\", nonce=\"qMRqWgAAAAAQMjIABgAAAFwEiEwAAAAA\""); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://microsoft.com/"); string parameter = await AuthenticationHelper.GetDigestTokenForCredential(credential, request, digestResponse).ConfigureAwait(false); Assert.StartsWith(encodedUserName, parameter); }
public async Task DigestResponse_AuthToken_Handling(string response, bool expectedResult) { NetworkCredential credential = new NetworkCredential("foo", "bar"); AuthenticationHelper.DigestResponse digestResponse = new AuthenticationHelper.DigestResponse(response); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://microsoft.com/"); string parameter = await AuthenticationHelper.GetDigestTokenForCredential(credential, request, digestResponse).ConfigureAwait(false); Assert.Equal(expectedResult, parameter != null); }
public async Task DigestResponse_ShouldSendQop(string response, string match, string doesNotMatch, int fieldCount) { NetworkCredential credential = new NetworkCredential("foo", "bar"); AuthenticationHelper.DigestResponse digestResponse = new AuthenticationHelper.DigestResponse(response); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://microsoft.com/"); string parameter = await AuthenticationHelper.GetDigestTokenForCredential(credential, request, digestResponse).ConfigureAwait(false); if (match != null) { Assert.Matches(match, parameter); } if (doesNotMatch != null) { Assert.DoesNotMatch(doesNotMatch, parameter); } Assert.Equal(fieldCount, parameter.Split(',').Length); Assert.False(parameter.Trim().EndsWith(",")); }