Skip to content

Commit

Permalink
Merge pull request #32 from wapplegate/feature/dotnet-8
Browse files Browse the repository at this point in the history
  • Loading branch information
wapplegate authored Jul 30, 2024
2 parents db1e221 + cc291ab commit 5ff2d4f
Show file tree
Hide file tree
Showing 26 changed files with 146 additions and 237 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/dotnet.yml → .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: development-build
name: develop-build-deploy

on:
push:
branches: ["development"]
branches: ["develop"]
pull_request:
branches: ["development"]
branches: ["develop"]

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: 6.0.x
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build, Test, Package, Deploy
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: main-build
name: main-build-deploy

on:
push:
Expand All @@ -7,11 +7,11 @@ 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: 6.0.x
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Build, Test, Package, Deploy
Expand Down
16 changes: 8 additions & 8 deletions AccessTokenClient.Extensions/AccessTokenClient.Extensions.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<EnablePackageValidation>true</EnablePackageValidation>
<Nullable>enable</Nullable>
<Version>3.0.1</Version>
<Version>4.0.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>William Applegate</Authors>
<Description>This package contains service collection extension methods to easily add the access token client to the service collection.</Description>
Expand All @@ -23,18 +23,18 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.0" />
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.7" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Scrutor" Version="4.2.0" />
<PackageReference Include="Scrutor" Version="4.2.2" />
</ItemGroup>

<ItemGroup>
Expand Down
26 changes: 13 additions & 13 deletions AccessTokenClient.Tests/AccessTokenClient.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="3.1.2">
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.6.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.17.2">
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.33.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2022.1.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Moq" Version="4.17.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exception>();
Expand Down
4 changes: 2 additions & 2 deletions AccessTokenClient.Tests/MemoryTokenResponseCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MemoryTokenResponseCacheTests
[Fact]
public void EnsureExceptionThrownWhenInjectedMemoryCacheIsNull()
{
Func<MemoryTokenResponseCache> creationFunction = () => new MemoryTokenResponseCache(null);
var creationFunction = () => new MemoryTokenResponseCache(null!);
creationFunction.Should().Throw<ArgumentNullException>();
}

Expand All @@ -27,7 +27,7 @@ public async Task EnsureSuccessResponseReturnedWhenCachedResponseExists()
});
var cache = new MemoryTokenResponseCache(memoryCache);
var tokenResponse = await cache.Get(Key);
tokenResponse.ShouldNotBeNull();
tokenResponse!.ShouldNotBeNull();
}

[Fact]
Expand Down
30 changes: 15 additions & 15 deletions AccessTokenClient.Tests/TokenClientCachingDecoratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -73,7 +73,7 @@ public async Task EnsureTokenResponseIsReturnedWhenCacheKeyIsNotFound()

// Set-up the token response cache mock:
var cacheMock = new Mock<ITokenResponseCache>();
cacheMock.Setup(m => m.Get(It.IsAny<string>(), It.IsAny<CancellationToken>())).ReturnsAsync((TokenResponse)null);
cacheMock.Setup(m => m.Get(It.IsAny<string>(), It.IsAny<CancellationToken>())).ReturnsAsync((TokenResponse)null!);

// Set-up the key generator mock:
var keyGeneratorMock = new Mock<IKeyGenerator>();
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -178,7 +178,7 @@ public async Task EnsureTokenResponseIsReturnedWhenScopesAreNotSpecified()

// Set-up the token response cache mock:
var cacheMock = new Mock<ITokenResponseCache>();
cacheMock.Setup(m => m.Get(It.IsAny<string>(), It.IsAny<CancellationToken>())).ReturnsAsync((TokenResponse)null);
cacheMock.Setup(m => m.Get(It.IsAny<string>(), It.IsAny<CancellationToken>())).ReturnsAsync((TokenResponse)null!);

// Set-up the key generator mock:
var keyGeneratorMock = new Mock<IKeyGenerator>();
Expand All @@ -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);
Expand All @@ -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<TokenClientCachingDecorator>(),
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions AccessTokenClient.Tests/TokenClientRetryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 5ff2d4f

Please sign in to comment.