16
16
*/
17
17
18
18
// 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' ;
20
24
import { expect , use } from 'chai' ;
21
25
import {
26
+ cleanUpTestInstance ,
22
27
getTestInstance ,
23
28
randomEmail
24
29
} from '../../helpers/integration/helpers' ;
@@ -33,16 +38,16 @@ describe('Integration test: hosting link validation', () => {
33
38
let auth : Auth ;
34
39
let email : string ;
35
40
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' ;
38
43
const BASE_SETTINGS : ActionCodeSettings = {
39
44
url : 'http://' + AUTHORIZED_CUSTOM_DOMAIN ,
40
45
handleCodeInApp : true ,
41
- android : { packageName : ANDROID_PACKAGE_NAME } ,
46
+ android : { packageName : ANDROID_PACKAGE_NAME }
42
47
} ;
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' ;
46
51
const TEST_TENANT_ID = 'passpol-tenant-d7hha' ;
47
52
48
53
beforeEach ( function ( ) {
@@ -53,63 +58,49 @@ describe('Integration test: hosting link validation', () => {
53
58
this . skip ( ) ;
54
59
}
55
60
} ) ;
56
-
61
+
62
+ afterEach ( async ( ) => {
63
+ await cleanUpTestInstance ( auth ) ;
64
+ } ) ;
65
+
57
66
it ( 'allows user to sign in with default firebase hosting link' , async ( ) => {
58
67
// 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 ) ;
64
69
} ) ;
65
70
66
71
it ( 'allows user to sign in to a tenant with default firebase hosting link' , async ( ) => {
67
72
auth . tenantId = TEST_TENANT_ID ;
68
73
// 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 ) ;
74
75
} ) ;
75
76
76
77
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
+ } ) ;
88
84
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
+ } ) ;
102
93
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
+ } ) ;
115
106
} ) ;
0 commit comments