ProtoTest.Rest
1.0.1
See the version list below for details.
dotnet add package ProtoTest.Rest --version 1.0.1
NuGet\Install-Package ProtoTest.Rest -Version 1.0.1
<PackageReference Include="ProtoTest.Rest" Version="1.0.1" />
<PackageVersion Include="ProtoTest.Rest" Version="1.0.1" />
<PackageReference Include="ProtoTest.Rest" />
paket add ProtoTest.Rest --version 1.0.1
#r "nuget: ProtoTest.Rest, 1.0.1"
#:package ProtoTest.Rest@1.0.1
#addin nuget:?package=ProtoTest.Rest&version=1.0.1
#tool nuget:?package=ProtoTest.Rest&version=1.0.1
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. |
-
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 (2)
Showing the top 2 NuGet packages that depend on ProtoTest.Rest:
| Package | Downloads |
|---|---|
|
ProtoTest.OpenApi
OpenAPI contract coverage for ProtoTest REST tests. |
|
|
ProtoTest.WireMock
Fake HTTP services for ProtoTest suites, backed by WireMock.Net: per-test stubs, matched-request trace evidence and stub coverage. |
GitHub repositories
This package is not used by any popular GitHub repositories.