From 99f07eb620712765c0ac4608297e9b0a9c1ece98 Mon Sep 17 00:00:00 2001 From: wapplegate Date: Tue, 30 Jul 2024 13:13:09 -0400 Subject: [PATCH 1/2] Upgrade library to target .NET 8. --- .github/workflows/{dotnet.yml => develop.yml} | 8 +-- .github/workflows/main.yml | 4 +- .../AccessTokenClient.Extensions.csproj | 16 +++--- .../AccessTokenClient.Tests.csproj | 26 ++++----- .../AccessTokenClientRetryIntegrationTests.cs | 6 +-- .../MemoryTokenResponseCache.cs | 4 +- .../TokenClientCachingDecoratorTests.cs | 30 +++++------ .../TokenClientRetryTests.cs | 4 +- .../TokenClientUnitTests.cs | 42 +++++++-------- .../TokenRequestKeyGeneratorTests.cs | 18 +++---- AccessTokenClient.sln | 2 +- AccessTokenClient/AccessTokenClient.csproj | 16 +++--- Projects/Benchmarks/Benchmarks.csproj | 15 ++---- Projects/Benchmarks/Program.cs | 8 +-- Projects/Console/Console.csproj | 10 ++-- Projects/Console/Program.cs | 8 +-- Projects/IdentityServer/IdentityServer.csproj | 8 ++- .../IdentityServerConfiguration.cs | 16 +++--- .../Properties/launchSettings.json | 18 +------ .../Properties/launchSettings.json | 31 ----------- .../Controllers/ValuesController.cs | 4 +- .../Program.cs | 8 +-- .../Properties/launchSettings.json | 15 ++++++ .../TestingWebApplication.csproj} | 4 +- .../appsettings.json | 0 azure-pipelines.yml | 54 ------------------- 26 files changed, 142 insertions(+), 233 deletions(-) rename .github/workflows/{dotnet.yml => develop.yml} (88%) delete mode 100644 Projects/TestingSixPointZeroApplication/Properties/launchSettings.json rename Projects/{TestingSixPointZeroApplication => TestingWebApplication}/Controllers/ValuesController.cs (91%) rename Projects/{TestingSixPointZeroApplication => TestingWebApplication}/Program.cs (84%) create mode 100644 Projects/TestingWebApplication/Properties/launchSettings.json rename Projects/{TestingSixPointZeroApplication/TestingSixPointZeroApplication.csproj => TestingWebApplication/TestingWebApplication.csproj} (89%) rename Projects/{TestingSixPointZeroApplication => TestingWebApplication}/appsettings.json (100%) delete mode 100644 azure-pipelines.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/develop.yml similarity index 88% rename from .github/workflows/dotnet.yml rename to .github/workflows/develop.yml index 35e52f6..3b52e16 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/develop.yml @@ -1,10 +1,10 @@ -name: development-build +name: develop-build-deploy on: push: - branches: ["development"] + branches: ["develop"] pull_request: - branches: ["development"] + branches: ["develop"] jobs: build: @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Restore run: dotnet restore - name: Build, Test, Package, Deploy diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5f7b793..b7a4685 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: main-build +name: main-build-deploy on: push: @@ -11,7 +11,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 8.0.x - name: Restore run: dotnet restore - name: Build, Test, Package, Deploy diff --git a/AccessTokenClient.Extensions/AccessTokenClient.Extensions.csproj b/AccessTokenClient.Extensions/AccessTokenClient.Extensions.csproj index 16f5332..dd2b830 100644 --- a/AccessTokenClient.Extensions/AccessTokenClient.Extensions.csproj +++ b/AccessTokenClient.Extensions/AccessTokenClient.Extensions.csproj @@ -1,10 +1,10 @@ - net6.0 + net8.0 true enable - 3.0.1 + 4.0.0 true William Applegate This package contains service collection extension methods to easily add the access token client to the service collection. @@ -23,18 +23,18 @@ true - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/AccessTokenClient.Tests/AccessTokenClient.Tests.csproj b/AccessTokenClient.Tests/AccessTokenClient.Tests.csproj index 6aeced4..bab85f6 100644 --- a/AccessTokenClient.Tests/AccessTokenClient.Tests.csproj +++ b/AccessTokenClient.Tests/AccessTokenClient.Tests.csproj @@ -1,34 +1,34 @@  - net6.0 + net8.0 enable enable false - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/AccessTokenClient.Tests/AccessTokenClientRetryIntegrationTests.cs b/AccessTokenClient.Tests/AccessTokenClientRetryIntegrationTests.cs index c1b5a33..45d1520 100644 --- a/AccessTokenClient.Tests/AccessTokenClientRetryIntegrationTests.cs +++ b/AccessTokenClient.Tests/AccessTokenClientRetryIntegrationTests.cs @@ -47,10 +47,10 @@ public async Task Test(HttpStatusCode statusCode) TokenEndpoint = "https://service/token", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] - { + Scopes = + [ "scope:read", "scope:create", "scope:edit", "scope:delete" - } + ] }); await func.Should().ThrowAsync(); diff --git a/AccessTokenClient.Tests/MemoryTokenResponseCache.cs b/AccessTokenClient.Tests/MemoryTokenResponseCache.cs index e7c1221..2c9600d 100644 --- a/AccessTokenClient.Tests/MemoryTokenResponseCache.cs +++ b/AccessTokenClient.Tests/MemoryTokenResponseCache.cs @@ -11,7 +11,7 @@ public class MemoryTokenResponseCacheTests [Fact] public void EnsureExceptionThrownWhenInjectedMemoryCacheIsNull() { - Func creationFunction = () => new MemoryTokenResponseCache(null); + var creationFunction = () => new MemoryTokenResponseCache(null!); creationFunction.Should().Throw(); } @@ -27,7 +27,7 @@ public async Task EnsureSuccessResponseReturnedWhenCachedResponseExists() }); var cache = new MemoryTokenResponseCache(memoryCache); var tokenResponse = await cache.Get(Key); - tokenResponse.ShouldNotBeNull(); + tokenResponse!.ShouldNotBeNull(); } [Fact] diff --git a/AccessTokenClient.Tests/TokenClientCachingDecoratorTests.cs b/AccessTokenClient.Tests/TokenClientCachingDecoratorTests.cs index d5f9eb4..092e9e0 100644 --- a/AccessTokenClient.Tests/TokenClientCachingDecoratorTests.cs +++ b/AccessTokenClient.Tests/TokenClientCachingDecoratorTests.cs @@ -49,10 +49,10 @@ public async Task EnsureTokenResponseIsReturnedWhenCacheKeyIsFound() var tokenResponse = await cachingDecorator.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); tokenResponse.ShouldNotBeNull(); @@ -73,7 +73,7 @@ public async Task EnsureTokenResponseIsReturnedWhenCacheKeyIsNotFound() // Set-up the token response cache mock: var cacheMock = new Mock(); - cacheMock.Setup(m => m.Get(It.IsAny(), It.IsAny())).ReturnsAsync((TokenResponse)null); + cacheMock.Setup(m => m.Get(It.IsAny(), It.IsAny())).ReturnsAsync((TokenResponse)null!); // Set-up the key generator mock: var keyGeneratorMock = new Mock(); @@ -95,14 +95,14 @@ public async Task EnsureTokenResponseIsReturnedWhenCacheKeyIsNotFound() var tokenResponse = await cachingDecorator.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); tokenResponse.ShouldNotBeNull(); - tokenResponse.AccessToken.ShouldNotBeNull(); + tokenResponse.AccessToken!.ShouldNotBeNull(); tokenResponse.AccessToken.Should().Be("1234567890"); messageHandler.NumberOfCalls.Should().Be(1); @@ -152,14 +152,14 @@ public async Task EnsureTokenResponseReturnedWhenCacheSetOperationIsSuccessfulOr var tokenResponse = await cachingDecorator.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); tokenResponse.ShouldNotBeNull(); - tokenResponse.AccessToken.ShouldNotBeNull(); + tokenResponse.AccessToken!.ShouldNotBeNull(); tokenResponse.AccessToken.Should().Be("1234567890"); messageHandler.NumberOfCalls.Should().Be(1); @@ -178,7 +178,7 @@ public async Task EnsureTokenResponseIsReturnedWhenScopesAreNotSpecified() // Set-up the token response cache mock: var cacheMock = new Mock(); - cacheMock.Setup(m => m.Get(It.IsAny(), It.IsAny())).ReturnsAsync((TokenResponse)null); + cacheMock.Setup(m => m.Get(It.IsAny(), It.IsAny())).ReturnsAsync((TokenResponse)null!); // Set-up the key generator mock: var keyGeneratorMock = new Mock(); @@ -200,13 +200,13 @@ public async Task EnsureTokenResponseIsReturnedWhenScopesAreNotSpecified() var tokenResponse = await cachingDecorator.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", }); tokenResponse.ShouldNotBeNull(); - tokenResponse.AccessToken.ShouldNotBeNull(); + tokenResponse.AccessToken!.ShouldNotBeNull(); tokenResponse.AccessToken.Should().Be("1234567890"); messageHandler.NumberOfCalls.Should().Be(1); @@ -219,7 +219,7 @@ public void EnsureExceptionThrownWhenCancellationRequested() { // Cancel the token before executing the decorator so it throws immediately: var source = new CancellationTokenSource(); - source.Cancel(); + await source.CancelAsync(); var decorator = new TokenClientCachingDecorator( new NullLogger(), @@ -231,10 +231,10 @@ public void EnsureExceptionThrownWhenCancellationRequested() var response = await decorator.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }, cancellationToken: source.Token); return response; diff --git a/AccessTokenClient.Tests/TokenClientRetryTests.cs b/AccessTokenClient.Tests/TokenClientRetryTests.cs index 8133b79..f0f4165 100644 --- a/AccessTokenClient.Tests/TokenClientRetryTests.cs +++ b/AccessTokenClient.Tests/TokenClientRetryTests.cs @@ -43,7 +43,7 @@ await tokenClient.RequestAccessToken(new TokenRequest TokenEndpoint = "http://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); } catch @@ -94,7 +94,7 @@ await tokenClient.RequestAccessToken(new TokenRequest TokenEndpoint = "http://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); } catch diff --git a/AccessTokenClient.Tests/TokenClientUnitTests.cs b/AccessTokenClient.Tests/TokenClientUnitTests.cs index 6d08c22..874054b 100644 --- a/AccessTokenClient.Tests/TokenClientUnitTests.cs +++ b/AccessTokenClient.Tests/TokenClientUnitTests.cs @@ -21,10 +21,10 @@ public async Task EnsureExceptionThrownWhenAccessTokenIsEmpty() Func> function = async () => await tokenClient.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); await function.Should().ThrowAsync(); @@ -43,10 +43,10 @@ public async Task EnsureExceptionThrownWhenTokenResponseIsEmpty() Func> function = async () => await tokenClient.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); await function.Should().ThrowAsync(); @@ -68,10 +68,10 @@ public async Task EnsureExceptionThrownWhenNonSuccessStatusCodeReturned(HttpStat Func> function = async () => await tokenClient.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); await function.Should().ThrowAsync(); @@ -86,18 +86,18 @@ public async Task EnsureExceptionThrownWhenCancellationRequested() // Cancel the token before executing the token client so it throws immediately: var source = new CancellationTokenSource(); - source.Cancel(); - + await source.CancelAsync(); + var client = new TokenClient(logger, httpClient); Func> function = async () => { var tokenResponse = await client.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }, cancellationToken: source.Token); return tokenResponse; @@ -110,7 +110,7 @@ public async Task EnsureExceptionThrownWhenCancellationRequested() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public async Task EnsureExceptionThrownWhenTokenEndpointNotSet(string tokenEndpoint) + public async Task EnsureExceptionThrownWhenTokenEndpointNotSet(string? tokenEndpoint) { var response = string.Empty; @@ -125,7 +125,7 @@ public async Task EnsureExceptionThrownWhenTokenEndpointNotSet(string tokenEndpo TokenEndpoint = tokenEndpoint, ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); await function.Should().ThrowAsync(); @@ -135,7 +135,7 @@ public async Task EnsureExceptionThrownWhenTokenEndpointNotSet(string tokenEndpo [InlineData(null)] [InlineData("")] [InlineData(" ")] - public async Task EnsureExceptionThrownWhenClientIdentifierNotSet(string clientIdentifier) + public async Task EnsureExceptionThrownWhenClientIdentifierNotSet(string? clientIdentifier) { var response = string.Empty; @@ -147,10 +147,10 @@ public async Task EnsureExceptionThrownWhenClientIdentifierNotSet(string clientI Func> function = async () => await tokenClient.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = clientIdentifier, ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); await function.Should().ThrowAsync(); @@ -160,7 +160,7 @@ public async Task EnsureExceptionThrownWhenClientIdentifierNotSet(string clientI [InlineData(null)] [InlineData("")] [InlineData(" ")] - public async Task EnsureExceptionThrownWhenClientSecretNotSet(string clientSecret) + public async Task EnsureExceptionThrownWhenClientSecretNotSet(string? clientSecret) { var response = string.Empty; @@ -172,10 +172,10 @@ public async Task EnsureExceptionThrownWhenClientSecretNotSet(string clientSecre Func> function = async () => await tokenClient.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = clientSecret, - Scopes = new[] { "scope:read" } + Scopes = ["scope:read"] }); await function.Should().ThrowAsync(); @@ -194,11 +194,11 @@ public async Task EnsureTokenResponseFromOptionalFunctionIsReturned() var tokenResponse = await tokenClient.RequestAccessToken(new TokenRequest { - TokenEndpoint = "http://www.token-endpoint.com", + TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope:read" } - }, execute: request => Task.FromResult(new TokenResponse + Scopes = ["scope:read"] + }, execute: _ => Task.FromResult(new TokenResponse { AccessToken = "access-token", ExpiresIn = 8000 diff --git a/AccessTokenClient.Tests/TokenRequestKeyGeneratorTests.cs b/AccessTokenClient.Tests/TokenRequestKeyGeneratorTests.cs index 246e55b..41f983a 100644 --- a/AccessTokenClient.Tests/TokenRequestKeyGeneratorTests.cs +++ b/AccessTokenClient.Tests/TokenRequestKeyGeneratorTests.cs @@ -16,7 +16,7 @@ public void EnsureKeyGeneratedSuccessfully() { ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope_1", "scope_2", "scope_3" }, + Scopes = ["scope_1", "scope_2", "scope_3"], TokenEndpoint = "https://www.token-endpoint.com" }; @@ -30,7 +30,7 @@ public void EnsureKeyGeneratedSuccessfully() [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void EnsureExceptionThrownWhenTokenEndpointIsInvalid(string tokenEndpoint) + public void EnsureExceptionThrownWhenTokenEndpointIsInvalid(string? tokenEndpoint) { var generator = new TokenRequestKeyGenerator(); @@ -39,7 +39,7 @@ public void EnsureExceptionThrownWhenTokenEndpointIsInvalid(string tokenEndpoint TokenEndpoint = tokenEndpoint, ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope_1", "scope_2", "scope_3" } + Scopes = ["scope_1", "scope_2", "scope_3"] }; Action action = () => generator.GenerateTokenRequestKey(request, "AccessTokenClient"); @@ -51,7 +51,7 @@ public void EnsureExceptionThrownWhenTokenEndpointIsInvalid(string tokenEndpoint [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void EnsureExceptionThrownWhenClientIdentifierIsInvalid(string clientIdentifier) + public void EnsureExceptionThrownWhenClientIdentifierIsInvalid(string? clientIdentifier) { var generator = new TokenRequestKeyGenerator(); @@ -60,7 +60,7 @@ public void EnsureExceptionThrownWhenClientIdentifierIsInvalid(string clientIden TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = clientIdentifier, ClientSecret = "client-secret", - Scopes = new[] { "scope_1", "scope_2", "scope_3" }, + Scopes = ["scope_1", "scope_2", "scope_3"], }; Action action = () => generator.GenerateTokenRequestKey(request, "AccessTokenClient"); @@ -72,7 +72,7 @@ public void EnsureExceptionThrownWhenClientIdentifierIsInvalid(string clientIden [InlineData(null)] [InlineData("")] [InlineData(" ")] - public void EnsureExceptionThrownWhenClientSecretIsInvalid(string clientSecret) + public void EnsureExceptionThrownWhenClientSecretIsInvalid(string? clientSecret) { var generator = new TokenRequestKeyGenerator(); @@ -81,7 +81,7 @@ public void EnsureExceptionThrownWhenClientSecretIsInvalid(string clientSecret) TokenEndpoint = "https://www.token-endpoint.com", ClientIdentifier = "client-identifier", ClientSecret = clientSecret, - Scopes = new[] { "scope_1", "scope_2", "scope_3" } + Scopes = ["scope_1", "scope_2", "scope_3"] }; Action action = () => generator.GenerateTokenRequestKey(request, "AccessTokenClient"); @@ -98,7 +98,7 @@ public void EnsureRequestGeneratesDifferentKeysWhenCaseIsDifferent() { ClientIdentifier = "client-identifier", ClientSecret = "client-secret", - Scopes = new[] { "scope_1", "scope_2", "scope_3" }, + Scopes = ["scope_1", "scope_2", "scope_3"], TokenEndpoint = "https://www.token-endpoint.com" }; @@ -108,7 +108,7 @@ public void EnsureRequestGeneratesDifferentKeysWhenCaseIsDifferent() { ClientIdentifier = "CLIENT-IDENTIFIER", ClientSecret = "CLIENT-SECRET", - Scopes = new[] { "SCOPE_1", "SCOPE_2", "SCOPE_3" }, + Scopes = ["SCOPE_1", "SCOPE_2", "SCOPE_3"], TokenEndpoint = "https://www.token-endpoint.com" }; diff --git a/AccessTokenClient.sln b/AccessTokenClient.sln index d3fe1dc..d452b47 100644 --- a/AccessTokenClient.sln +++ b/AccessTokenClient.sln @@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Benchmarks", "Projects\Benc EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console", "Projects\Console\Console.csproj", "{E296FB16-8A13-47C7-8604-84418813E699}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestingSixPointZeroApplication", "Projects\TestingSixPointZeroApplication\TestingSixPointZeroApplication.csproj", "{48E954B7-06B4-44C2-8872-C8F98ADC5665}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestingWebApplication", "Projects\TestingWebApplication\TestingWebApplication.csproj", "{48E954B7-06B4-44C2-8872-C8F98ADC5665}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/AccessTokenClient/AccessTokenClient.csproj b/AccessTokenClient/AccessTokenClient.csproj index f983dc7..2349029 100644 --- a/AccessTokenClient/AccessTokenClient.csproj +++ b/AccessTokenClient/AccessTokenClient.csproj @@ -1,10 +1,10 @@ - net6.0 + net8.0 true enable - 3.0.1 + 4.0.0 true William Applegate This library provides a token client that can be used when you need to make client credentials OAuth requests. Instead of re-writing the same token clients over and over again in your services, you can use this package to make those token requests easily. The package also includes the ability to cache access tokens so they can be reused. @@ -23,15 +23,15 @@ true - - - - - + + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Projects/Benchmarks/Benchmarks.csproj b/Projects/Benchmarks/Benchmarks.csproj index 817b8ca..6a0c168 100644 --- a/Projects/Benchmarks/Benchmarks.csproj +++ b/Projects/Benchmarks/Benchmarks.csproj @@ -2,23 +2,18 @@ Exe - net6.0 + net8.0 enable enable - + - - - - - - - - + + + diff --git a/Projects/Benchmarks/Program.cs b/Projects/Benchmarks/Program.cs index ec26add..d8fb63c 100644 --- a/Projects/Benchmarks/Program.cs +++ b/Projects/Benchmarks/Program.cs @@ -52,10 +52,10 @@ public async Task GetAccessToken() TokenEndpoint = "https://localhost:44303/connect/token", ClientIdentifier = "testing_client_identifier", ClientSecret = "511536EF-F270-4058-80CA-1C89C192F69A", - Scopes = new[] - { - "employee:read", "employee:create", "employee:edit", "employee:delete" - } + Scopes = + [ + "movie:read", "movie:create", "movie:edit", "movie:delete" + ] }); } } diff --git a/Projects/Console/Console.csproj b/Projects/Console/Console.csproj index f448147..581bb51 100644 --- a/Projects/Console/Console.csproj +++ b/Projects/Console/Console.csproj @@ -2,14 +2,14 @@ Exe - net6.0 + net8.0 - - - - + + + + diff --git a/Projects/Console/Program.cs b/Projects/Console/Program.cs index abeecc9..1db511c 100644 --- a/Projects/Console/Program.cs +++ b/Projects/Console/Program.cs @@ -36,10 +36,10 @@ TokenEndpoint = "https://localhost:44303/connect/token", ClientIdentifier = "testing_client_identifier", ClientSecret = "511536EF-F270-4058-80CA-1C89C192F69A", - Scopes = new[] - { - "employee:read", "employee:create", "employee:edit", "employee:delete" - } + Scopes = + [ + "movie:read", "movie:create", "movie:edit", "movie:delete" + ] }); Console.WriteLine(tokenResponse.AccessToken); diff --git a/Projects/IdentityServer/IdentityServer.csproj b/Projects/IdentityServer/IdentityServer.csproj index 7026422..2dba0c0 100644 --- a/Projects/IdentityServer/IdentityServer.csproj +++ b/Projects/IdentityServer/IdentityServer.csproj @@ -1,14 +1,12 @@ - net6.0 + net8.0 - - - + + \ No newline at end of file diff --git a/Projects/IdentityServer/IdentityServerConfiguration.cs b/Projects/IdentityServer/IdentityServerConfiguration.cs index c57f65c..e37c32c 100644 --- a/Projects/IdentityServer/IdentityServerConfiguration.cs +++ b/Projects/IdentityServer/IdentityServerConfiguration.cs @@ -7,10 +7,10 @@ public static class IdentityServerConfiguration { public static IEnumerable Scopes => new[] { - new ApiScope("employee:read", "The ability to read employee data."), - new ApiScope("employee:create", "The ability create employee data."), - new ApiScope("employee:edit", "The ability to edit employee data."), - new ApiScope("employee:delete", "The ability to delete employee data.") + new ApiScope("movie:read", "The ability to read movie data."), + new ApiScope("movie:create", "The ability create a movie."), + new ApiScope("movie:edit", "The ability to edit movie data."), + new ApiScope("movie:delete", "The ability to delete a movie.") }; public static IEnumerable Clients => new[] @@ -26,10 +26,10 @@ public static class IdentityServerConfiguration }, AllowedScopes = { - "employee:read", - "employee:create", - "employee:edit", - "employee:delete" + "movie:read", + "movie:create", + "movie:edit", + "movie:delete" } } }; diff --git a/Projects/IdentityServer/Properties/launchSettings.json b/Projects/IdentityServer/Properties/launchSettings.json index f38badf..1eaff77 100644 --- a/Projects/IdentityServer/Properties/launchSettings.json +++ b/Projects/IdentityServer/Properties/launchSettings.json @@ -1,27 +1,13 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:52431/", - "sslPort": 44303 - } - }, + "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, "IdentityServer": { "commandName": "Project", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, - "applicationUrl": "https://localhost:5001;http://localhost:5000" + "applicationUrl": "https://localhost:44303" } } } \ No newline at end of file diff --git a/Projects/TestingSixPointZeroApplication/Properties/launchSettings.json b/Projects/TestingSixPointZeroApplication/Properties/launchSettings.json deleted file mode 100644 index 9560d1a..0000000 --- a/Projects/TestingSixPointZeroApplication/Properties/launchSettings.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:25580", - "sslPort": 0 - } - }, - "profiles": { - "TestingSixPointZeroApplication": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "launchUrl": "swagger", - "applicationUrl": "http://localhost:5114", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "swagger", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} \ No newline at end of file diff --git a/Projects/TestingSixPointZeroApplication/Controllers/ValuesController.cs b/Projects/TestingWebApplication/Controllers/ValuesController.cs similarity index 91% rename from Projects/TestingSixPointZeroApplication/Controllers/ValuesController.cs rename to Projects/TestingWebApplication/Controllers/ValuesController.cs index 1a56c57..3fedd29 100644 --- a/Projects/TestingSixPointZeroApplication/Controllers/ValuesController.cs +++ b/Projects/TestingWebApplication/Controllers/ValuesController.cs @@ -1,7 +1,7 @@ using AccessTokenClient; using Microsoft.AspNetCore.Mvc; -namespace TestingSixPointZeroApplication.Controllers; +namespace TestingWebApplication.Controllers; [ApiController] [Route("values")] @@ -51,5 +51,5 @@ public class TestingClientOptions : ITokenRequestOptions public string ClientSecret { get; set; } - public string[] Scopes { get; set; } + public string[] Scopes { get; set; } = []; } \ No newline at end of file diff --git a/Projects/TestingSixPointZeroApplication/Program.cs b/Projects/TestingWebApplication/Program.cs similarity index 84% rename from Projects/TestingSixPointZeroApplication/Program.cs rename to Projects/TestingWebApplication/Program.cs index 06e44b1..3603e63 100644 --- a/Projects/TestingSixPointZeroApplication/Program.cs +++ b/Projects/TestingWebApplication/Program.cs @@ -1,7 +1,7 @@ using AccessTokenClient; using AccessTokenClient.Caching; using AccessTokenClient.Extensions; -using TestingSixPointZeroApplication.Controllers; +using TestingWebApplication.Controllers; var builder = WebApplication.CreateBuilder(args); @@ -9,7 +9,7 @@ builder.Services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new() { Title = "TestingSixPointZeroApplication", Version = "v1" }); + c.SwaggerDoc("v1", new() { Title = "TestingWebApplication", Version = "v1" }); }); builder.Services.AddMemoryCache(); @@ -33,7 +33,7 @@ TokenEndpoint = "https://localhost:44303/connect/token", ClientIdentifier = "testing_client_identifier", ClientSecret = "511536EF-F270-4058-80CA-1C89C192F69A", - Scopes = new[] { "employee:read" } + Scopes = ["movie:read"] }); builder.Services @@ -45,7 +45,7 @@ if (app.Environment.IsDevelopment()) { app.UseSwagger(); - app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TestingSixPointZeroApplication v1")); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TestingWebApplication v1")); } app.UseAuthorization(); diff --git a/Projects/TestingWebApplication/Properties/launchSettings.json b/Projects/TestingWebApplication/Properties/launchSettings.json new file mode 100644 index 0000000..8f8f317 --- /dev/null +++ b/Projects/TestingWebApplication/Properties/launchSettings.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "TestingWebApplication": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5114", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/Projects/TestingSixPointZeroApplication/TestingSixPointZeroApplication.csproj b/Projects/TestingWebApplication/TestingWebApplication.csproj similarity index 89% rename from Projects/TestingSixPointZeroApplication/TestingSixPointZeroApplication.csproj rename to Projects/TestingWebApplication/TestingWebApplication.csproj index 6a9c8d1..b7c5172 100644 --- a/Projects/TestingSixPointZeroApplication/TestingSixPointZeroApplication.csproj +++ b/Projects/TestingWebApplication/TestingWebApplication.csproj @@ -1,13 +1,13 @@ - net6.0 + net8.0 enable enable - + diff --git a/Projects/TestingSixPointZeroApplication/appsettings.json b/Projects/TestingWebApplication/appsettings.json similarity index 100% rename from Projects/TestingSixPointZeroApplication/appsettings.json rename to Projects/TestingWebApplication/appsettings.json diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 6c42ce4..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,54 +0,0 @@ -trigger: - - main - - development - -pool: - vmImage: "ubuntu-latest" - -variables: - buildConfiguration: "Release" - -steps: - - task: UseDotNet@2 - displayName: "SDK" - inputs: - packageType: "sdk" - version: "6.0.100" - - task: DotNetCoreCLI@2 - displayName: "Restore" - inputs: - command: "restore" - feedsToUse: "select" - - task: DotNetCoreCLI@2 - displayName: "Build" - inputs: - command: "build" - arguments: "--configuration $(buildConfiguration)" - projects: "**/*.csproj" - - task: DotNetCoreCLI@2 - displayName: "Test" - inputs: - command: "test" - arguments: "--configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/" - projects: "**/*.csproj" - - task: PublishCodeCoverageResults@1 - displayName: "Publish Coverage" - inputs: - codeCoverageTool: "Cobertura" - summaryFileLocation: "$(Build.SourcesDirectory)/TestResults/Coverage/coverage.cobertura.xml" - failIfCoverageEmpty: true - - task: DotNetCoreCLI@2 - inputs: - command: "pack" - packagesToPack: "**/*.csproj" - nobuild: true - includesymbols: true - includesource: true - versioningScheme: byPrereleaseNumber - - task: NuGetCommand@2 - displayName: "Push" - inputs: - command: "push" - packagesToPush: "$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg" - nuGetFeedType: "internal" - publishVstsFeed: "9566de23-5df9-4be2-b676-8ac0e1cbd609/45a7e446-1e14-44f0-a847-4c60611a0413" \ No newline at end of file From cc291ab4b69ee0616f5df03f42838754560262e7 Mon Sep 17 00:00:00 2001 From: wapplegate Date: Tue, 30 Jul 2024 13:17:57 -0400 Subject: [PATCH 2/2] Update action. --- .github/workflows/develop.yml | 4 ++-- .github/workflows/main.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 3b52e16..8455a65 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -10,9 +10,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - name: Restore diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b7a4685..1fc086f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,9 +7,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: 8.0.x - name: Restore