@@ -59,7 +59,7 @@ function initializeContext(testDir) {
59
59
return ctx ;
60
60
}
61
61
62
- describe ( 'updateConfiguration .js' , function ( ) {
62
+ describe ( 'updateConfigurationBeforePrepare .js' , function ( ) {
63
63
beforeEach ( function ( ) {
64
64
tu . copyRecursiveSync ( assetsDirectory , workingDirectory ) ;
65
65
} ) ;
@@ -104,7 +104,7 @@ describe('updateConfiguration.js', function (){
104
104
} ) ;
105
105
106
106
it ( 'Should not update name if it is missing in manifest.json' , function ( done ) {
107
- var testDir = path . join ( workingDirectory , 'jsonEmpty ' ) ;
107
+ var testDir = path . join ( workingDirectory , 'jsonPropertiesMissing ' ) ;
108
108
var configXML = path . join ( testDir , 'config.xml' ) ;
109
109
var ctx = initializeContext ( testDir ) ;
110
110
@@ -146,7 +146,7 @@ describe('updateConfiguration.js', function (){
146
146
} ) ;
147
147
148
148
it ( 'Should not update orientation if it is missing in manifest.json' , function ( done ) {
149
- var testDir = path . join ( workingDirectory , 'jsonEmpty ' ) ;
149
+ var testDir = path . join ( workingDirectory , 'jsonPropertiesMissing ' ) ;
150
150
var configXML = path . join ( testDir , 'config.xml' ) ;
151
151
var ctx = initializeContext ( testDir ) ;
152
152
@@ -187,7 +187,7 @@ describe('updateConfiguration.js', function (){
187
187
} ) ;
188
188
189
189
it ( 'Should not update fullscreen if it is missing in manifest.json' , function ( done ) {
190
- var testDir = path . join ( workingDirectory , 'jsonEmpty ' ) ;
190
+ var testDir = path . join ( workingDirectory , 'jsonPropertiesMissing ' ) ;
191
191
var configXML = path . join ( testDir , 'config.xml' ) ;
192
192
var ctx = initializeContext ( testDir ) ;
193
193
@@ -214,7 +214,7 @@ describe('updateConfiguration.js', function (){
214
214
} ) ;
215
215
216
216
it ( 'Should keep existing access rules unchanged in config.xml' , function ( done ) {
217
- var testDir = path . join ( workingDirectory , 'jsonEmpty ' ) ;
217
+ var testDir = path . join ( workingDirectory , 'jsonPropertiesMissing ' ) ;
218
218
var configXML = path . join ( testDir , 'config.xml' ) ;
219
219
var ctx = initializeContext ( testDir ) ;
220
220
@@ -267,7 +267,7 @@ describe('updateConfiguration.js', function (){
267
267
} ) ;
268
268
} ) ;
269
269
270
- it ( 'Should add access rules for scope in config.xml' , function ( done ) {
270
+ it ( 'Should add access rules for scope in config.xml if scope is a relative URL ' , function ( done ) {
271
271
var testDir = path . join ( workingDirectory , 'xmlEmptyWidget' ) ;
272
272
var configXML = path . join ( testDir , 'config.xml' ) ;
273
273
var ctx = initializeContext ( testDir ) ;
@@ -286,6 +286,44 @@ describe('updateConfiguration.js', function (){
286
286
} ) ;
287
287
} ) ;
288
288
289
+ it ( 'Should add access rules for scope in config.xml if scope is a full URL' , function ( done ) {
290
+ var testDir = path . join ( workingDirectory , 'fullUrlForScope' ) ;
291
+ var configXML = path . join ( testDir , 'config.xml' ) ;
292
+ var ctx = initializeContext ( testDir ) ;
293
+
294
+ updateConfiguration ( ctx ) . then ( function ( ) {
295
+ var content = fs . readFileSync ( configXML ) . toString ( ) ;
296
+
297
+ // rules for android
298
+ assert ( content . match ( / < p l a t f o r m n a m e = " a n d r o i d " > [ \s \S ] * < a c c e s s h a p - r u l e = " y e s " o r i g i n = " h t t p : \/ \/ w w w .d o m a i n .c o m \/ \* " \/ > [ \s \S ] * < \/ p l a t f o r m > / ) ) ;
299
+ assert ( content . match ( / < p l a t f o r m n a m e = " a n d r o i d " > [ \s \S ] * < a l l o w - n a v i g a t i o n h a p - r u l e = " y e s " h r e f = " h t t p : \/ \/ w w w .d o m a i n .c o m \/ \* " \/ > [ \s \S ] * < \/ p l a t f o r m > / ) ) ;
300
+
301
+ // rules for ios
302
+ assert ( content . match ( / < p l a t f o r m n a m e = " i o s " > [ \s \S ] * < a c c e s s h a p - r u l e = " y e s " o r i g i n = " h t t p : \/ \/ w w w .d o m a i n .c o m \/ \* " \/ > [ \s \S ] * < \/ p l a t f o r m > / ) ) ;
303
+
304
+ done ( ) ;
305
+ } ) ;
306
+ } ) ;
307
+
308
+ it ( 'Should add access rules for scope in config.xml if scope is a full URL with wildcard as subdomain' , function ( done ) {
309
+ var testDir = path . join ( workingDirectory , 'wildcardSubdomainForScope' ) ;
310
+ var configXML = path . join ( testDir , 'config.xml' ) ;
311
+ var ctx = initializeContext ( testDir ) ;
312
+
313
+ updateConfiguration ( ctx ) . then ( function ( ) {
314
+ var content = fs . readFileSync ( configXML ) . toString ( ) ;
315
+
316
+ // rules for android
317
+ assert ( content . match ( / < p l a t f o r m n a m e = " a n d r o i d " > [ \s \S ] * < a c c e s s h a p - r u l e = " y e s " o r i g i n = " h t t p : \/ \/ \* .d o m a i n .c o m " \/ > [ \s \S ] * < \/ p l a t f o r m > / ) ) ;
318
+ assert ( content . match ( / < p l a t f o r m n a m e = " a n d r o i d " > [ \s \S ] * < a l l o w - n a v i g a t i o n h a p - r u l e = " y e s " h r e f = " h t t p : \/ \/ \* .d o m a i n .c o m " \/ > [ \s \S ] * < \/ p l a t f o r m > / ) ) ;
319
+
320
+ // rules for ios
321
+ assert ( content . match ( / < p l a t f o r m n a m e = " i o s " > [ \s \S ] * < a c c e s s h a p - r u l e = " y e s " o r i g i n = " h t t p : \/ \/ \* .d o m a i n .c o m " \/ > [ \s \S ] * < \/ p l a t f o r m > / ) ) ;
322
+
323
+ done ( ) ;
324
+ } ) ;
325
+ } ) ;
326
+
289
327
it ( 'Should add access rules from mjs_access_whitelist list' , function ( done ) {
290
328
var testDir = path . join ( workingDirectory , 'xmlEmptyWidget' ) ;
291
329
var configXML = path . join ( testDir , 'config.xml' ) ;
0 commit comments