1616 */
1717
1818// eslint-disable-next-line import/no-extraneous-dependencies
19- import { ActionCodeSettings , Auth , sendSignInLinkToEmail } from '@firebase/auth' ;
19+ import {
20+ ActionCodeSettings ,
21+ Auth ,
22+ sendSignInLinkToEmail
23+ } from '@firebase/auth' ;
2024import { expect , use } from 'chai' ;
2125import {
26+ cleanUpTestInstance ,
2227 getTestInstance ,
2328 randomEmail
2429} from '../../helpers/integration/helpers' ;
@@ -33,16 +38,16 @@ describe('Integration test: hosting link validation', () => {
3338 let auth : Auth ;
3439 let email : string ;
3540
36- const AUTHORIZED_CUSTOM_DOMAIN = " localhost/action_code_return" ;
37- const ANDROID_PACKAGE_NAME = " com.google.firebase.test.thin" ;
41+ const AUTHORIZED_CUSTOM_DOMAIN = ' localhost/action_code_return' ;
42+ const ANDROID_PACKAGE_NAME = ' com.google.firebase.test.thin' ;
3843 const BASE_SETTINGS : ActionCodeSettings = {
3944 url : 'http://' + AUTHORIZED_CUSTOM_DOMAIN ,
4045 handleCodeInApp : true ,
41- android : { packageName : ANDROID_PACKAGE_NAME } ,
46+ android : { packageName : ANDROID_PACKAGE_NAME }
4247 } ;
43- const VALID_LINK_DOMAIN = " jscore-sandbox.testdomaindonotuse.com" ;
44- const INVALID_LINK_DOMAIN = " invalid.testdomaindonotuse.com" ;
45- const INVALID_LINK_DOMAIN_ERROR = " auth/invalid-hosting-link-domain" ;
48+ const VALID_LINK_DOMAIN = ' jscore-sandbox.testdomaindonotuse.com' ;
49+ const INVALID_LINK_DOMAIN = ' invalid.testdomaindonotuse.com' ;
50+ const INVALID_LINK_DOMAIN_ERROR = ' auth/invalid-hosting-link-domain' ;
4651 const TEST_TENANT_ID = 'passpol-tenant-d7hha' ;
4752
4853 beforeEach ( function ( ) {
@@ -53,63 +58,49 @@ describe('Integration test: hosting link validation', () => {
5358 this . skip ( ) ;
5459 }
5560 } ) ;
56-
61+
62+ afterEach ( async ( ) => {
63+ await cleanUpTestInstance ( auth ) ;
64+ } ) ;
65+
5766 it ( 'allows user to sign in with default firebase hosting link' , async ( ) => {
5867 // Sends email link to user using default hosting link.
59- await sendSignInLinkToEmail (
60- auth ,
61- email ,
62- BASE_SETTINGS
63- ) ;
68+ await sendSignInLinkToEmail ( auth , email , BASE_SETTINGS ) ;
6469 } ) ;
6570
6671 it ( 'allows user to sign in to a tenant with default firebase hosting link' , async ( ) => {
6772 auth . tenantId = TEST_TENANT_ID ;
6873 // Sends email link to user using default hosting link.
69- await sendSignInLinkToEmail (
70- auth ,
71- email ,
72- BASE_SETTINGS
73- ) ;
74+ await sendSignInLinkToEmail ( auth , email , BASE_SETTINGS ) ;
7475 } ) ;
7576
7677 it ( 'allows user to sign in with custom firebase hosting link' , async ( ) => {
77- // Sends email link to user using custom hosting link.
78- await sendSignInLinkToEmail (
79- auth ,
80- email ,
81- {
82- ...BASE_SETTINGS ,
83- linkDomain : VALID_LINK_DOMAIN
84-
85- }
86- ) ;
87- } ) ;
78+ // Sends email link to user using custom hosting link.
79+ await sendSignInLinkToEmail ( auth , email , {
80+ ...BASE_SETTINGS ,
81+ linkDomain : VALID_LINK_DOMAIN
82+ } ) ;
83+ } ) ;
8884
89- it ( 'allows user to sign in to a tenant with custom firebase hosting link' , async ( ) => {
90- // Sends email link to user using custom hosting link.
91- auth . tenantId = TEST_TENANT_ID ;
92- await sendSignInLinkToEmail (
93- auth ,
94- email ,
95- {
96- ...BASE_SETTINGS ,
97- linkDomain : VALID_LINK_DOMAIN
98-
99- }
100- ) ;
101- } ) ;
85+ it ( 'allows user to sign in to a tenant with custom firebase hosting link' , async ( ) => {
86+ // Sends email link to user using custom hosting link.
87+ auth . tenantId = TEST_TENANT_ID ;
88+ await sendSignInLinkToEmail ( auth , email , {
89+ ...BASE_SETTINGS ,
90+ linkDomain : VALID_LINK_DOMAIN
91+ } ) ;
92+ } ) ;
10293
103- it ( 'sign in with invalid firebase hosting link throws exception' , async ( ) => {
104- // Throws an exception while sening email link to user using invalid hosting link.
105- await expect ( sendSignInLinkToEmail (
106- auth ,
107- email ,
108- {
109- ... BASE_SETTINGS ,
110- linkDomain : INVALID_LINK_DOMAIN
111-
112- }
113- ) ) . to . be . rejectedWith ( FirebaseError , new RegExp ( ".*" + INVALID_LINK_DOMAIN_ERROR + ".*" ) ) ;
114- } ) ;
94+ it ( 'sign in with invalid firebase hosting link throws exception' , async ( ) => {
95+ // Throws an exception while sening email link to user using invalid hosting link.
96+ await expect (
97+ sendSignInLinkToEmail ( auth , email , {
98+ ... BASE_SETTINGS ,
99+ linkDomain : INVALID_LINK_DOMAIN
100+ } )
101+ ) . to . be . rejectedWith (
102+ FirebaseError ,
103+ new RegExp ( '.*' + INVALID_LINK_DOMAIN_ERROR + '.*' )
104+ ) ;
105+ } ) ;
115106} ) ;
0 commit comments