From 9160557c44441c51dcf68a7a908edf95bc215b21 Mon Sep 17 00:00:00 2001 From: Jonathan Edey <145066863+jonathanedey@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:14:04 -0400 Subject: [PATCH 1/7] chore: Bump supported .NET versions to `net462` and `net6.0`+ (#377) * Add net6.0 to targeted frameworks * Add net6.0 to CI * fix: update target frameworks for integration tests ans snippets * Refactor build process and test multiple frameworks * Refactor build process and test multiple frameworks * fix script call * Refactor and update nightly and release workflows * Trigger Integration Tests * fix running unit tests in release stage * fix build before running integration tests * fix: revert to expected build name * try only 3.1 * try no specific version * fix set `Microsoft.NET.Test.Sdk` to 15.0.0 * Add Microsoft.TestPlatform.ObjectModel package for net462 * fix: Update xunit Packages and remove Microsoft.TestPlatform.ObjectModel package for net462 * Fix: tests * fix: added preprocessor directives to handle differences in tests between .net versions * Add netcoreapp3.1, net7.0 and net8.0 * fix: Add conditional package references and tests for netcoreapp3.1 * fix conditional test * Update workflows * fix: build before running integration tests * Removed netcoreap3.1 and redundant net7 and net8 --- .github/scripts/run_integration_tests.sh | 3 +- .github/workflows/ci.yml | 19 ++++--- .github/workflows/nightly.yml | 17 ++++--- .github/workflows/release.yml | 24 ++++----- .../Auth/AbstractFirebaseAuthTest.cs | 8 +-- .../FirebaseAdmin.IntegrationTests.csproj | 8 +-- .../FirebaseAdmin.Snippets.csproj | 2 +- .../FirebaseAuthSnippets.cs | 6 ++- .../FirebaseAdmin.Tests/Auth/AuthBuilder.cs | 10 ++-- .../Auth/Jwt/CustomTokenVerifier.cs | 4 +- .../Auth/Jwt/JwtTestUtils.cs | 2 +- .../Auth/Jwt/ServiceAccountSignerTest.cs | 4 +- .../Auth/Multitenancy/TenantManagerTest.cs | 16 +++--- .../Auth/Providers/OidcProviderConfigTest.cs | 12 ++--- .../Auth/Users/EmailActionRequestTest.cs | 28 +++++------ .../Auth/Users/FirebaseUserManagerTest.cs | 50 +++++++++---------- .../FirebaseAdmin.Tests.csproj | 7 ++- .../FirebaseAdmin.Tests/FirebaseAppTest.cs | 2 +- .../Messaging/BatchResponseTest.cs | 2 +- .../Messaging/FirebaseMessagingTest.cs | 14 ++++++ .../Messaging/MessageTest.cs | 4 ++ .../FirebaseAdmin/FirebaseAdmin.csproj | 2 +- 22 files changed, 132 insertions(+), 112 deletions(-) diff --git a/.github/scripts/run_integration_tests.sh b/.github/scripts/run_integration_tests.sh index 565986b8..9caee954 100755 --- a/.github/scripts/run_integration_tests.sh +++ b/.github/scripts/run_integration_tests.sh @@ -25,4 +25,5 @@ gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}" echo "${FIREBASE_API_KEY}" > FirebaseAdmin/FirebaseAdmin.IntegrationTests/resources/integration_apikey.txt -dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests +dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests --configuration Release --framework net462 +dotnet test FirebaseAdmin/FirebaseAdmin.IntegrationTests --configuration Release --framework net6.0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index af4aaa64..0cdf1e6c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] + framework-version: [net462, net6.0] env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 @@ -17,21 +18,19 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v4 - - name: Setup .NET Core 2.1 - uses: actions/setup-dotnet@v1 + - name: Setup .NET + uses: actions/setup-dotnet@v4 with: - dotnet-version: 2.1.x + dotnet-version: 6.0.x - name: Install dependencies - run: dotnet msbuild /t:restore FirebaseAdmin + run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln - name: Build with dotnet - run: | - dotnet msbuild FirebaseAdmin/FirebaseAdmin - dotnet msbuild FirebaseAdmin/FirebaseAdmin.Snippets - dotnet msbuild FirebaseAdmin/FirebaseAdmin.IntegrationTests + run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore - name: Run unit tests - run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests + run: | + dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build --framework ${{ matrix.framework-version }} diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 43094798..2c3e4889 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -34,23 +34,23 @@ jobs: steps: - name: Checkout source for staging - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: ${{ github.event.client_payload.ref || github.ref }} - - name: Setup .NET Core 2.1 - uses: actions/setup-dotnet@v1 + - name: Setup .NET + uses: actions/setup-dotnet@v4 with: - dotnet-version: 2.1.x + dotnet-version: 6.0.x - name: Install dependencies - run: dotnet msbuild /t:restore FirebaseAdmin + run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln - name: Build with dotnet - run: dotnet msbuild FirebaseAdmin/FirebaseAdmin + run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore - name: Run unit tests - run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests + run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build - name: Run integration tests run: ./.github/scripts/run_integration_tests.sh @@ -59,7 +59,8 @@ jobs: FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }} - name: Package release artifacts - run: dotnet pack -c Release FirebaseAdmin/FirebaseAdmin + run: dotnet pack FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore --no-build + # Attach the packaged artifacts to the workflow output. These can be manually # downloaded for later inspection if necessary. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d937c08d..d252e615 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,23 +46,23 @@ jobs: # via the 'ref' client parameter. steps: - name: Checkout source for staging - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: ref: ${{ github.event.client_payload.ref || github.ref }} - - name: Setup .NET Core 2.1 - uses: actions/setup-dotnet@v1 + - name: Setup .NET + uses: actions/setup-dotnet@v4 with: - dotnet-version: 2.1.x + dotnet-version: 6.0.x - name: Install dependencies - run: dotnet msbuild /t:restore FirebaseAdmin + run: dotnet restore FirebaseAdmin/FirebaseAdmin.sln - name: Build with dotnet - run: dotnet msbuild FirebaseAdmin/FirebaseAdmin + run: dotnet build FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore - name: Run unit tests - run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests + run: dotnet test FirebaseAdmin/FirebaseAdmin.Tests --configuration Release --no-restore --no-build - name: Run integration tests run: ./.github/scripts/run_integration_tests.sh @@ -71,7 +71,7 @@ jobs: FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }} - name: Package release artifacts - run: dotnet pack -c Release FirebaseAdmin/FirebaseAdmin + run: dotnet pack FirebaseAdmin/FirebaseAdmin.sln --configuration Release --no-restore --no-build # Attach the packaged artifacts to the workflow output. These can be manually # downloaded for later inspection if necessary. @@ -100,7 +100,7 @@ jobs: steps: - name: Checkout source for publish - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Download the artifacts created by the stage_release job. - name: Download release candidates @@ -108,10 +108,10 @@ jobs: with: name: Release - - name: Setup .NET Core - uses: actions/setup-dotnet@v1 + - name: Setup .NET + uses: actions/setup-dotnet@v4 with: - dotnet-version: 2.2.108 + dotnet-version: 6.0.x - name: Publish preflight check id: preflight diff --git a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs index 37b8d650..67516795 100644 --- a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs @@ -17,10 +17,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using System.Web; using FirebaseAdmin.Auth; using FirebaseAdmin.Auth.Hash; using Google.Apis.Auth.OAuth2; +using Microsoft.AspNetCore.WebUtilities; using Xunit; namespace FirebaseAdmin.IntegrationTests.Auth @@ -603,7 +603,7 @@ public async Task EmailVerificationLink() user.Email, EmailLinkSettings); var uri = new Uri(link); - var query = HttpUtility.ParseQueryString(uri.Query); + var query = QueryHelpers.ParseQuery(uri.Query); Assert.Equal(ContinueUrl, query["continueUrl"]); Assert.Equal("verifyEmail", query["mode"]); } @@ -617,7 +617,7 @@ public async Task PasswordResetLink() user.Email, EmailLinkSettings); var uri = new Uri(link); - var query = HttpUtility.ParseQueryString(uri.Query); + var query = QueryHelpers.ParseQuery(uri.Query); Assert.Equal(ContinueUrl, query["continueUrl"]); var request = new ResetPasswordRequest() @@ -645,7 +645,7 @@ public async Task SignInWithEmailLink() user.Email, EmailLinkSettings); var uri = new Uri(link); - var query = HttpUtility.ParseQueryString(uri.Query); + var query = QueryHelpers.ParseQuery(uri.Query); Assert.Equal(ContinueUrl, query["continueUrl"]); var idToken = await AuthIntegrationUtils.SignInWithEmailLinkAsync( diff --git a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj index 5c839131..2ac51960 100644 --- a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj +++ b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + net462;net6.0 latest false true @@ -10,8 +10,9 @@ - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -20,7 +21,6 @@ all - diff --git a/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj b/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj index 75cedf49..3564f4d1 100644 --- a/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj +++ b/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj @@ -1,7 +1,7 @@ - netcoreapp2.1 + net462;net6.0; false true ../../stylecop_test.ruleset diff --git a/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAuthSnippets.cs b/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAuthSnippets.cs index b11974cd..1b316fd6 100644 --- a/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAuthSnippets.cs +++ b/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAuthSnippets.cs @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Threading.Tasks; using FirebaseAdmin.Auth; @@ -582,9 +583,10 @@ internal static async Task SetCustomUserClaimsIncrementalAsync() object isAdmin; if (user.CustomClaims.TryGetValue("admin", out isAdmin) && (bool)isAdmin) { - var claims = new Dictionary(user.CustomClaims); + var claims = user.CustomClaims.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); // Add level. - claims["level"] = 10; + var level = 10; + claims["level"] = level; // Add custom claims for additional privileges. await FirebaseAuth.DefaultInstance.SetCustomUserClaimsAsync(user.Uid, claims); } diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/AuthBuilder.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/AuthBuilder.cs index decb54a8..bcd0b0b8 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/AuthBuilder.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/AuthBuilder.cs @@ -64,19 +64,19 @@ private void PopulateArgs(AbstractFirebaseAuth.Args args, TestOptions options) if (options.UserManagerRequestHandler != null) { args.UserManager = new Lazy( - this.CreateUserManager(options)); + () => this.CreateUserManager(options)); } if (options.ProviderConfigRequestHandler != null) { args.ProviderConfigManager = new Lazy( - this.CreateProviderConfigManager(options)); + () => this.CreateProviderConfigManager(options)); } if (options.IdTokenVerifier) { args.IdTokenVerifier = new Lazy( - this.CreateIdTokenVerifier()); + () => this.CreateIdTokenVerifier()); } if (options.SessionCookieVerifier) @@ -84,7 +84,7 @@ private void PopulateArgs(AbstractFirebaseAuth.Args args, TestOptions options) if (args is FirebaseAuth.Args) { (args as FirebaseAuth.Args).SessionCookieVerifier = - new Lazy(this.CreateSessionCookieVerifier()); + new Lazy(() => this.CreateSessionCookieVerifier()); } else { @@ -95,7 +95,7 @@ private void PopulateArgs(AbstractFirebaseAuth.Args args, TestOptions options) if (options.TokenFactory) { - args.TokenFactory = new Lazy(this.CreateTokenFactory()); + args.TokenFactory = new Lazy(() => this.CreateTokenFactory()); } } diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/CustomTokenVerifier.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/CustomTokenVerifier.cs index 314b28d7..7d365f68 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/CustomTokenVerifier.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/CustomTokenVerifier.cs @@ -45,7 +45,7 @@ internal static CustomTokenVerifier ForEmulator(string tenantId = null) internal void Verify(string token, string uid, IDictionary claims = null) { - string[] segments = token.Split("."); + string[] segments = token.Split('.'); Assert.Equal(3, segments.Length); var header = JwtUtils.Decode(segments[0]); @@ -99,7 +99,7 @@ internal RSACustomTokenVerifier(string issuer, byte[] publicKey, string tenantId : base(issuer, tenantId) { var x509cert = new X509Certificate2(publicKey); - this.rsa = (RSA)x509cert.PublicKey.Key; + this.rsa = (RSA)x509cert.GetRSAPublicKey(); } protected override void AssertSignature(string tokenData, string signature) diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/JwtTestUtils.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/JwtTestUtils.cs index db24f856..6972b4ac 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/JwtTestUtils.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/JwtTestUtils.cs @@ -113,7 +113,7 @@ private sealed class ByteArrayPublicKeySource : IPublicKeySource public ByteArrayPublicKeySource(byte[] publicKey) { var x509cert = new X509Certificate2(publicKey); - var rsa = (RSA)x509cert.PublicKey.Key; + var rsa = (RSA)x509cert.GetRSAPublicKey(); this.rsa = ImmutableList.Create(new PublicKey("test-key-id", rsa)); } diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/ServiceAccountSignerTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/ServiceAccountSignerTest.cs index 630b688a..21309907 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/ServiceAccountSignerTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Jwt/ServiceAccountSignerTest.cs @@ -34,7 +34,7 @@ public async Task Signer() Assert.Equal( "client@test-project.iam.gserviceaccount.com", await signer.GetKeyIdAsync()); byte[] data = Encoding.UTF8.GetBytes("Hello world"); - byte[] signature = signer.SignDataAsync(data).Result; + byte[] signature = await signer.SignDataAsync(data); Assert.True(this.Verify(data, signature)); } @@ -47,7 +47,7 @@ public void NullCredential() private bool Verify(byte[] data, byte[] signature) { var x509cert = new X509Certificate2(File.ReadAllBytes("./resources/public_cert.pem")); - var rsa = (RSA)x509cert.PublicKey.Key; + var rsa = (RSA)x509cert.GetRSAPublicKey(); return rsa.VerifyData( data, signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1); } diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Multitenancy/TenantManagerTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Multitenancy/TenantManagerTest.cs index 1d1361b4..25796e41 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Multitenancy/TenantManagerTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Multitenancy/TenantManagerTest.cs @@ -77,7 +77,7 @@ public static IEnumerable InvalidStrings() { var strings = new List() { null, string.Empty }; return TestConfigs.SelectMany( - config => strings, (config, str) => config.Append(str).ToArray()); + config => strings, (config, str) => config.Concat(new object[] { str }).ToArray()); } [Theory] @@ -93,7 +93,7 @@ public async Task GetTenant(TestConfig config) var provider = await auth.TenantManager.GetTenantAsync("tenant1"); AssertTenant(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Get, request.Method); config.AssertRequest("tenants/tenant1", request); @@ -152,7 +152,7 @@ public async Task CreateTenant(TestConfig config) var provider = await auth.TenantManager.CreateTenantAsync(args); AssertTenant(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Post, request.Method); config.AssertRequest("tenants", request); @@ -178,7 +178,7 @@ public async Task CreateTenantMinimal(TestConfig config) var provider = await auth.TenantManager.CreateTenantAsync(new TenantArgs()); AssertTenant(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Post, request.Method); config.AssertRequest("tenants", request); @@ -239,7 +239,7 @@ public async Task UpdateTenant(TestConfig config) var provider = await auth.TenantManager.UpdateTenantAsync("tenant1", args); AssertTenant(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpUtils.Patch, request.Method); var mask = "allowPasswordSignup,displayName,enableEmailLinkSignin"; @@ -270,7 +270,7 @@ public async Task UpdateTenantMinimal(TestConfig config) var provider = await auth.TenantManager.UpdateTenantAsync("tenant1", args); AssertTenant(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpUtils.Patch, request.Method); config.AssertRequest("tenants/tenant1?updateMask=displayName", request); @@ -354,7 +354,7 @@ public async Task DeleteTenant(TestConfig config) await auth.TenantManager.DeleteTenantAsync("tenant1"); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Delete, request.Method); config.AssertRequest("tenants/tenant1", request); @@ -669,7 +669,7 @@ internal FirebaseAuth CreateFirebaseAuth(HttpMessageHandler handler = null) EmulatorHost = this.EmulatorHost, }); var args = FirebaseAuth.Args.CreateDefault(); - args.TenantManager = new Lazy(tenantManager); + args.TenantManager = new Lazy(() => tenantManager); return new FirebaseAuth(args); } diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Providers/OidcProviderConfigTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Providers/OidcProviderConfigTest.cs index d68094f5..3dd8886f 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Providers/OidcProviderConfigTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Providers/OidcProviderConfigTest.cs @@ -72,7 +72,7 @@ public async Task GetConfig(ProviderTestConfig config) var provider = await auth.GetOidcProviderConfigAsync("oidc.provider"); this.AssertOidcProviderConfig(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Get, request.Method); config.AssertRequest("oauthIdpConfigs/oidc.provider", request); @@ -148,7 +148,7 @@ public async Task CreateConfig(ProviderTestConfig config) var provider = await auth.CreateProviderConfigAsync(args); this.AssertOidcProviderConfig(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Post, request.Method); config.AssertRequest("oauthIdpConfigs?oauthIdpConfigId=oidc.provider", request); @@ -184,7 +184,7 @@ public async Task CreateConfigMinimal(ProviderTestConfig config) var provider = await auth.CreateProviderConfigAsync(args); this.AssertOidcProviderConfig(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Post, request.Method); config.AssertRequest( @@ -271,7 +271,7 @@ public async Task UpdateConfig(ProviderTestConfig config) var provider = await auth.UpdateProviderConfigAsync(args); this.AssertOidcProviderConfig(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(ProviderTestConfig.PatchMethod, request.Method); var mask = "clientId,clientSecret,displayName,enabled,issuer,responseType.code,responseType.idToken"; @@ -307,7 +307,7 @@ public async Task UpdateConfigMinimal(ProviderTestConfig config) var provider = await auth.UpdateProviderConfigAsync(args); this.AssertOidcProviderConfig(provider); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(ProviderTestConfig.PatchMethod, request.Method); config.AssertRequest( @@ -382,7 +382,7 @@ public async Task DeleteConfig(ProviderTestConfig config) await auth.DeleteProviderConfigAsync("oidc.provider"); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = handler.Requests[0]; Assert.Equal(HttpMethod.Delete, request.Method); config.AssertRequest("oauthIdpConfigs/oidc.provider", request); diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Users/EmailActionRequestTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Users/EmailActionRequestTest.cs index d79887e8..fe3a8ec4 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Users/EmailActionRequestTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Users/EmailActionRequestTest.cs @@ -92,42 +92,42 @@ public class EmailActionRequestTest }; [Fact] - public void NoEmail() + public async void NoEmail() { var handler = new MockMessageHandler() { Response = GenerateEmailLinkResponse }; var auth = this.CreateFirebaseAuth(handler); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GenerateEmailVerificationLinkAsync(null)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GenerateEmailVerificationLinkAsync(string.Empty)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GeneratePasswordResetLinkAsync(null)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GeneratePasswordResetLinkAsync(string.Empty)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GenerateSignInWithEmailLinkAsync(null, ActionCodeSettings)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GenerateSignInWithEmailLinkAsync(string.Empty, ActionCodeSettings)); } [Theory] [MemberData(nameof(InvalidActionCodeSettingsArgs))] - public void InvalidActionCodeSettings(ActionCodeSettings settings) + public async void InvalidActionCodeSettings(ActionCodeSettings settings) { var handler = new MockMessageHandler() { Response = GenerateEmailLinkResponse }; var auth = this.CreateFirebaseAuth(handler); var email = "user@example.com"; - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GenerateEmailVerificationLinkAsync(email, settings)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GeneratePasswordResetLinkAsync(email, settings)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GenerateSignInWithEmailLinkAsync(email, settings)); } @@ -264,13 +264,13 @@ public async Task PasswordResetLinkUnexpectedResponse() } [Fact] - public void SignInWithEmailLinkNoSettings() + public async void SignInWithEmailLinkNoSettings() { var handler = new MockMessageHandler() { Response = GenerateEmailLinkResponse }; var auth = this.CreateFirebaseAuth(handler); var email = "user@example.com"; - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.GenerateSignInWithEmailLinkAsync(email, null)); } @@ -361,7 +361,7 @@ private FirebaseAuth CreateFirebaseAuth(HttpMessageHandler handler) RetryOptions = RetryOptions.NoBackOff, }); var args = FirebaseAuth.Args.CreateDefault(); - args.UserManager = new Lazy(userManager); + args.UserManager = new Lazy(() => userManager); return new FirebaseAuth(args); } diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Users/FirebaseUserManagerTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Users/FirebaseUserManagerTest.cs index 84a37494..616a8120 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Users/FirebaseUserManagerTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/Users/FirebaseUserManagerTest.cs @@ -564,7 +564,7 @@ public async Task ListUsersReadPage(TestConfig config) Assert.Equal("token", userPage.NextPageToken); Assert.Equal(3, userPage.Count()); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); config.AssertRequest( "accounts:batchGet?maxResults=3", Assert.Single(handler.Requests)); @@ -1302,7 +1302,7 @@ public async Task NullClaims(TestConfig config) [Theory] [MemberData(nameof(TestConfigs))] - public void ReservedClaims(TestConfig config) + public async void ReservedClaims(TestConfig config) { var handler = new MockMessageHandler(); var auth = config.CreateAuth(handler); @@ -1314,14 +1314,14 @@ public void ReservedClaims(TestConfig config) { key, "value" }, }; - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.SetCustomUserClaimsAsync("user1", customClaims)); } } [Theory] [MemberData(nameof(TestConfigs))] - public void UpdateUserNoUid(TestConfig config) + public async void UpdateUserNoUid(TestConfig config) { var handler = new MockMessageHandler(); var auth = config.CreateAuth(handler); @@ -1330,12 +1330,12 @@ public void UpdateUserNoUid(TestConfig config) { EmailVerified = true, }; - Assert.ThrowsAsync(async () => await auth.UpdateUserAsync(args)); + await Assert.ThrowsAsync(async () => await auth.UpdateUserAsync(args)); } [Theory] [MemberData(nameof(TestConfigs))] - public void UpdateUserInvalidUid(TestConfig config) + public async void UpdateUserInvalidUid(TestConfig config) { var handler = new MockMessageHandler(); var auth = config.CreateAuth(handler); @@ -1345,7 +1345,7 @@ public void UpdateUserInvalidUid(TestConfig config) EmailVerified = true, Uid = new string('a', 129), }; - Assert.ThrowsAsync(async () => await auth.UpdateUserAsync(args)); + await Assert.ThrowsAsync(async () => await auth.UpdateUserAsync(args)); } [Theory] @@ -1487,7 +1487,7 @@ public async Task UpdateUserShortPassword(TestConfig config) [Theory] [MemberData(nameof(TestConfigs))] - public void EmptyNameClaims(TestConfig config) + public async void EmptyNameClaims(TestConfig config) { var handler = new MockMessageHandler(); var auth = config.CreateAuth(handler); @@ -1496,13 +1496,13 @@ public void EmptyNameClaims(TestConfig config) { string.Empty, "value" }, }; - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.SetCustomUserClaimsAsync("user1", emptyClaims)); } [Theory] [MemberData(nameof(TestConfigs))] - public void LargeClaimsOverLimit(TestConfig config) + public async void LargeClaimsOverLimit(TestConfig config) { var handler = new MockMessageHandler(); var auth = config.CreateAuth(handler); @@ -1511,7 +1511,7 @@ public void LargeClaimsOverLimit(TestConfig config) { "testClaim", new string('a', 1001) }, }; - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.SetCustomUserClaimsAsync("user1", largeClaims)); } @@ -1721,7 +1721,7 @@ public async Task RevokeRefreshTokens(TestConfig config) await auth.RevokeRefreshTokensAsync("user1"); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = NewtonsoftJsonSerializer.Instance.Deserialize(handler.LastRequestBody); Assert.Equal(2, request.Count); Assert.Equal("user1", request["localId"]); @@ -1732,31 +1732,31 @@ public async Task RevokeRefreshTokens(TestConfig config) [Theory] [MemberData(nameof(TestConfigs))] - public void RevokeRefreshTokensNoUid(TestConfig config) + public async void RevokeRefreshTokensNoUid(TestConfig config) { var handler = new MockMessageHandler() { Response = CreateUserResponse }; var auth = config.CreateAuth(handler); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.RevokeRefreshTokensAsync(null)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.RevokeRefreshTokensAsync(string.Empty)); } [Theory] [MemberData(nameof(TestConfigs))] - public void RevokeRefreshTokensInvalidUid(TestConfig config) + public async void RevokeRefreshTokensInvalidUid(TestConfig config) { var auth = config.CreateAuth(new MockMessageHandler()); var uid = new string('a', 129); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.RevokeRefreshTokensAsync(uid)); } [Theory] [MemberData(nameof(MainTenantTestConfigs))] - public void CreateSessionCookieNoIdToken(TestConfig config) + public async void CreateSessionCookieNoIdToken(TestConfig config) { var handler = new MockMessageHandler() { Response = "{}" }; var auth = (FirebaseAuth)config.CreateAuth(handler); @@ -1765,31 +1765,31 @@ public void CreateSessionCookieNoIdToken(TestConfig config) ExpiresIn = TimeSpan.FromHours(1), }; - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.CreateSessionCookieAsync(null, options)); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.CreateSessionCookieAsync(string.Empty, options)); } [Theory] [MemberData(nameof(MainTenantTestConfigs))] - public void CreateSessionCookieNoOptions(TestConfig config) + public async void CreateSessionCookieNoOptions(TestConfig config) { var handler = new MockMessageHandler() { Response = "{}" }; var auth = (FirebaseAuth)config.CreateAuth(handler); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.CreateSessionCookieAsync("idToken", null)); } [Theory] [MemberData(nameof(MainTenantTestConfigs))] - public void CreateSessionCookieNoExpiresIn(TestConfig config) + public async void CreateSessionCookieNoExpiresIn(TestConfig config) { var handler = new MockMessageHandler() { Response = "{}" }; var auth = (FirebaseAuth)config.CreateAuth(handler); - Assert.ThrowsAsync( + await Assert.ThrowsAsync( async () => await auth.CreateSessionCookieAsync( "idToken", new SessionCookieOptions())); } @@ -1846,7 +1846,7 @@ public async Task CreateSessionCookie(TestConfig config) var result = await auth.CreateSessionCookieAsync(idToken, options); Assert.Equal("cookie", result); - Assert.Equal(1, handler.Requests.Count); + Assert.Single(handler.Requests); var request = NewtonsoftJsonSerializer.Instance.Deserialize(handler.LastRequestBody); Assert.Equal(2, request.Count); Assert.Equal(idToken, request["idToken"]); diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj b/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj index 974f2237..45566a4b 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj +++ b/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net462;net6.0 latest false ../../FirebaseAdmin.snk @@ -18,8 +18,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -28,7 +28,6 @@ all - diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAppTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAppTest.cs index 45fe909f..9f677011 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAppTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAppTest.cs @@ -250,7 +250,7 @@ public void GetSdkVersion() { var version = FirebaseApp.GetSdkVersion(); - var segments = version.Split("."); + var segments = version.Split('.'); Assert.Equal(3, segments.Length); int result; Assert.All(segments, (segment) => int.TryParse(segment, out result)); diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/BatchResponseTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/BatchResponseTest.cs index 71dd1d3a..77d56117 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/BatchResponseTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/BatchResponseTest.cs @@ -31,7 +31,7 @@ public void EmptyResponses() Assert.Equal(0, batchResponse.SuccessCount); Assert.Equal(0, batchResponse.FailureCount); - Assert.Equal(0, batchResponse.Responses.Count); + Assert.Empty(batchResponse.Responses); } [Fact] diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingTest.cs index ddcba187..564371bb 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/FirebaseMessagingTest.cs @@ -99,9 +99,16 @@ public async Task SendMessageCancel() FirebaseApp.Create(new AppOptions() { Credential = MockCredential }); var canceller = new CancellationTokenSource(); canceller.Cancel(); + + #if NET6_0_OR_GREATER + await Assert.ThrowsAsync( + async () => await FirebaseMessaging.DefaultInstance.SendAsync( + new Message() { Topic = "test-topic" }, canceller.Token)); + #else await Assert.ThrowsAsync( async () => await FirebaseMessaging.DefaultInstance.SendAsync( new Message() { Topic = "test-topic" }, canceller.Token)); + #endif } [Fact] @@ -114,9 +121,16 @@ public async Task SendMessageCancelWithClientFactory() }); var canceller = new CancellationTokenSource(); canceller.Cancel(); + + #if NET6_0_OR_GREATER + await Assert.ThrowsAsync( + async () => await FirebaseMessaging.DefaultInstance.SendAsync( + new Message() { Topic = "test-topic" }, canceller.Token)); + #else await Assert.ThrowsAsync( async () => await FirebaseMessaging.DefaultInstance.SendAsync( new Message() { Topic = "test-topic" }, canceller.Token)); + #endif } [Fact] diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs index b53e87b6..d57d2a4c 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs @@ -339,7 +339,11 @@ public void AndroidConfig() "color", new JObject() { { "red", 0.6666667 }, + #if NET6_0_OR_GREATER + { "green", 0.73333335 }, + #else { "green", 0.733333349 }, + #endif { "blue", 0.8 }, { "alpha", 0.8666667 }, } diff --git a/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj b/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj index a76a2371..1cbc8bee 100644 --- a/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj +++ b/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj @@ -2,7 +2,7 @@ 2.4.0 - netstandard2.0;net461 + netstandard2.0;net462;net6.0 latest true ../../FirebaseAdmin.snk From 50b0ed998ffa81abc9e1ffe95baab4b74738fdb8 Mon Sep 17 00:00:00 2001 From: Jonathan Edey <145066863+jonathanedey@users.noreply.github.com> Date: Wed, 3 Apr 2024 17:14:26 -0400 Subject: [PATCH 2/7] (chore): Upgrade Dependancies (#385) --- .../Auth/AbstractFirebaseAuthTest.cs | 3 ++- .../FirebaseAdmin.IntegrationTests.csproj | 5 +++-- .../IntegrationTestUtils.cs | 3 ++- .../FirebaseAdmin.Snippets.csproj | 11 ++++++++--- .../FirebaseAdmin.Tests/Auth/FirebaseAuthTest.cs | 1 + .../FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj | 8 ++++---- .../FirebaseAdmin.Tests/Messaging/MessageTest.cs | 3 ++- .../FirebaseAdmin/Auth/Jwt/FirebaseTokenFactory.cs | 1 + FirebaseAdmin/FirebaseAdmin/Auth/Jwt/IAMSigner.cs | 6 +++--- .../FirebaseAdmin/Auth/Multitenancy/Tenant.cs | 6 +++--- FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj | 10 +++++----- FirebaseAdmin/FirebaseAdmin/FirebaseApp.cs | 1 + .../Messaging/InstanceIdServiceResponse.cs | 6 +++--- README.md | 3 ++- 14 files changed, 40 insertions(+), 27 deletions(-) diff --git a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs index 67516795..13b0a9b4 100644 --- a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/Auth/AbstractFirebaseAuthTest.cs @@ -93,7 +93,8 @@ public async Task CreateCustomTokenWithoutServiceAccount() Credential = GoogleCredential.FromAccessToken(token), ServiceAccountId = serviceAcct.Id, ProjectId = serviceAcct.ProjectId, - }, "IAMSignApp"); + }, + "IAMSignApp"); try { diff --git a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj index 2ac51960..624fcabb 100644 --- a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj +++ b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/FirebaseAdmin.IntegrationTests.csproj @@ -9,15 +9,16 @@ - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all diff --git a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/IntegrationTestUtils.cs b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/IntegrationTestUtils.cs index 8b6af282..af807ec1 100644 --- a/FirebaseAdmin/FirebaseAdmin.IntegrationTests/IntegrationTestUtils.cs +++ b/FirebaseAdmin/FirebaseAdmin.IntegrationTests/IntegrationTestUtils.cs @@ -30,7 +30,8 @@ internal static class IntegrationTestUtils Credential = GoogleCredential.FromFile(ServiceAccountFile), }; return FirebaseApp.Create(options); - }, true); + }, + true); public static FirebaseApp EnsureDefaultApp() { diff --git a/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj b/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj index 3564f4d1..92a02278 100644 --- a/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj +++ b/FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAdmin.Snippets.csproj @@ -1,21 +1,26 @@ - net462;net6.0; + net462;net6.0 false true ../../stylecop_test.ruleset - + + + + + + - + all diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/FirebaseAuthTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/FirebaseAuthTest.cs index b68c84f9..3d780f9d 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Auth/FirebaseAuthTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Auth/FirebaseAuthTest.cs @@ -18,6 +18,7 @@ using Xunit; [assembly: CollectionBehavior(DisableTestParallelization = true)] + namespace FirebaseAdmin.Auth.Tests { public class FirebaseAuthTest : IDisposable diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj b/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj index 45566a4b..3bf40915 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj +++ b/FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj @@ -15,16 +15,16 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all diff --git a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs index d57d2a4c..aca5ea8a 100644 --- a/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs +++ b/FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs @@ -60,7 +60,8 @@ public void DataMessage() { { "topic", "test-topic" }, { "data", new JObject() { { "k1", "v1" }, { "k2", "v2" } } }, - }, message); + }, + message); } [Fact] diff --git a/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenFactory.cs b/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenFactory.cs index 8d7dcac0..a534be4a 100644 --- a/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenFactory.cs +++ b/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenFactory.cs @@ -28,6 +28,7 @@ "3003684e85e61cf15f13150008c81f0b75a252673028e530ea95d0c581378da8c6846526ab9597" + "4c6d0bc66d2462b51af69968a0e25114bde8811e0d6ee1dc22d4a59eee6a8bba4712cba839652f" + "badddb9c")] + namespace FirebaseAdmin.Auth.Jwt { /// diff --git a/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/IAMSigner.cs b/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/IAMSigner.cs index 7c9394c7..559667da 100644 --- a/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/IAMSigner.cs +++ b/FirebaseAdmin/FirebaseAdmin/Auth/Jwt/IAMSigner.cs @@ -56,8 +56,7 @@ public IAMSigner( RetryOptions = retryOptions, }); this.keyId = new Lazy>( - async () => await DiscoverServiceAccountIdAsync(clientFactory) - .ConfigureAwait(false), true); + async () => await DiscoverServiceAccountIdAsync(clientFactory).ConfigureAwait(false), true); } public string Algorithm => JwtUtils.AlgorithmRS256; @@ -98,7 +97,8 @@ public virtual async Task GetKeyIdAsync( + "with service account credentials or specify a service account " + "ID with iam.serviceAccounts.signBlob permission. Please refer to " + "https://firebase.google.com/docs/auth/admin/create-custom-tokens for " - + "more details on creating custom tokens.", e); + + "more details on creating custom tokens.", + e); } } diff --git a/FirebaseAdmin/FirebaseAdmin/Auth/Multitenancy/Tenant.cs b/FirebaseAdmin/FirebaseAdmin/Auth/Multitenancy/Tenant.cs index 91880b50..3f2eff94 100644 --- a/FirebaseAdmin/FirebaseAdmin/Auth/Multitenancy/Tenant.cs +++ b/FirebaseAdmin/FirebaseAdmin/Auth/Multitenancy/Tenant.cs @@ -53,17 +53,17 @@ internal Tenant(TenantArgs args) /// /// Gets the tenant display name. /// - public string DisplayName => args.DisplayName; + public string DisplayName => this.args.DisplayName; /// /// Gets a value indicating whether the email sign-in provider is enabled. /// - public bool PasswordSignUpAllowed => args.PasswordSignUpAllowed ?? false; + public bool PasswordSignUpAllowed => this.args.PasswordSignUpAllowed ?? false; /// /// Gets a value indicating whether the email link sign-in is enabled. /// - public bool EmailLinkSignInEnabled => args.EmailLinkSignInEnabled ?? false; + public bool EmailLinkSignInEnabled => this.args.EmailLinkSignInEnabled ?? false; private string ExtractResourceId(string resourceName) { diff --git a/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj b/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj index 1cbc8bee..d6aa6d65 100644 --- a/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj +++ b/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj @@ -24,11 +24,11 @@ - - - - - + + + + + all diff --git a/FirebaseAdmin/FirebaseAdmin/FirebaseApp.cs b/FirebaseAdmin/FirebaseAdmin/FirebaseApp.cs index 3371a000..4818b2dc 100644 --- a/FirebaseAdmin/FirebaseAdmin/FirebaseApp.cs +++ b/FirebaseAdmin/FirebaseAdmin/FirebaseApp.cs @@ -27,6 +27,7 @@ "3003684e85e61cf15f13150008c81f0b75a252673028e530ea95d0c581378da8c6846526ab9597" + "4c6d0bc66d2462b51af69968a0e25114bde8811e0d6ee1dc22d4a59eee6a8bba4712cba839652f" + "badddb9c")] + namespace FirebaseAdmin { internal delegate TResult ServiceFactory() diff --git a/FirebaseAdmin/FirebaseAdmin/Messaging/InstanceIdServiceResponse.cs b/FirebaseAdmin/FirebaseAdmin/Messaging/InstanceIdServiceResponse.cs index 4ed4bb52..37ffedba 100644 --- a/FirebaseAdmin/FirebaseAdmin/Messaging/InstanceIdServiceResponse.cs +++ b/FirebaseAdmin/FirebaseAdmin/Messaging/InstanceIdServiceResponse.cs @@ -20,12 +20,12 @@ internal class InstanceIdServiceResponse /// /// Gets the number of errors returned by the operation. /// - public int ErrorCount => Results?.Count(results => results.HasError) ?? 0; + public int ErrorCount => this.Results?.Count(results => results.HasError) ?? 0; /// /// Gets the number of results returned by the operation. /// - public int ResultCount => Results?.Count() ?? 0; + public int ResultCount => this.Results?.Count() ?? 0; /// /// An instance Id response error. @@ -41,7 +41,7 @@ internal class InstanceIdServiceResponseElement /// /// Gets a value indicating whether this response element in the response array is an error, as an empty element indicates success. /// - public bool HasError => !string.IsNullOrEmpty(Error); + public bool HasError => !string.IsNullOrEmpty(this.Error); } } } diff --git a/README.md b/README.md index 598c3775..157d5b97 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,9 @@ We also welcome bug reports, feature requests, and code review feedback. Admin .NET SDK supports the following frameworks: -* .NET Framework 4.6.1+ +* .NET Framework 4.6.2+ * .NET Standard 2.0, providing .NET Core support +* .NET 6.0+ This is consistent with the frameworks supported by other .NET libraries associated with Google Cloud Platform. From 12c688a5e9d1882dc8201b01100b2e2d0f47e287 Mon Sep 17 00:00:00 2001 From: Jonathan Edey <145066863+jonathanedey@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:31:11 -0400 Subject: [PATCH 3/7] [chore] Update Github action workflows to fix node version and `set-output` deprecation warnings (#376) --- .github/scripts/publish_preflight_check.sh | 13 +++++++------ .github/workflows/ci.yml | 1 + .github/workflows/nightly.yml | 7 ++++--- .github/workflows/release.yml | 16 ++++++---------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.github/scripts/publish_preflight_check.sh b/.github/scripts/publish_preflight_check.sh index eb6bf18e..25c0e51b 100755 --- a/.github/scripts/publish_preflight_check.sh +++ b/.github/scripts/publish_preflight_check.sh @@ -70,7 +70,7 @@ if [[ ! "${RELEASE_VERSION}" =~ ^([0-9]*)\.([0-9]*)\.([0-9]*)$ ]]; then fi echo_info "Extracted release version: ${RELEASE_VERSION}" -echo "::set-output name=version::v${RELEASE_VERSION}" +echo "version=v${RELEASE_VERSION}" >> $GITHUB_OUTPUT echo_info "" @@ -155,12 +155,13 @@ readonly CHANGELOG=`${CURRENT_DIR}/generate_changelog.sh` echo "$CHANGELOG" # Parse and preformat the text to handle multi-line output. -# See https://github.community/t5/GitHub-Actions/set-output-Truncates-Multiline-Strings/td-p/37870 +# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string +# and https://github.com/github/docs/issues/21529#issue-1418590935 FILTERED_CHANGELOG=`echo "$CHANGELOG" | grep -v "\\[INFO\\]"` || true -FILTERED_CHANGELOG="${FILTERED_CHANGELOG//'%'/'%25'}" -FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\n'/'%0A'}" -FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\r'/'%0D'}" -echo "::set-output name=changelog::${FILTERED_CHANGELOG}" +FILTERED_CHANGELOG="${FILTERED_CHANGELOG//$'\''/'"'}" +echo "changelog<> $GITHUB_OUTPUT +echo -e "$FILTERED_CHANGELOG" >> $GITHUB_OUTPUT +echo "CHANGELOGEOF" >> $GITHUB_OUTPUT echo "" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0cdf1e6c..2f35e32c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Setup .NET uses: actions/setup-dotnet@v4 with: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2c3e4889..bd7c77b1 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -28,9 +28,9 @@ jobs: runs-on: ubuntu-latest env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - DOTNET_NOLOGO: 1 + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + DOTNET_NOLOGO: true steps: - name: Checkout source for staging @@ -38,6 +38,7 @@ jobs: with: ref: ${{ github.event.client_payload.ref || github.ref }} + - name: Setup .NET uses: actions/setup-dotnet@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d252e615..9cb77aa7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,6 +50,7 @@ jobs: with: ref: ${{ github.event.client_payload.ref || github.ref }} + - name: Setup .NET uses: actions/setup-dotnet@v4 with: @@ -108,6 +109,7 @@ jobs: with: name: Release + - name: Setup .NET uses: actions/setup-dotnet@v4 with: @@ -117,19 +119,13 @@ jobs: id: preflight run: ./.github/scripts/publish_preflight_check.sh - # We pull this action from a custom fork of a contributor until - # https://github.com/actions/create-release/pull/32 is merged. Also note that v1 of - # this action does not support the "body" parameter. + # See: https://cli.github.com/manual/gh_release_create - name: Create release tag - uses: fleskesvor/create-release@1a72e235c178bf2ae6c51a8ae36febc24568c5fe env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.preflight.outputs.version }} - release_name: Firebase Admin .NET SDK ${{ steps.preflight.outputs.version }} - body: ${{ steps.preflight.outputs.changelog }} - draft: false - prerelease: false + run: gh release create ${{ steps.preflight.outputs.version }} + --title "Firebase Admin .NET SDK ${{ steps.preflight.outputs.version }}" + --notes '${{ steps.preflight.outputs.changelog }}' - name: Publish to Nuget run: ./.github/scripts/publish_package.sh From 2b81d3ae25d53ea13b3cdce535d8d426410652b3 Mon Sep 17 00:00:00 2001 From: Jonathan Edey <145066863+jonathanedey@users.noreply.github.com> Date: Tue, 9 Apr 2024 16:31:39 -0400 Subject: [PATCH 4/7] Add `README.md` to Nuget and update `CONTRIBUTING.md` (#389) --- CONTRIBUTING.md | 5 +++-- FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj | 5 +++++ README.md | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e792f7aa..7009675f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -92,8 +92,9 @@ This section explains how to set up a development environment on Linux or Mac. W should be able to import the solution file (`FirebaseAdmin/FirebaseAdmin.sln`) into Visual Studio. -Start by installing [.NET Core](https://www.microsoft.com/net/download) 2.1 or higher. This -installs the `dotnet` command-line utility into the system. +Start by installing [.NET](https://dotnet.microsoft.com/en-us/download) 6 or higher or +[.NET Framework](https://dotnet.microsoft.com/en-us/download/dotnet-framework) 4.6.2 or +higher. This installs the `dotnet` command-line utility into the system. Run the following commands from the command line to get your local environmentset up: diff --git a/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj b/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj index d6aa6d65..43cb7759 100644 --- a/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj +++ b/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj @@ -21,8 +21,13 @@ git https://github.com/Firebase/firebase-admin-dotnet ../../stylecop.ruleset + README.md + + + + diff --git a/README.md b/README.md index 157d5b97..401bb5e4 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ We also welcome bug reports, feature requests, and code review feedback. Admin .NET SDK supports the following frameworks: * .NET Framework 4.6.2+ -* .NET Standard 2.0, providing .NET Core support +* .NET Standard 2.0 * .NET 6.0+ This is consistent with the frameworks supported by other .NET libraries From 3b9ed3960d1d02fdada20f69b032a37275ba51d0 Mon Sep 17 00:00:00 2001 From: Jonathan Edey Date: Tue, 9 Apr 2024 17:03:21 -0400 Subject: [PATCH 5/7] Trigger Integration tests From ba754f0bd115572a3e63e869f52a3a37e5fc4c5a Mon Sep 17 00:00:00 2001 From: Jonathan Edey Date: Tue, 9 Apr 2024 17:12:01 -0400 Subject: [PATCH 6/7] fix: correct target framework from merge. --- FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj b/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj index 7df16791..2b036449 100644 --- a/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj +++ b/FirebaseAdmin/FirebaseAdmin/FirebaseAdmin.csproj @@ -2,7 +2,7 @@ 2.4.1 - netstandard2.0;net461 + netstandard2.0;net462;net6.0 latest true ../../FirebaseAdmin.snk From 6abd08300ff7e682969a7333464630aa25bff365 Mon Sep 17 00:00:00 2001 From: Jonathan Edey Date: Wed, 10 Apr 2024 11:35:01 -0400 Subject: [PATCH 7/7] fix: remove previous deprecation note --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index a4be8f0c..401bb5e4 100644 --- a/README.md +++ b/README.md @@ -63,11 +63,6 @@ Admin .NET SDK supports the following frameworks: * .NET Standard 2.0 * .NET 6.0+ -Support for .NET Framework 4.6.1 is now deprecated. -Next major version of the Admin SDK will terminate support for this -framework. Developers are advised to upgrade their runtime frameworks -accordingly. - This is consistent with the frameworks supported by other .NET libraries associated with Google Cloud Platform.