-
Notifications
You must be signed in to change notification settings - Fork 119
Updates dependencies. Removes ASP.NET support for netstandard2.0 & tests for netcoreapp2.1 #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1becdd6
Updating dependencies
rossgrambo b18d7bb
Updates packages and resolves issues
rossgrambo f0c910d
Remove pointless semicolon
rossgrambo bab0180
Adjusts dotnet installation for buiddy build
rossgrambo dd69d84
Merge branch 'main' into rossgrambo/dependency-update
rossgrambo c9b4f14
Removes ASP.NET tests from .NET tests
rossgrambo f3ce959
Removes unused usings
rossgrambo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,8 @@ | ||
| # Installs .NET Core 2.1, .NET 5 and .NET 6 for CI/CD environment | ||
| # Installs .NET 6 and .NET 7 for CI/CD environment | ||
| # see: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script#examples | ||
|
|
||
| [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; | ||
|
|
||
| &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 2.1.816 | ||
| &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel 6.0 | ||
|
|
||
| &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 5.0.408 | ||
|
|
||
| &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) | ||
| &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Channel 7.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
187 changes: 187 additions & 0 deletions
187
tests/Tests.FeatureManagement.AspNetCore/FeatureManagementAspNetCore.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| using Microsoft.AspNetCore; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.AspNetCore.Hosting; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using Microsoft.AspNetCore.TestHost; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.FeatureManagement; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Net; | ||
| using System.Net.Http; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
|
|
||
| namespace Tests.FeatureManagement.AspNetCore | ||
| { | ||
| public class FeatureManagementAspNetCore | ||
| { | ||
| [Fact] | ||
| public async Task Integrates() | ||
| { | ||
| IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); | ||
|
|
||
| TestServer testServer = new TestServer(WebHost.CreateDefaultBuilder().ConfigureServices(services => | ||
| { | ||
| services | ||
| .AddSingleton(config) | ||
| .AddFeatureManagement() | ||
| .AddFeatureFilter<TestFilter>(); | ||
|
|
||
| services.AddMvcCore(o => | ||
| { | ||
| DisableEndpointRouting(o); | ||
| o.Filters.AddForFeature<MvcFilter>(Enum.GetName(typeof(Features), Features.ConditionalFeature)); | ||
| }); | ||
| }) | ||
| .Configure(app => | ||
| { | ||
| app.UseForFeature(Enum.GetName(typeof(Features), Features.ConditionalFeature), a => a.Use(async (ctx, next) => | ||
| { | ||
| ctx.Response.Headers[nameof(RouterMiddleware)] = bool.TrueString; | ||
|
|
||
| await next(); | ||
| })); | ||
|
|
||
| app.UseMvc(); | ||
| })); | ||
|
|
||
| IEnumerable<IFeatureFilterMetadata> featureFilters = testServer.Host.Services.GetRequiredService<IEnumerable<IFeatureFilterMetadata>>(); | ||
|
|
||
| TestFilter testFeatureFilter = (TestFilter)featureFilters.First(f => f is TestFilter); | ||
|
|
||
| testFeatureFilter.Callback = _ => Task.FromResult(true); | ||
|
|
||
| HttpResponseMessage res = await testServer.CreateClient().GetAsync(""); | ||
|
|
||
| Assert.True(res.Headers.Contains(nameof(MvcFilter))); | ||
| Assert.True(res.Headers.Contains(nameof(RouterMiddleware))); | ||
|
|
||
| testFeatureFilter.Callback = _ => Task.FromResult(false); | ||
|
|
||
| res = await testServer.CreateClient().GetAsync(""); | ||
|
|
||
| Assert.False(res.Headers.Contains(nameof(MvcFilter))); | ||
| Assert.False(res.Headers.Contains(nameof(RouterMiddleware))); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task GatesFeatures() | ||
| { | ||
| IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); | ||
|
|
||
| TestServer testServer = new TestServer(WebHost.CreateDefaultBuilder().ConfigureServices(services => | ||
| { | ||
| services | ||
| .AddSingleton(config) | ||
| .AddFeatureManagement() | ||
| .AddFeatureFilter<TestFilter>(); | ||
|
|
||
| services.AddMvcCore(o => DisableEndpointRouting(o)); | ||
| }) | ||
| .Configure(app => app.UseMvc())); | ||
|
|
||
| IEnumerable<IFeatureFilterMetadata> featureFilters = testServer.Host.Services.GetRequiredService<IEnumerable<IFeatureFilterMetadata>>(); | ||
|
|
||
| TestFilter testFeatureFilter = (TestFilter)featureFilters.First(f => f is TestFilter); | ||
|
|
||
| // | ||
| // Enable all features | ||
| testFeatureFilter.Callback = ctx => Task.FromResult(true); | ||
|
|
||
| HttpResponseMessage gateAllResponse = await testServer.CreateClient().GetAsync("gateAll"); | ||
| HttpResponseMessage gateAnyResponse = await testServer.CreateClient().GetAsync("gateAny"); | ||
|
|
||
| Assert.Equal(HttpStatusCode.OK, gateAllResponse.StatusCode); | ||
| Assert.Equal(HttpStatusCode.OK, gateAnyResponse.StatusCode); | ||
|
|
||
| // | ||
| // Enable 1/2 features | ||
| testFeatureFilter.Callback = ctx => Task.FromResult(ctx.FeatureName == Enum.GetName(typeof(Features), Features.ConditionalFeature)); | ||
|
|
||
| gateAllResponse = await testServer.CreateClient().GetAsync("gateAll"); | ||
| gateAnyResponse = await testServer.CreateClient().GetAsync("gateAny"); | ||
|
|
||
| Assert.Equal(HttpStatusCode.NotFound, gateAllResponse.StatusCode); | ||
| Assert.Equal(HttpStatusCode.OK, gateAnyResponse.StatusCode); | ||
|
|
||
| // | ||
| // Enable no | ||
| testFeatureFilter.Callback = ctx => Task.FromResult(false); | ||
|
|
||
| gateAllResponse = await testServer.CreateClient().GetAsync("gateAll"); | ||
| gateAnyResponse = await testServer.CreateClient().GetAsync("gateAny"); | ||
|
|
||
| Assert.Equal(HttpStatusCode.NotFound, gateAllResponse.StatusCode); | ||
| Assert.Equal(HttpStatusCode.NotFound, gateAnyResponse.StatusCode); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task GatesRazorPageFeatures() | ||
| { | ||
| IConfiguration config = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build(); | ||
|
|
||
| TestServer testServer = new TestServer(WebHost.CreateDefaultBuilder().ConfigureServices(services => | ||
| { | ||
| services | ||
| .AddSingleton(config) | ||
| .AddFeatureManagement() | ||
| .AddFeatureFilter<TestFilter>(); | ||
|
|
||
| services.AddRazorPages(); | ||
|
|
||
| services.AddMvc(o => DisableEndpointRouting(o)); | ||
| }) | ||
| .Configure(app => | ||
| { | ||
| app.UseMvc(); | ||
| })); | ||
|
|
||
| IEnumerable<IFeatureFilterMetadata> featureFilters = testServer.Host.Services.GetRequiredService<IEnumerable<IFeatureFilterMetadata>>(); | ||
|
|
||
| TestFilter testFeatureFilter = (TestFilter)featureFilters.First(f => f is TestFilter); | ||
|
|
||
| // | ||
| // Enable all features | ||
| testFeatureFilter.Callback = ctx => Task.FromResult(true); | ||
|
|
||
| HttpResponseMessage gateAllResponse = await testServer.CreateClient().GetAsync("RazorTestAll"); | ||
| HttpResponseMessage gateAnyResponse = await testServer.CreateClient().GetAsync("RazorTestAny"); | ||
|
|
||
| Assert.Equal(HttpStatusCode.OK, gateAllResponse.StatusCode); | ||
| Assert.Equal(HttpStatusCode.OK, gateAnyResponse.StatusCode); | ||
|
|
||
| // | ||
| // Enable 1/2 features | ||
| testFeatureFilter.Callback = ctx => Task.FromResult(ctx.FeatureName == Enum.GetName(typeof(Features), Features.ConditionalFeature)); | ||
|
|
||
| gateAllResponse = await testServer.CreateClient().GetAsync("RazorTestAll"); | ||
| gateAnyResponse = await testServer.CreateClient().GetAsync("RazorTestAny"); | ||
|
|
||
| Assert.Equal(HttpStatusCode.NotFound, gateAllResponse.StatusCode); | ||
| Assert.Equal(HttpStatusCode.OK, gateAnyResponse.StatusCode); | ||
|
|
||
| // | ||
| // Enable no | ||
| testFeatureFilter.Callback = ctx => Task.FromResult(false); | ||
|
|
||
| gateAllResponse = await testServer.CreateClient().GetAsync("RazorTestAll"); | ||
| gateAnyResponse = await testServer.CreateClient().GetAsync("RazorTestAny"); | ||
|
|
||
| Assert.Equal(HttpStatusCode.NotFound, gateAllResponse.StatusCode); | ||
| Assert.Equal(HttpStatusCode.NotFound, gateAnyResponse.StatusCode); | ||
| } | ||
|
|
||
| private static void DisableEndpointRouting(MvcOptions options) | ||
| { | ||
| // | ||
| // Endpoint routing is disabled by default in .NET Core 2.1 since it didn't exist. | ||
| options.EnableEndpointRouting = false; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| namespace Tests.FeatureManagement.AspNetCore | ||
| { | ||
| enum Features | ||
| { | ||
| ConditionalFeature, | ||
| ConditionalFeature2 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tests/Tests.FeatureManagement.AspNetCore/Pages/_ViewImports.cshtml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| @using Tests.FeatureManagement.AspNetCore | ||
| @namespace Tests.FeatureManagement.AspNetCore.Pages | ||
| @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
| // | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.FeatureManagement; | ||
| using System; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace Tests.FeatureManagement.AspNetCore | ||
| { | ||
| class TestFilter : IFeatureFilter, IFilterParametersBinder | ||
| { | ||
| public Func<IConfiguration, object> ParametersBinderCallback { get; set; } | ||
|
|
||
| public Func<FeatureFilterEvaluationContext, Task<bool>> Callback { get; set; } | ||
|
|
||
| public object BindParameters(IConfiguration parameters) | ||
| { | ||
| if (ParametersBinderCallback != null) | ||
| { | ||
| return ParametersBinderCallback(parameters); | ||
| } | ||
|
|
||
| return parameters; | ||
| } | ||
|
|
||
| public Task<bool> EvaluateAsync(FeatureFilterEvaluationContext context) | ||
| { | ||
| return Callback?.Invoke(context) ?? Task.FromResult(false); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.