@@ -952,15 +952,19 @@ function testUseEmulator() {
952
952
auth1 . useEmulator ( 'http://emulator.test.domain:1234' ) ;
953
953
assertObjectEquals (
954
954
{
955
- url : 'http://emulator.test.domain:1234' ,
955
+ protocol : 'http' ,
956
+ host : 'emulator.test.domain' ,
957
+ port : 1234 ,
958
+ options : { disableWarnings : false } ,
956
959
} ,
957
- auth1 . getEmulatorConfig ( ) ) ;
960
+ auth1 . emulatorConfig ) ;
958
961
// Should notify the RPC handler.
959
962
assertEquals (
960
963
1 , fireauth . RpcHandler . prototype . updateEmulatorConfig . getCallCount ( ) ) ;
961
964
assertObjectEquals (
962
965
{
963
966
url : 'http://emulator.test.domain:1234' ,
967
+ disableWarnings : false ,
964
968
} ,
965
969
fireauth . RpcHandler . prototype . updateEmulatorConfig . getLastCall ( )
966
970
. getArgument ( 0 )
@@ -986,9 +990,12 @@ function testUseEmulator() {
986
990
auth1 . useEmulator ( 'http://emulator.test.domain:1234' ) ;
987
991
assertObjectEquals (
988
992
{
989
- url : 'http://emulator.test.domain:1234' ,
993
+ protocol : 'http' ,
994
+ host : 'emulator.test.domain' ,
995
+ port : 1234 ,
996
+ options : { disableWarnings : false } ,
990
997
} ,
991
- auth1 . getEmulatorConfig ( ) ) ;
998
+ auth1 . emulatorConfig ) ;
992
999
assertEquals (
993
1000
1 , fireauth . RpcHandler . prototype . updateEmulatorConfig . getCallCount ( ) ) ;
994
1001
assertEquals ( 1 , fireauth . util . consoleInfo . getCallCount ( ) ) ;
@@ -997,9 +1004,12 @@ function testUseEmulator() {
997
1004
auth1 . useEmulator ( 'http://emulator.other.domain:9876' ) ;
998
1005
assertObjectEquals (
999
1006
{
1000
- url : 'http://emulator.test.domain:1234' ,
1007
+ protocol : 'http' ,
1008
+ host : 'emulator.test.domain' ,
1009
+ port : 1234 ,
1010
+ options : { disableWarnings : false } ,
1001
1011
} ,
1002
- auth1 . getEmulatorConfig ( ) ) ;
1012
+ auth1 . emulatorConfig ) ;
1003
1013
assertEquals (
1004
1014
1 , fireauth . RpcHandler . prototype . updateEmulatorConfig . getCallCount ( ) ) ;
1005
1015
}
@@ -1030,16 +1040,20 @@ function testUseEmulator_withDisableWarnings() {
1030
1040
auth1 . useEmulator (
1031
1041
'http://emulator.test.domain:1234' , { disableWarnings : true } ) ;
1032
1042
assertObjectEquals (
1033
- {
1034
- url : 'http://emulator.test.domain:1234' ,
1035
- } ,
1036
- auth1 . getEmulatorConfig ( ) ) ;
1043
+ {
1044
+ protocol : 'http' ,
1045
+ host : 'emulator.test.domain' ,
1046
+ port : 1234 ,
1047
+ options : { disableWarnings : true } ,
1048
+ } ,
1049
+ auth1 . emulatorConfig ) ;
1037
1050
// Should notify the RPC handler.
1038
1051
assertEquals (
1039
1052
1 , fireauth . RpcHandler . prototype . updateEmulatorConfig . getCallCount ( ) ) ;
1040
1053
assertObjectEquals (
1041
1054
{
1042
1055
url : 'http://emulator.test.domain:1234' ,
1056
+ disableWarnings : true ,
1043
1057
} ,
1044
1058
fireauth . RpcHandler . prototype . updateEmulatorConfig . getLastCall ( )
1045
1059
. getArgument ( 0 ) ) ;
@@ -1057,6 +1071,76 @@ function testUseEmulator_withDisableWarnings() {
1057
1071
}
1058
1072
1059
1073
1074
+ function testEmulatorConfig ( ) {
1075
+ app1 = firebase . initializeApp ( config1 , appId1 ) ;
1076
+ auth1 = app1 . auth ( ) ;
1077
+
1078
+ // Update the emulator config.
1079
+ auth1 . useEmulator (
1080
+ 'http://emulator.test.domain:1234' , { disableWarnings : true } ) ;
1081
+ assertObjectEquals (
1082
+ {
1083
+ protocol : 'http' ,
1084
+ host : 'emulator.test.domain' ,
1085
+ port : 1234 ,
1086
+ options : { disableWarnings : true } ,
1087
+ } ,
1088
+ auth1 . emulatorConfig ) ;
1089
+ }
1090
+
1091
+
1092
+ /**
1093
+ * Asserts that the port is correctly set to null if no port supplied.
1094
+ */
1095
+ function testEmulatorConfig_noPortSpecified ( ) {
1096
+ app1 = firebase . initializeApp ( config1 , appId1 ) ;
1097
+ auth1 = app1 . auth ( ) ;
1098
+
1099
+ // Update the emulator config.
1100
+ auth1 . useEmulator ( 'http://emulator.test.domain' ) ;
1101
+ assertObjectEquals (
1102
+ {
1103
+ protocol : 'http' ,
1104
+ host : 'emulator.test.domain' ,
1105
+ port : null ,
1106
+ options : { disableWarnings : false } ,
1107
+ } ,
1108
+ auth1 . emulatorConfig ) ;
1109
+ }
1110
+
1111
+
1112
+ /**
1113
+ * Asserts that the port is correctly assigned 0 if specifically set to 0 for
1114
+ * some reason. Also checks https protocol.
1115
+ */
1116
+ function testEmulatorConfig_portZeroAndHttpsSpecified ( ) {
1117
+ app1 = firebase . initializeApp ( config1 , appId1 ) ;
1118
+ auth1 = app1 . auth ( ) ;
1119
+
1120
+ // Update the emulator config.
1121
+ auth1 . useEmulator ( 'https://emulator.test.domain:0' ) ;
1122
+ assertObjectEquals (
1123
+ {
1124
+ protocol : 'https' ,
1125
+ host : 'emulator.test.domain' ,
1126
+ port : 0 ,
1127
+ options : { disableWarnings : false } ,
1128
+ } ,
1129
+ auth1 . emulatorConfig ) ;
1130
+ }
1131
+
1132
+
1133
+ /**
1134
+ * Asserts that the function returns null if useEmulator is not called.
1135
+ */
1136
+ function testEmulatorConfig_nullIfNoEmulatorConfig ( ) {
1137
+ app1 = firebase . initializeApp ( config1 , appId1 ) ;
1138
+ auth1 = app1 . auth ( ) ;
1139
+
1140
+ assertNull ( auth1 . emulatorConfig ) ;
1141
+ }
1142
+
1143
+
1060
1144
function testGetSetTenantId ( ) {
1061
1145
app1 = firebase . initializeApp ( config1 , appId1 ) ;
1062
1146
auth1 = app1 . auth ( ) ;
@@ -2317,59 +2401,6 @@ function testAuth_authEventManager() {
2317
2401
}
2318
2402
2319
2403
2320
- function testAuth_authEventManager_withEmulator ( ) {
2321
- // Test Auth event manager.
2322
- fireauth . AuthEventManager . ENABLED = true ;
2323
- stubs . reset ( ) ;
2324
- initializeMockStorage ( ) ;
2325
- var expectedManager = {
2326
- 'subscribe' : goog . testing . recordFunction ( ) ,
2327
- 'unsubscribe' : goog . testing . recordFunction ( ) ,
2328
- 'clearRedirectResult' : goog . testing . recordFunction ( )
2329
- } ;
2330
- // Return stub manager.
2331
- stubs . replace (
2332
- fireauth . AuthEventManager ,
2333
- 'getManager' ,
2334
- function ( authDomain , apiKey , appName , emulatorConfig ) {
2335
- assertEquals ( 'subdomain.firebaseapp.com' , authDomain ) ;
2336
- assertEquals ( 'API_KEY' , apiKey ) ;
2337
- assertEquals ( appId1 , appName ) ;
2338
- assertObjectEquals ( emulatorConfig , {
2339
- url : 'http://emulator.test.domain:1234'
2340
- } ) ;
2341
- return expectedManager ;
2342
- } ) ;
2343
- asyncTestCase . waitForSignals ( 1 ) ;
2344
- app1 = firebase . initializeApp ( config3 , appId1 ) ;
2345
- auth1 = app1 . auth ( ) ;
2346
- auth1 . useEmulator ( 'http://emulator.test.domain:1234' ) ;
2347
- // Test manager initialized and Auth subscribed.
2348
- auth1 . onIdTokenChanged ( function ( user ) {
2349
- var manager = fireauth . AuthEventManager . getManager (
2350
- config3 [ 'authDomain' ] , config3 [ 'apiKey' ] , app1 . name , {
2351
- url : 'http://emulator.test.domain:1234' ,
2352
- } ) ;
2353
- assertEquals ( expectedManager , manager ) ;
2354
- assertEquals ( 0 , expectedManager . unsubscribe . getCallCount ( ) ) ;
2355
- assertEquals ( 1 , expectedManager . subscribe . getCallCount ( ) ) ;
2356
- assertEquals (
2357
- auth1 , expectedManager . subscribe . getLastCall ( ) . getArgument ( 0 ) ) ;
2358
- assertEquals ( 0 , expectedManager . clearRedirectResult . getCallCount ( ) ) ;
2359
- // Delete should trigger unsubscribe and redirect result clearing.
2360
- auth1 . delete ( ) ;
2361
- // After destroy, Auth should be unsubscribed.
2362
- assertEquals ( 1 , expectedManager . subscribe . getCallCount ( ) ) ;
2363
- assertEquals ( 1 , expectedManager . unsubscribe . getCallCount ( ) ) ;
2364
- // Redirect result should also be cleared.
2365
- assertEquals ( 1 , expectedManager . clearRedirectResult . getCallCount ( ) ) ;
2366
- assertEquals (
2367
- auth1 , expectedManager . unsubscribe . getLastCall ( ) . getArgument ( 0 ) ) ;
2368
- asyncTestCase . signal ( ) ;
2369
- } ) ;
2370
- }
2371
-
2372
-
2373
2404
/** Asserts that AuthEventManager can pass through emulator settings. */
2374
2405
function testAuth_authEventManager_withEmulator ( ) {
2375
2406
// Test Auth event manager.
@@ -2390,7 +2421,8 @@ function testAuth_authEventManager_withEmulator() {
2390
2421
assertEquals ( 'API_KEY' , apiKey ) ;
2391
2422
assertEquals ( appId1 , appName ) ;
2392
2423
assertObjectEquals ( emulatorConfig , {
2393
- url : 'http://emulator.host:1234'
2424
+ url : 'http://emulator.host:1234' ,
2425
+ disableWarnings : false ,
2394
2426
} ) ;
2395
2427
return expectedManager ;
2396
2428
} ) ;
@@ -2402,7 +2434,8 @@ function testAuth_authEventManager_withEmulator() {
2402
2434
auth1 . onIdTokenChanged ( function ( user ) {
2403
2435
var manager = fireauth . AuthEventManager . getManager (
2404
2436
config3 [ 'authDomain' ] , config3 [ 'apiKey' ] , app1 . name , {
2405
- url : 'http://emulator.host:1234'
2437
+ url : 'http://emulator.host:1234' ,
2438
+ disableWarnings : false ,
2406
2439
} ) ;
2407
2440
assertEquals ( expectedManager , manager ) ;
2408
2441
assertEquals ( 0 , expectedManager . unsubscribe . getCallCount ( ) ) ;
@@ -2667,7 +2700,8 @@ function testAuth_initState_signedInStatus_withEmulator() {
2667
2700
. getThis ( ) ) ;
2668
2701
assertObjectEquals (
2669
2702
{
2670
- url : 'http://emulator.test.domain:1234'
2703
+ url : 'http://emulator.test.domain:1234' ,
2704
+ disableWarnings : false ,
2671
2705
} ,
2672
2706
fireauth . RpcHandler . prototype . updateEmulatorConfig . getLastCall ( )
2673
2707
. getArgument ( 0 ) ) ;
@@ -4526,6 +4560,7 @@ function testAuth_signInWithIdTokenResponse_withEmulator() {
4526
4560
var expectedOptions = Object . assign ( { } , config3 ) ;
4527
4561
expectedOptions [ 'emulatorConfig' ] = {
4528
4562
url : 'http://emulator.test.domain:1234' ,
4563
+ disableWarnings : false ,
4529
4564
} ;
4530
4565
// The newly signed in user.
4531
4566
var user1 = new fireauth . AuthUser (
0 commit comments