@@ -1665,11 +1665,7 @@ describe('Apple Game Center Auth adapter', () => {
16651665 bundleId : 'cloud.xtralife.gamecenterauth' ,
16661666 } ;
16671667
1668- try {
1669- await gcenter . validateAuthData ( authData ) ;
1670- } catch ( e ) {
1671- fail ( ) ;
1672- }
1668+ await gcenter . validateAuthData ( authData ) ;
16731669 } ) ;
16741670
16751671 it ( 'validateAuthData invalid signature id' , async ( ) => {
@@ -1690,42 +1686,33 @@ describe('Apple Game Center Auth adapter', () => {
16901686 }
16911687 } ) ;
16921688
1693- it ( 'validateAuthData invalid public key url' , async ( ) => {
1694- const authData = {
1695- id : 'G:1965586982' ,
1696- publicKeyUrl : 'invalid.com' ,
1697- timestamp : 1565257031287 ,
1698- signature : '1234' ,
1699- salt : 'DzqqrQ==' ,
1700- bundleId : 'cloud.xtralife.gamecenterauth' ,
1701- } ;
1702-
1703- try {
1704- await gcenter . validateAuthData ( authData ) ;
1705- fail ( ) ;
1706- } catch ( e ) {
1707- expect ( e . message ) . toBe ( 'Apple Game Center - invalid publicKeyUrl: invalid.com' ) ;
1708- }
1709- } ) ;
1710-
17111689 it ( 'validateAuthData invalid public key http url' , async ( ) => {
1712- const authData = {
1713- id : 'G:1965586982' ,
1714- publicKeyUrl : 'http://static.gc.apple.com/public-key/gc-prod-4.cer' ,
1715- timestamp : 1565257031287 ,
1716- signature : '1234' ,
1717- salt : 'DzqqrQ==' ,
1718- bundleId : 'cloud.xtralife.gamecenterauth' ,
1719- } ;
1720-
1721- try {
1722- await gcenter . validateAuthData ( authData ) ;
1723- fail ( ) ;
1724- } catch ( e ) {
1725- expect ( e . message ) . toBe (
1726- 'Apple Game Center - invalid publicKeyUrl: http://static.gc.apple.com/public-key/gc-prod-4.cer'
1727- ) ;
1728- }
1690+ const publicKeyUrls = [
1691+ 'example.com' ,
1692+ 'http://static.gc.apple.com/public-key/gc-prod-4.cer' ,
1693+ 'https://developer.apple.com/assets/elements/badges/download-on-the-app-store.svg' ,
1694+ 'https://example.com/ \\.apple.com/public_key.cer' ,
1695+ 'https://example.com/ &.apple.com/public_key.cer' ,
1696+ ] ;
1697+ await Promise . all (
1698+ publicKeyUrls . map ( publicKeyUrl =>
1699+ expectAsync (
1700+ gcenter . validateAuthData ( {
1701+ id : 'G:1965586982' ,
1702+ timestamp : 1565257031287 ,
1703+ publicKeyUrl,
1704+ signature : '1234' ,
1705+ salt : 'DzqqrQ==' ,
1706+ bundleId : 'com.example.com' ,
1707+ } )
1708+ ) . toBeRejectedWith (
1709+ new Parse . Error (
1710+ Parse . Error . SCRIPT_FAILED ,
1711+ `Apple Game Center - invalid publicKeyUrl: ${ publicKeyUrl } `
1712+ )
1713+ )
1714+ )
1715+ ) ;
17291716 } ) ;
17301717} ) ;
17311718
0 commit comments