@@ -1749,7 +1749,7 @@ describe('ParseUser', () => {
1749
1749
} ) ;
1750
1750
} ) ;
1751
1751
1752
- fit ( 'can encrypt user' , async ( ) => {
1752
+ it ( 'can encrypt user' , async ( ) => {
1753
1753
CoreManager . set ( 'ENCRYPTED_KEY' , 'hello' ) ;
1754
1754
1755
1755
ParseUser . enableUnsafeCurrentUser ( ) ;
@@ -1804,7 +1804,7 @@ describe('ParseUser', () => {
1804
1804
it ( 'can encrypt user with custom CryptoController' , async ( ) => {
1805
1805
CoreManager . set ( 'ENCRYPTED_KEY' , 'hello' ) ;
1806
1806
const ENCRYPTED_DATA = 'encryptedString' ;
1807
-
1807
+ const CryptoController = CoreManager . getCryptoController ( ) ;
1808
1808
ParseUser . enableUnsafeCurrentUser ( ) ;
1809
1809
ParseUser . _clearCache ( ) ;
1810
1810
Storage . _clear ( ) ;
@@ -1828,6 +1828,7 @@ describe('ParseUser', () => {
1828
1828
ajax ( ) { } ,
1829
1829
} ) ;
1830
1830
const CustomCrypto = {
1831
+ async : 0 ,
1831
1832
encrypt ( _obj , secretKey ) {
1832
1833
expect ( secretKey ) . toBe ( 'hello' ) ;
1833
1834
return ENCRYPTED_DATA ;
@@ -1843,20 +1844,32 @@ describe('ParseUser', () => {
1843
1844
// Clear cache to read from disk
1844
1845
ParseUser . _clearCache ( ) ;
1845
1846
1846
- const isCurrent = await u . isCurrentAsync ( ) ;
1847
1847
expect ( u . id ) . toBe ( 'uid2' ) ;
1848
1848
expect ( u . getSessionToken ( ) ) . toBe ( '123abc' ) ;
1849
- expect ( isCurrent ) . toBe ( true ) ;
1849
+ expect ( u . isCurrent ( ) ) . toBe ( true ) ;
1850
1850
expect ( u . authenticated ( ) ) . toBe ( true ) ;
1851
1851
expect ( ParseUser . current ( ) . id ) . toBe ( 'uid2' ) ;
1852
1852
1853
1853
const path = Storage . generatePath ( 'currentUser' ) ;
1854
1854
const userStorage = Storage . getItem ( path ) ;
1855
1855
expect ( userStorage ) . toBe ( ENCRYPTED_DATA ) ;
1856
1856
CoreManager . set ( 'ENCRYPTED_KEY' , null ) ;
1857
+ CoreManager . setCryptoController ( CryptoController ) ;
1857
1858
Storage . _clear ( ) ;
1858
1859
} ) ;
1859
1860
1861
+ it ( 'cannot get synchronous current user with encryption enabled' , async ( ) => {
1862
+ CoreManager . set ( 'ENCRYPTED_KEY' , 'hello' ) ;
1863
+ ParseUser . enableUnsafeCurrentUser ( ) ;
1864
+ ParseUser . _clearCache ( ) ;
1865
+ expect ( ( ) => {
1866
+ ParseUser . current ( ) ;
1867
+ } ) . toThrow (
1868
+ 'Cannot call currentUser() when using a platform with an async encrypted storage system. Call currentUserAsync() instead.'
1869
+ ) ;
1870
+ CoreManager . set ( 'ENCRYPTED_KEY' , null ) ;
1871
+ } ) ;
1872
+
1860
1873
it ( 'can static signup a user with installationId' , async ( ) => {
1861
1874
ParseUser . disableUnsafeCurrentUser ( ) ;
1862
1875
ParseUser . _clearCache ( ) ;
0 commit comments