Class HttpClientAuthenticationExtensions
- Namespace
- XBullet.EasyTesting.Authentication
- Assembly
- XBullet.EasyTesting.dll
Methods for selecting the identity used by integration-test requests.
public static class HttpClientAuthenticationExtensions
- Inheritance
-
HttpClientAuthenticationExtensions
- Inherited Members
Methods
AuthenticateAs(HttpClient, TestUser)
Adds a test identity to every request made by this client.
public static HttpClient AuthenticateAs(this HttpClient client, TestUser user)
Parameters
clientHttpClientThe client whose default request headers are modified in place. The caller retains ownership and remains responsible for disposing it.
userTestUserThe test-user definition serialized immediately into the simulated-authentication header. The method does not retain, own, or mutate the supplied object. The header is test-only and is not cryptographically protected.
Returns
- HttpClient
The same
clientinstance for fluent use.
AuthenticateAs(HttpRequestMessage, TestUser)
Adds a test identity to one request.
public static HttpRequestMessage AuthenticateAs(this HttpRequestMessage request, TestUser user)
Parameters
requestHttpRequestMessageThe request whose headers are modified in place. The caller retains ownership and remains responsible for disposing it.
userTestUserThe test-user definition serialized immediately into the simulated-authentication header. The method does not retain, own, or mutate the supplied object. The header is test-only and is not cryptographically protected.
Returns
- HttpRequestMessage
The same
requestinstance for fluent use.
UseAnonymousUser(HttpClient)
Removes any test identity configured on the client.
public static HttpClient UseAnonymousUser(this HttpClient client)
Parameters
clientHttpClientThe client whose default simulated-user and Authorization headers are cleared in place. Request-specific headers, cookies, certificates, and other credentials are unchanged. The caller retains ownership and remains responsible for disposing the client.
Returns
- HttpClient
The same
clientinstance for fluent use.