@@ -1652,7 +1652,8 @@ describe('apple signin auth adapter', () => {
16521652
16531653describe ( 'Apple Game Center Auth adapter' , ( ) => {
16541654 const gcenter = require ( '../lib/Adapters/Auth/gcenter' ) ;
1655-
1655+ const fs = require ( 'fs' ) ;
1656+ const testCert = fs . readFileSync ( __dirname + '/support/cert/game_center.pem' ) ;
16561657 it ( 'validateAuthData should validate' , async ( ) => {
16571658 // real token is used
16581659 const authData = {
@@ -1664,30 +1665,22 @@ describe('Apple Game Center Auth adapter', () => {
16641665 salt : 'DzqqrQ==' ,
16651666 bundleId : 'cloud.xtralife.gamecenterauth' ,
16661667 } ;
1667-
1668- try {
1669- await gcenter . validateAuthData ( authData ) ;
1670- } catch ( e ) {
1671- fail ( ) ;
1672- }
1668+ gcenter . cache [ 'https://static.gc.apple.com/public-key/gc-prod-4.cer' ] = testCert ;
1669+ await gcenter . validateAuthData ( authData ) ;
16731670 } ) ;
16741671
16751672 it ( 'validateAuthData invalid signature id' , async ( ) => {
16761673 const authData = {
16771674 id : 'G:1965586982' ,
1678- publicKeyUrl : 'https://static.gc.apple.com/public-key/gc-prod-4 .cer' ,
1675+ publicKeyUrl : 'https://static.gc.apple.com/public-key/gc-prod-6 .cer' ,
16791676 timestamp : 1565257031287 ,
16801677 signature : '1234' ,
16811678 salt : 'DzqqrQ==' ,
1682- bundleId : 'cloud.xtralife.gamecenterauth ' ,
1679+ bundleId : 'com.example.com ' ,
16831680 } ;
1684-
1685- try {
1686- await gcenter . validateAuthData ( authData ) ;
1687- fail ( ) ;
1688- } catch ( e ) {
1689- expect ( e . message ) . toBe ( 'Apple Game Center - invalid signature' ) ;
1690- }
1681+ await expectAsync ( gcenter . validateAuthData ( authData ) ) . toBeRejectedWith (
1682+ new Parse . Error ( Parse . Error . SCRIPT_FAILED , 'Apple Game Center - invalid signature' )
1683+ ) ;
16911684 } ) ;
16921685
16931686 it ( 'validateAuthData invalid public key url' , async ( ) => {
0 commit comments