Skip to content

Commit

Permalink
Feature/update to net6 (#55)
Browse files Browse the repository at this point in the history
Change PackageLicenseUrl to PackageLicenseUrl
Remove SetCompatibilityVersion from the code
Update README
  • Loading branch information
Sergio1192 authored Mar 28, 2022
1 parent ac68313 commit 9d6a353
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 216 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup Label="Package information">
<Version>3.2.0</Version>

<PackageLicenseUrl>https://github.com/Xabaril/Acheve.TestHost/blob/master/LICENSE</PackageLicenseUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>http://github.com/xabaril/Acheve.TestHost</PackageProjectUrl>
<RepositoryUrl>http://github.com/xabaril/Acheve.TestHost</RepositoryUrl>
<Authors>Xabaril Contributors</Authors>
Expand Down
201 changes: 0 additions & 201 deletions LICENSE

This file was deleted.

22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
[![Build status](https://ci.appveyor.com/api/projects/status/n6mfcq24ud5lecvb?svg=true)](https://ci.appveyor.com/project/Xabaril/acheve-testhost) [![NuGet](https://img.shields.io/nuget/v/acheve.testhost.svg)](https://www.nuget.org/packages/acheve.testhost/)

[![Build history](https://buildstats.info/appveyor/chart/xabaril/Acheve-TestHost)](https://ci.appveyor.com/project/xabaril/Acheve-TestHost/history)

# Acheve

NuGet package to improve AspNetCore TestServer experiences
[![Build status](https://github.com/Xabaril/Acheve.TestHost/actions/workflows/nuget.yml/badge.svg)](https://github.com/Xabaril/Acheve.TestHost/actions/workflows/nuget.yml/badge.svg) [![NuGet](https://img.shields.io/nuget/v/acheve.testhost.svg)](https://www.nuget.org/packages/acheve.testhost/)

Unit testing your Mvc controllers is not enough to verify the correctness of your WebApi. Are the filters working? Is the correct status code sent when that condition is reached? Is the user authorized to request that endpoint?
NuGet package to improve AspNetCore TestServer experiences

Unit testing your Mvc controllers is not enough to verify the correctness of your WebApi. Are the filters working? Is the correct status code sent when that condition is reached? Is the user authorized to request that endpoint?

The NuGet package [Microsoft.AspNetCore.TestHost](https://www.nuget.org/packages/Microsoft.AspNetCore.TestHost/) allows you to create an in memory server that exposes an HttpClient to be able to send request to the server. All in memory, all in the same process. Fast. It's the best way to create integration tests in your Mvc application. But at this moment this library has some gaps that *Acheve* try to fill.

## About Security

But when your Mvc application requires an authenticated request it could be a little more dificult...

What if you have an easy way to indicate the claims in the request?
What if you have an easy way to indicate the claims in the request?

This package implements an authentication middleware and several extension methods to easily indicate
the claims for authenticated calls to the WebApi.
Expand Down Expand Up @@ -48,7 +45,7 @@ In the TestServer startup class you shoud incude the authentication service and
}
```

And in your tests you can use an HttpClient with default credentials or build
And in your tests you can use an HttpClient with default credentials or build
the request with the server RequestBuilder and the desired claims:

```csharp
Expand Down Expand Up @@ -126,7 +123,6 @@ Both methods (`WithDefaultIdentity` and `WithIdentity`) accept as the only param

You can find a complete example in the [samples](https://github.com/hbiarge/Acheve.AspNetCore.TestHost.Security/tree/master/Acheve.AspNet.TestHost.Security/samples) directory.


## About discovering uri's

Well, when you try to create any test using Test Server you need to know the uri of the action to be invoked.
Expand Down Expand Up @@ -161,8 +157,8 @@ public static class API

The main problems on this approach are:

1.- If any route convention is changed all integration test will fail.
2.- If you refactor any parameter order the integration test will fail.
1. If any route convention is changed all integration test will fail.
1. If you refactor any parameter order the integration test will fail.

With *Acheve* you can create the uri dynamically using the attribute routing directly from your controllers.

Expand All @@ -172,3 +168,7 @@ var response = await _server.CreateHttpApiRequest<ValuesController>(controller=>
.GetAsync();

```

## License

[Apache 2.0](https://licenses.nuget.org/Apache-2.0)
1 change: 0 additions & 1 deletion samples/Sample.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public void ConfigureServices(IServiceCollection services)
.AddJwtBearer();

services.AddControllers()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddApplicationPart(Assembly.Load(new AssemblyName("Sample.Api")));

ApiConfiguration.Configure(services);
Expand Down
1 change: 0 additions & 1 deletion samples/Sample.IntegrationTests/TestStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void ConfigureServices(IServiceCollection services)
});

services.AddControllers()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddApplicationPart(Assembly.Load(new AssemblyName("Sample.Api")));

ApiConfiguration.Configure(services);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class DefaultStartup
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers()
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
.AddApplicationPart(Assembly.Load(new AssemblyName("UnitTests")));
}

Expand Down

0 comments on commit 9d6a353

Please sign in to comment.