Skip to content

Commit c6b8bba

Browse files
authored
feat(auth): Added InvalidDynamicLinkDomain Error Code (#167)
* feat(auth): Added InvalidDynamicLinkDomain error code * Removed incorrect conditional in release workflow
1 parent d9ca03c commit c6b8bba

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ jobs:
100100
name: Release
101101

102102
- name: Setup .NET Core
103-
if: matrix.os == 'ubuntu-latest'
104103
uses: actions/setup-dotnet@v1
105104
with:
106105
dotnet-version: 2.2.108

FirebaseAdmin/FirebaseAdmin.Tests/Auth/EmailActionRequestTest.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System;
1616
using System.Collections.Generic;
1717
using System.Linq;
18+
using System.Net;
1819
using System.Net.Http;
1920
using System.Threading.Tasks;
2021
using FirebaseAdmin.Tests;
@@ -321,6 +322,35 @@ public async Task SignInWithEmailLinkUnexpectedResponse()
321322
Assert.Null(exception.InnerException);
322323
}
323324

325+
[Fact]
326+
public async Task InvalidDynamicLinkDomain()
327+
{
328+
var json = $@"{{
329+
""error"": {{
330+
""message"": ""INVALID_DYNAMIC_LINK_DOMAIN"",
331+
}}
332+
}}";
333+
var handler = new MockMessageHandler()
334+
{
335+
StatusCode = HttpStatusCode.InternalServerError,
336+
Response = json,
337+
};
338+
var auth = this.CreateFirebaseAuth(handler);
339+
340+
var exception = await Assert.ThrowsAsync<FirebaseAuthException>(
341+
async () => await auth.GenerateSignInWithEmailLinkAsync(
342+
"[email protected]", ActionCodeSettings));
343+
344+
Assert.Equal(ErrorCode.InvalidArgument, exception.ErrorCode);
345+
Assert.Equal(AuthErrorCode.InvalidDynamicLinkDomain, exception.AuthErrorCode);
346+
Assert.Equal(
347+
"Dynamic link domain specified in ActionCodeSettings is not authorized "
348+
+ "(INVALID_DYNAMIC_LINK_DOMAIN).",
349+
exception.Message);
350+
Assert.NotNull(exception.HttpResponse);
351+
Assert.Null(exception.InnerException);
352+
}
353+
324354
private FirebaseAuth CreateFirebaseAuth(HttpMessageHandler handler)
325355
{
326356
var userManager = new FirebaseUserManager(new FirebaseUserManager.Args

FirebaseAdmin/FirebaseAdmin/Auth/AuthErrorCode.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,10 @@ public enum AuthErrorCode
5858
/// No user record found for the given identifier.
5959
/// </summary>
6060
UserNotFound,
61+
62+
/// <summary>
63+
/// Dynamic link domain specified in <see cref="ActionCodeSettings"/> is not authorized.
64+
/// </summary>
65+
InvalidDynamicLinkDomain,
6166
}
6267
}

FirebaseAdmin/FirebaseAdmin/Auth/AuthErrorHandler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ internal sealed class AuthErrorHandler
5656
AuthErrorCode.EmailAlreadyExists,
5757
"The user with the provided email already exists")
5858
},
59+
{
60+
"INVALID_DYNAMIC_LINK_DOMAIN",
61+
new ErrorInfo(
62+
ErrorCode.InvalidArgument,
63+
AuthErrorCode.InvalidDynamicLinkDomain,
64+
"Dynamic link domain specified in ActionCodeSettings is not authorized")
65+
},
5966
{
6067
"PHONE_NUMBER_EXISTS",
6168
new ErrorInfo(

0 commit comments

Comments
 (0)