Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: Update project target frameworks and dependencies #251

Merged
merged 9 commits into from
Oct 29, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,10 @@ public async Task ListUsers()
}

var pagedEnumerable = this.Auth.ListUsersAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
var enumerator = pagedEnumerable.GetAsyncEnumerator();

var listedUsers = new List<string>();
while (await enumerator.MoveNext())
while (await enumerator.MoveNextAsync())
{
var uid = enumerator.Current.Uid;
if (users.Contains(uid) && !listedUsers.Contains(uid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using System.Threading.Tasks;
using FirebaseAdmin.Auth;
using FirebaseAdmin.Auth.Providers;
Expand Down Expand Up @@ -69,8 +68,8 @@ public async Task ListProviderConfig()
OidcProviderConfig config = null;

var pagedEnumerable = this.auth.ListOidcProviderConfigsAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
while (await enumerator.MoveNext())
var enumerator = pagedEnumerable.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
if (enumerator.Current.ProviderId == this.providerId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public async Task ListProviderConfig()
SamlProviderConfig config = null;

var pagedEnumerable = this.auth.ListSamlProviderConfigsAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
while (await enumerator.MoveNext())
var enumerator = pagedEnumerable.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
if (enumerator.Current.ProviderId == this.providerId)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Collections.Generic;
using System.Threading.Tasks;
using FirebaseAdmin.Auth;
using FirebaseAdmin.Auth.Multitenancy;
Expand Down Expand Up @@ -63,8 +62,8 @@ public async Task ListTenants()

var pagedEnumerable = FirebaseAuth.DefaultInstance.TenantManager
.ListTenantsAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
while (await enumerator.MoveNext())
var enumerator = pagedEnumerable.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
if (enumerator.Current.TenantId == this.fixture.TenantId)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>../../stylecop_test.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Apis.Auth" Version="1.40.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-beta.61">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
// limitations under the License.

using System;
using System.Collections.Generic;
using System.IO;
using FirebaseAdmin;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Json;

namespace FirebaseAdmin.IntegrationTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>../../stylecop_test.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Apis.Auth" Version="1.40.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.0" />
<PackageReference Include="Google.Apis.Auth" Version="1.49.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

using System;
// [START using_namespace_decl]
using FirebaseAdmin;
using FirebaseAdmin.Auth;
using Google.Apis.Auth.OAuth2;
// [END using_namespace_decl]
Expand Down
16 changes: 8 additions & 8 deletions FirebaseAdmin/FirebaseAdmin.Snippets/FirebaseAuthSnippets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ internal static async Task ListAllUsersAsync()
// [START list_all_users]
// Start listing users from the beginning, 1000 at a time.
var pagedEnumerable = FirebaseAuth.DefaultInstance.ListUsersAsync(null);
var responses = pagedEnumerable.AsRawResponses().GetEnumerator();
while (await responses.MoveNext())
var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator();
while (await responses.MoveNextAsync())
{
ExportedUserRecords response = responses.Current;
foreach (ExportedUserRecord user in response.Users)
Expand All @@ -510,8 +510,8 @@ internal static async Task ListAllUsersAsync()

// Iterate through all users. This will still retrieve users in batches,
// buffering no more than 1000 users in memory at a time.
var enumerator = FirebaseAuth.DefaultInstance.ListUsersAsync(null).GetEnumerator();
while (await enumerator.MoveNext())
var enumerator = FirebaseAuth.DefaultInstance.ListUsersAsync(null).GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
ExportedUserRecord user = enumerator.Current;
Console.WriteLine($"User: {user.Uid}");
Expand Down Expand Up @@ -756,9 +756,9 @@ internal static async Task ListSamlProviderConfigs()
};
IAsyncEnumerator<SamlProviderConfig> enumerator = FirebaseAuth.DefaultInstance
.ListSamlProviderConfigsAsync(listOptions)
.GetEnumerator();
.GetAsyncEnumerator();

while (await enumerator.MoveNext())
while (await enumerator.MoveNextAsync())
{
SamlProviderConfig saml = enumerator.Current;
Console.WriteLine(saml.ProviderId);
Expand Down Expand Up @@ -826,9 +826,9 @@ internal static async Task ListOidcProviderConfigs()
};
IAsyncEnumerator<OidcProviderConfig> enumerator = FirebaseAuth.DefaultInstance
.ListOidcProviderConfigsAsync(listOptions)
.GetEnumerator();
.GetAsyncEnumerator();

while (await enumerator.MoveNext())
while (await enumerator.MoveNextAsync())
{
OidcProviderConfig oidc = enumerator.Current;
Console.WriteLine(oidc.ProviderId);
Expand Down
3 changes: 0 additions & 3 deletions FirebaseAdmin/FirebaseAdmin.Tests/Auth/FirebaseAuthTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
// limitations under the License.

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using FirebaseAdmin.Auth.Jwt;
using Google.Apis.Auth.OAuth2;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ public async Task ListTenants()
var tenants = new List<Tenant>();

var pagedEnumerable = auth.TenantManager.ListTenantsAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
while (await enumerator.MoveNext())
var enumerator = pagedEnumerable.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
tenants.Add(enumerator.Current);
}
Expand Down Expand Up @@ -509,8 +509,8 @@ public async Task ListTenantsAsRawResponses()
var tokens = new List<string>();

var pagedEnumerable = auth.TenantManager.ListTenantsAsync(null);
var responses = pagedEnumerable.AsRawResponses().GetEnumerator();
while (await responses.MoveNext())
var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator();
while (await responses.MoveNextAsync())
{
tenants.AddRange(responses.Current.Tenants);
tokens.Add(responses.Current.NextPageToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ public async Task ListConfigs(ProviderTestConfig config)
var configs = new List<OidcProviderConfig>();

var pagedEnumerable = auth.ListOidcProviderConfigsAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
while (await enumerator.MoveNext())
var enumerator = pagedEnumerable.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
configs.Add(enumerator.Current);
}
Expand Down Expand Up @@ -528,8 +528,8 @@ public async Task ListOidcAsRawResponses(ProviderTestConfig config)
var tokens = new List<string>();

var pagedEnumerable = auth.ListOidcProviderConfigsAsync(null);
var responses = pagedEnumerable.AsRawResponses().GetEnumerator();
while (await responses.MoveNext())
var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator();
while (await responses.MoveNextAsync())
{
configs.AddRange(responses.Current.ProviderConfigs);
tokens.Add(responses.Current.NextPageToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ public async Task ListConfigs(ProviderTestConfig config)
var configs = new List<SamlProviderConfig>();

var pagedEnumerable = auth.ListSamlProviderConfigsAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
while (await enumerator.MoveNext())
var enumerator = pagedEnumerable.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
configs.Add(enumerator.Current);
}
Expand Down Expand Up @@ -523,8 +523,8 @@ public async Task ListSamlAsRawResponses(ProviderTestConfig config)
var tokens = new List<string>();

var pagedEnumerable = auth.ListSamlProviderConfigsAsync(null);
var responses = pagedEnumerable.AsRawResponses().GetEnumerator();
while (await responses.MoveNext())
var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator();
while (await responses.MoveNextAsync())
{
configs.AddRange(responses.Current.ProviderConfigs);
tokens.Add(responses.Current.NextPageToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using FirebaseAdmin.Auth.Hash;
Expand Down Expand Up @@ -443,8 +442,8 @@ public async Task ListUsers(TestConfig config)
var users = new List<ExportedUserRecord>();

var pagedEnumerable = auth.ListUsersAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
while (await enumerator.MoveNext())
var enumerator = pagedEnumerable.GetAsyncEnumerator();
while (await enumerator.MoveNextAsync())
{
users.Add(enumerator.Current);
if (users.Count % 3 == 0)
Expand Down Expand Up @@ -649,8 +648,8 @@ public async Task ListUsersAsRawResponses(TestConfig config)
var tokens = new List<string>();

var pagedEnumerable = auth.ListUsersAsync(null);
var responses = pagedEnumerable.AsRawResponses().GetEnumerator();
while (await responses.MoveNext())
var responses = pagedEnumerable.AsRawResponses().GetAsyncEnumerator();
while (await responses.MoveNextAsync())
{
users.AddRange(responses.Current.Users);
tokens.Add(responses.Current.NextPageToken);
Expand Down Expand Up @@ -750,7 +749,7 @@ public async Task ListUsersHttpError(TestConfig config)

var pagedEnumerable = auth.ListUsersAsync(null);
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
async () => await pagedEnumerable.First());
async () => await pagedEnumerable.FirstAsync());

Assert.Equal(ErrorCode.Internal, exception.ErrorCode);
Assert.Null(exception.AuthErrorCode);
Expand All @@ -775,16 +774,16 @@ public async Task ListUsersIntermittentHttpError(TestConfig config)
var auth = config.CreateAuth(handler);

var pagedEnumerable = auth.ListUsersAsync(null);
var enumerator = pagedEnumerable.GetEnumerator();
var enumerator = pagedEnumerable.GetAsyncEnumerator();
for (int i = 0; i < 3; i++)
{
Assert.True(await enumerator.MoveNext());
Assert.True(await enumerator.MoveNextAsync());
}

handler.StatusCode = HttpStatusCode.InternalServerError;
handler.Response = "{}";
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
async () => await enumerator.MoveNext());
async () => await enumerator.MoveNextAsync());

Assert.Equal(ErrorCode.Internal, exception.ErrorCode);
Assert.Null(exception.AuthErrorCode);
Expand Down Expand Up @@ -812,7 +811,7 @@ public async Task ListUsersNonJsonResponse(TestConfig config)

var pagedEnumerable = auth.ListUsersAsync(null);
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
async () => await pagedEnumerable.First());
async () => await pagedEnumerable.FirstAsync());

Assert.Equal(ErrorCode.Unknown, exception.ErrorCode);
Assert.Equal(AuthErrorCode.UnexpectedResponse, exception.AuthErrorCode);
Expand Down
19 changes: 13 additions & 6 deletions FirebaseAdmin/FirebaseAdmin.Tests/FirebaseAdmin.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<AssemblyOriginatorKeyFile>../../FirebaseAdmin.snk</AssemblyOriginatorKeyFile>
Expand All @@ -11,11 +11,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
<PackageReference Include="Google.Apis.Auth" Version="1.40.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Google.Apis.Auth" Version="1.49.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="System.Linq.Async" Version="4.1.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-beta.61">
<PrivateAssets>all</PrivateAssets>
Expand Down
1 change: 0 additions & 1 deletion FirebaseAdmin/FirebaseAdmin.Tests/Messaging/MessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using System.Collections.Generic;
using System.Linq;
using Google.Apis.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using FirebaseAdmin.Messaging;
using Newtonsoft.Json;
using Xunit;
Expand Down
6 changes: 1 addition & 5 deletions FirebaseAdmin/FirebaseAdmin/Auth/IUserInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace FirebaseAdmin.Auth
namespace FirebaseAdmin.Auth
{
/// <summary>
/// A collection of standard profile information for a user. Used to expose profile information
Expand Down
7 changes: 0 additions & 7 deletions FirebaseAdmin/FirebaseAdmin/Auth/Jwt/FirebaseTokenVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,8 @@ private async Task VerifySignatureAsync(
var keys = await this.keySource.GetPublicKeysAsync(cancellationToken)
.ConfigureAwait(false);
var verified = keys.Any(key =>
#if NETSTANDARD1_5 || NETSTANDARD2_0 || NET461
key.Id == keyId && key.RSA.VerifyHash(
hash, signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1)
#elif NET45
key.Id == keyId &&
((RSACryptoServiceProvider)key.RSA).VerifyHash(hash, Sha256Oid, signature)
#else
#error Unsupported target
#endif
);
if (!verified)
{
Expand Down
Loading