ProtoTest.Rest
1.0.1
dotnet add package ProtoTest.Rest --version 1.0.1
NuGet\Install-Package ProtoTest.Rest -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProtoTest.Rest" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProtoTest.Rest" Version="1.0.1" />
<PackageReference Include="ProtoTest.Rest" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProtoTest.Rest --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ProtoTest.Rest, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProtoTest.Rest@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProtoTest.Rest&version=1.0.1
#tool nuget:?package=ProtoTest.Rest&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ProtoTest.Rest
A per-test HTTP client with route and query expansion, the shared [Auth<T>] pipeline, JSON shape assertions, capture and endpoint coverage.
dotnet add package ProtoTest.Rest
Quick start
builder.AddApplication("Api", app => app.AddRest(rest => rest
.AddClient("Orders"))); // joins the application's BaseUrl with Endpoints:Orders
[Application("Api", "Rest:Orders")]
[Auth<BearerTokenAuthenticator>("token")]
public sealed class OrderTests
{
[ProtoTest]
public async Task GetOrder()
{
using var response = await Proto.Context.Rest()
.GetAsync("/orders/{id}", new { id = 42 });
response.Should.HaveHttpStatus(HttpStatusCode.OK)
.ShouldMatchShape(new
{
id = 42,
status = JsonValue.NotNull()
});
}
}
What it adds
- Clients —
Proto.Context.Rest(name?)resolves a namedHttpClient;AddClientaccepts an explicit base URL, an endpoint name or a per-testFunc<ProtoExecutionContext, Uri>resolver, andAddClientFromreuses another integration's transport. - Requests —
Header,Body(object, raw, bytes or a content factory) and the verb helpers;{route}tokens and leftover properties expand into the route and query string. - Assertions —
response.Should.HaveHttpStatus(...),ShouldNot.HaveHttpStatus(...)andShouldMatchShape(...); failures carryRestStatusAssertionExceptionorJsonShapeMismatchException. - Authentication — the shared
[Auth<T>]pipeline plus per-requestAuth(...)/WithoutAuth(), with built-in bearer, basic and API-key authenticators. - Capture and coverage —
CaptureAttachments()records redacted request/response bodies;RestCoverageCollectorreports endpoints fromhttp.responseobservations. - Tracing —
http.requestoperations with request/response sections,http.response/http.failureobservations andassert.http.status/assert.json.shapechecks.
Configuration
Under ProtoTest:Rest:Responses and ProtoTest:Rest:Attachments; code callbacks (ConfigureResponses, CaptureAttachments) run first and configuration is bound over them.
| Key | Type | Default |
|---|---|---|
MaxResponseBodyBytes |
int |
10485760 (10 MiB) |
MaxDiagnosticBodyLength |
int |
65536 |
CaptureRequestBodies |
bool |
true |
CaptureResponses |
bool |
true |
CaptureExpectedShapes |
bool |
true |
RedactSensitiveData |
bool |
true |
SensitiveHeaders |
List<string> |
Authorization, Proxy-Authorization, Cookie, Set-Cookie, X-Api-Key |
SensitiveQueryParameters |
List<string> |
access_token, refresh_token, token, apiKey, api_key, key |
SensitiveJsonProperties |
List<string> |
password, token, access_token, refresh_token, secret, apiKey, api_key |
Shape assertions are positive-only; response bodies are always buffered in full and there is no retry policy.
Learn more
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.Extensions.Http (>= 10.0.12)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Http (>= 1.0.1)
- ProtoTest.Json (>= 1.0.1)
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.1)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Http (>= 1.0.1)
- ProtoTest.Json (>= 1.0.1)
-
net9.0
- Microsoft.Extensions.Http (>= 9.0.20)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Http (>= 1.0.1)
- ProtoTest.Json (>= 1.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ProtoTest.Rest:
| Package | Downloads |
|---|---|
|
ProtoTest.OpenApi
OpenAPI contract coverage for ProtoTest REST tests. |
GitHub repositories
This package is not used by any popular GitHub repositories.