@@ -1339,16 +1339,25 @@ function testStartSignInWithEmailAndPassword_success() {
13391339 app . getAuth ( ) . install ( ) ;
13401340 app . getExternalAuth ( ) . install ( ) ;
13411341 asyncTestCase . waitForSignals ( 1 ) ;
1342+ var expectedUserCredential = {
1343+ 'user' : expectedUser ,
1344+ 'credential' : null ,
1345+ 'operationType' : 'signIn' ,
1346+ 'additionalUserInfo' : { 'providerId' : 'password' , 'isNewUser' : false }
1347+ } ;
13421348 app . startSignInWithEmailAndPassword ( '[email protected] ' , 'password' ) 1343- . then ( function ( user ) {
1344- assertEquals ( app . getAuth ( ) . currentUser , user ) ;
1349+ . then ( function ( userCredential ) {
1350+ assertObjectEquals ( expectedUserCredential , userCredential ) ;
13451351 asyncTestCase . signal ( ) ;
13461352 } ) ;
1347- app . getAuth ( ) . assertSignInWithEmailAndPassword (
1353+ app . getAuth ( ) . assertSignInAndRetrieveDataWithEmailAndPassword (
13481354 [ '[email protected] ' , 'password' ] , 13491355 function ( ) {
13501356 app . getAuth ( ) . setUser ( expectedUser ) ;
1351- return app . getAuth ( ) . currentUser ;
1357+ // Make a copy of expected UserCredential to ensure
1358+ // expectedUserCredential which is used to be compared with later will
1359+ // not be modified.
1360+ return goog . object . clone ( expectedUserCredential ) ;
13521361 } ) ;
13531362 app . getAuth ( ) . process ( ) ;
13541363 app . getExternalAuth ( ) . process ( ) ;
@@ -1371,7 +1380,7 @@ function testStartSignInWithEmailAndPassword_error() {
13711380 assertEquals ( expectedError , error ) ;
13721381 asyncTestCase . signal ( ) ;
13731382 } ) ;
1374- app . getAuth ( ) . assertSignInWithEmailAndPassword (
1383+ app . getAuth ( ) . assertSignInAndRetrieveDataWithEmailAndPassword (
13751384 [ '[email protected] ' , 'password' ] , 13761385 null ,
13771386 expectedError ) ;
@@ -1418,11 +1427,16 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_isAnonymous_success() {
14181427 } ) ;
14191428 // Simulate anonymous user logged in on external instance.
14201429 testAuth . setUser ( anonymousUser ) ;
1421- app . getAuth ( ) . assertSignInWithEmailAndPassword (
1430+ app . getAuth ( ) . assertSignInAndRetrieveDataWithEmailAndPassword (
14221431 [ '[email protected] ' , 'password' ] , 14231432 function ( ) {
14241433 app . getAuth ( ) . setUser ( expectedUser ) ;
1425- return app . getAuth ( ) . currentUser ;
1434+ return {
1435+ 'user' : expectedUser ,
1436+ 'credential' : null ,
1437+ 'operationType' : 'signIn' ,
1438+ 'additionalUserInfo' : { 'providerId' : 'password' , 'isNewUser' : false }
1439+ } ;
14261440 } ) ;
14271441 app . getAuth ( ) . process ( ) . then ( function ( ) {
14281442 // Trigger initial onAuthStateChanged listener.
@@ -1466,7 +1480,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_isAnon_error() {
14661480 asyncTestCase . signal ( ) ;
14671481 } ) ;
14681482 // Simulate wrong password error on sign-in.
1469- app . getAuth ( ) . assertSignInWithEmailAndPassword (
1483+ app . getAuth ( ) . assertSignInAndRetrieveDataWithEmailAndPassword (
14701484 [ '[email protected] ' , 'password' ] , 14711485 null ,
14721486 expectedError ) ;
@@ -1486,16 +1500,25 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_nonAnon_success() {
14861500 asyncTestCase . waitForSignals ( 1 ) ;
14871501 // Simulate non-anonymous user logged in on external instance.
14881502 testAuth . setUser ( expectedUser ) ;
1503+ var expectedUserCredential = {
1504+ 'user' : expectedUser ,
1505+ 'credential' : null ,
1506+ 'operationType' : 'signIn' ,
1507+ 'additionalUserInfo' : { 'providerId' : 'password' , 'isNewUser' : false }
1508+ } ;
14891509 app . startSignInWithEmailAndPassword ( '[email protected] ' , 'password' ) 1490- . then ( function ( user ) {
1491- assertEquals ( app . getAuth ( ) . currentUser , user ) ;
1510+ . then ( function ( userCredential ) {
1511+ assertObjectEquals ( expectedUserCredential , userCredential ) ;
14921512 asyncTestCase . signal ( ) ;
14931513 } ) ;
1494- app . getAuth ( ) . assertSignInWithEmailAndPassword (
1514+ app . getAuth ( ) . assertSignInAndRetrieveDataWithEmailAndPassword (
14951515 [ '[email protected] ' , 'password' ] , 14961516 function ( ) {
14971517 app . getAuth ( ) . setUser ( expectedUser ) ;
1498- return app . getAuth ( ) . currentUser ;
1518+ // Make a copy of expected UserCredential to ensure
1519+ // expectedUserCredential which is used to be compared with later will
1520+ // not be modified.
1521+ return goog . object . clone ( expectedUserCredential ) ;
14991522 } ) ;
15001523 app . getAuth ( ) . process ( ) . then ( function ( ) {
15011524 // Trigger initial onAuthStateChanged listener.
@@ -1517,16 +1540,25 @@ function testStartSignInWithEmailAndPassword_upgradeAnonymous_noUser_success() {
15171540 asyncTestCase . waitForSignals ( 1 ) ;
15181541 // Simulate no user logged in on external instance.
15191542 testAuth . setUser ( null ) ;
1543+ var expectedUserCredential = {
1544+ 'user' : expectedUser ,
1545+ 'credential' : null ,
1546+ 'operationType' : 'signIn' ,
1547+ 'additionalUserInfo' : { 'providerId' : 'password' , 'isNewUser' : false }
1548+ } ;
15201549 app . startSignInWithEmailAndPassword ( '[email protected] ' , 'password' ) 1521- . then ( function ( user ) {
1522- assertEquals ( app . getAuth ( ) . currentUser , user ) ;
1550+ . then ( function ( userCredential ) {
1551+ assertObjectEquals ( expectedUserCredential , userCredential ) ;
15231552 asyncTestCase . signal ( ) ;
15241553 } ) ;
1525- app . getAuth ( ) . assertSignInWithEmailAndPassword (
1554+ app . getAuth ( ) . assertSignInAndRetrieveDataWithEmailAndPassword (
15261555 [ '[email protected] ' , 'password' ] , 15271556 function ( ) {
15281557 app . getAuth ( ) . setUser ( expectedUser ) ;
1529- return app . getAuth ( ) . currentUser ;
1558+ // Make a copy of expected UserCredential to ensure
1559+ // expectedUserCredential which is used to be compared with later will
1560+ // not be modified.
1561+ return goog . object . clone ( expectedUserCredential ) ;
15301562 } ) ;
15311563 app . getAuth ( ) . process ( ) . then ( function ( ) {
15321564 // Trigger initial onAuthStateChanged listener.
@@ -3768,17 +3800,26 @@ function testSignInWithExistingEmailAndPasswordForLinking_success() {
37683800 app . getAuth ( ) . install ( ) ;
37693801 app . getExternalAuth ( ) . install ( ) ;
37703802 asyncTestCase . waitForSignals ( 1 ) ;
3803+ var expectedUserCredential = {
3804+ 'user' : expectedUser ,
3805+ 'credential' : null ,
3806+ 'operationType' : 'signIn' ,
3807+ 'additionalUserInfo' : { 'providerId' : 'password' , 'isNewUser' : false }
3808+ } ;
37713809 app . signInWithExistingEmailAndPasswordForLinking (
377238103773- . then ( function ( user ) {
3774- assertEquals ( app . getAuth ( ) . currentUser , user ) ;
3811+ . then ( function ( userCredential ) {
3812+ assertObjectEquals ( expectedUserCredential , userCredential ) ;
37753813 asyncTestCase . signal ( ) ;
37763814 } ) ;
3777- app . getAuth ( ) . assertSignInWithEmailAndPassword (
3815+ app . getAuth ( ) . assertSignInAndRetrieveDataWithEmailAndPassword (
37783816 [ '[email protected] ' , 'password' ] , 37793817 function ( ) {
37803818 app . getAuth ( ) . setUser ( expectedUser ) ;
3781- return app . getAuth ( ) . currentUser ;
3819+ // Make a copy of expected UserCredential to ensure
3820+ // expectedUserCredential which is used to be compared with later will
3821+ // not be modified.
3822+ return goog . object . clone ( expectedUserCredential ) ;
37823823 } ) ;
37833824 app . getAuth ( ) . process ( ) ;
37843825 app . getExternalAuth ( ) . process ( ) ;
@@ -3802,7 +3843,7 @@ function testSignInWithExistingEmailAndPasswordForLinking_error() {
38023843 assertEquals ( expectedError , error ) ;
38033844 asyncTestCase . signal ( ) ;
38043845 } ) ;
3805- app . getAuth ( ) . assertSignInWithEmailAndPassword (
3846+ app . getAuth ( ) . assertSignInAndRetrieveDataWithEmailAndPassword (
38063847 [ '[email protected] ' , 'password' ] , 38073848 null ,
38083849 expectedError ) ;
0 commit comments