@@ -52,11 +52,20 @@ describe('theme', () => {
5252 expect ( parse ( { } ) . data ?. capabilities ?. network_access ) . toBeUndefined ( )
5353 } )
5454
55- test ( 'ignores a boolean network_access, as before' , ( ) => {
56- const result = parse ( { network_access : true } )
55+ test . each ( [ true , false ] ) ( 'rejects a boolean network_access of %s' , ( networkAccess ) => {
56+ const result = parse ( { network_access : networkAccess } )
57+
58+ expect ( result . state ) . toBe ( 'error' )
59+ expect ( errorMessages ( result ) ) . toEqual ( [
60+ 'network_access must be a table with an allowed_sources list for theme app extensions' ,
61+ ] )
62+ } )
63+
64+ test ( 'ignores capabilities that do not apply to theme extensions' , ( ) => {
65+ const result = parse ( { network_access : { allowed_sources : [ ] } , api_access : true , block_progress : true } )
5766
5867 expect ( result . state ) . toBe ( 'ok' )
59- expect ( result . data ?. capabilities ?. network_access ) . toBeUndefined ( )
68+ expect ( result . data ?. capabilities ) . toEqual ( { network_access : { allowed_sources : [ ] } } )
6069 } )
6170
6271 test ( 'requires allowed_sources when the network_access table is declared' , ( ) => {
@@ -77,7 +86,7 @@ describe('theme', () => {
7786 ] )
7887 } )
7988
80- test ( 'rejects a network_access value that is neither a table nor a boolean ' , ( ) => {
89+ test ( 'rejects a network_access value that is not a table' , ( ) => {
8190 const result = parse ( { network_access : 'https://api.example.com' } )
8291
8392 expect ( result . state ) . toBe ( 'error' )
@@ -99,6 +108,13 @@ describe('theme', () => {
99108 [ 'a wildcard that is not the leading label' , 'https://api.*.example.com' ] ,
100109 [ 'a single-label host' , 'https://localhost' ] ,
101110 [ 'an IP address' , 'https://127.0.0.1' ] ,
111+ [ 'an IP address with a hexadecimal final label' , 'https://127.0.0x1' ] ,
112+ [ 'an IP address in hexadecimal notation' , 'https://0x7f.0x1' ] ,
113+ [ 'a link-local IP address in hexadecimal notation' , 'https://0xa9.0xfe.0xa9.0xfe' ] ,
114+ [ 'a wildcard on an IP address' , 'https://*.127.0.0.1' ] ,
115+ [ 'a wildcard on an IP address in hexadecimal notation' , 'https://*.0x7f.0x1' ] ,
116+ [ 'a host that cannot be parsed as a URL' , 'https://example.0xabc' ] ,
117+ [ 'a wildcard on a host that cannot be parsed as a URL' , 'https://*.example.0xabc' ] ,
102118 [ 'an invalid label' , 'https://-api.example.com' ] ,
103119 [ 'an empty label' , 'https://api..example.com' ] ,
104120 [ 'a trailing dot' , 'https://api.example.com./' ] ,
@@ -149,8 +165,8 @@ describe('theme', () => {
149165 await expect ( themeSpec . deployConfig ?.( config , '' , '' , undefined ) ) . resolves . toEqual ( { theme_extension : { files : { } } } )
150166 } )
151167
152- test ( 'sends only the theme extension files when network_access is a boolean ' , async ( ) => {
153- const config = parse ( { network_access : true , block_progress : true } ) . data !
168+ test ( 'sends only the theme extension files when other capabilities are declared ' , async ( ) => {
169+ const config = parse ( { api_access : true , block_progress : true } ) . data !
154170
155171 await expect ( themeSpec . deployConfig ?.( config , '' , '' , undefined ) ) . resolves . toEqual ( { theme_extension : { files : { } } } )
156172 } )
@@ -175,16 +191,16 @@ describe('theme', () => {
175191 } )
176192
177193 describe ( 'UI extensions' , ( ) => {
178- test ( 'still accept a boolean network_access' , ( ) => {
194+ test . each ( [ true , false ] ) ( 'still accept a boolean network_access of %s ' , ( networkAccess ) => {
179195 const result = UIExtensionSchema . safeParse ( {
180196 name : 'ui extension' ,
181197 type : 'ui_extension' ,
182198 extension_points : [ ] ,
183- capabilities : { network_access : true } ,
199+ capabilities : { network_access : networkAccess } ,
184200 } )
185201
186202 expect ( result . success ) . toBe ( true )
187- expect ( result . data ?. capabilities ?. network_access ) . toBe ( true )
203+ expect ( result . data ?. capabilities ?. network_access ) . toBe ( networkAccess )
188204 } )
189205
190206 test ( 'reject a network_access table' , ( ) => {
0 commit comments