Skip to content

Commit

Permalink
feat(auth): Added InvalidDynamicLinkDomain Error Code (#167)
Browse files Browse the repository at this point in the history
* feat(auth): Added InvalidDynamicLinkDomain error code

* Removed incorrect conditional in release workflow
  • Loading branch information
hiranya911 authored Apr 8, 2020
1 parent d9ca03c commit c6b8bba
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ jobs:
name: Release

- name: Setup .NET Core
if: matrix.os == 'ubuntu-latest'
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.2.108
Expand Down
30 changes: 30 additions & 0 deletions FirebaseAdmin/FirebaseAdmin.Tests/Auth/EmailActionRequestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using FirebaseAdmin.Tests;
Expand Down Expand Up @@ -321,6 +322,35 @@ public async Task SignInWithEmailLinkUnexpectedResponse()
Assert.Null(exception.InnerException);
}

[Fact]
public async Task InvalidDynamicLinkDomain()
{
var json = $@"{{
""error"": {{
""message"": ""INVALID_DYNAMIC_LINK_DOMAIN"",
}}
}}";
var handler = new MockMessageHandler()
{
StatusCode = HttpStatusCode.InternalServerError,
Response = json,
};
var auth = this.CreateFirebaseAuth(handler);

var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
async () => await auth.GenerateSignInWithEmailLinkAsync(
"[email protected]", ActionCodeSettings));

Assert.Equal(ErrorCode.InvalidArgument, exception.ErrorCode);
Assert.Equal(AuthErrorCode.InvalidDynamicLinkDomain, exception.AuthErrorCode);
Assert.Equal(
"Dynamic link domain specified in ActionCodeSettings is not authorized "
+ "(INVALID_DYNAMIC_LINK_DOMAIN).",
exception.Message);
Assert.NotNull(exception.HttpResponse);
Assert.Null(exception.InnerException);
}

private FirebaseAuth CreateFirebaseAuth(HttpMessageHandler handler)
{
var userManager = new FirebaseUserManager(new FirebaseUserManager.Args
Expand Down
5 changes: 5 additions & 0 deletions FirebaseAdmin/FirebaseAdmin/Auth/AuthErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,10 @@ public enum AuthErrorCode
/// No user record found for the given identifier.
/// </summary>
UserNotFound,

/// <summary>
/// Dynamic link domain specified in <see cref="ActionCodeSettings"/> is not authorized.
/// </summary>
InvalidDynamicLinkDomain,
}
}
7 changes: 7 additions & 0 deletions FirebaseAdmin/FirebaseAdmin/Auth/AuthErrorHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ internal sealed class AuthErrorHandler
AuthErrorCode.EmailAlreadyExists,
"The user with the provided email already exists")
},
{
"INVALID_DYNAMIC_LINK_DOMAIN",
new ErrorInfo(
ErrorCode.InvalidArgument,
AuthErrorCode.InvalidDynamicLinkDomain,
"Dynamic link domain specified in ActionCodeSettings is not authorized")
},
{
"PHONE_NUMBER_EXISTS",
new ErrorInfo(
Expand Down

0 comments on commit c6b8bba

Please sign in to comment.