@@ -67,7 +67,10 @@ const SYS_ONLY_SET = { name: 'sys_only', label: 'Sys Only', objects: { sys_user:
6767/** A set `crm` ships that grants on a platform object only: its package is the one thing out of an island's reach. */
6868const CRM_SYS_SET = { name : 'crm_user_reader' , label : 'CRM User Reader' , objects : { sys_user : { allowRead : true } } , _packageId : 'crm' } ;
6969
70- const CATALOG : TestSecurityCatalog = { permissions : [ PACKAGED , ENV_SET , OWNED_SET , SYS_ONLY_SET , CRM_SYS_SET ] } ;
70+ /** [#29594] A set the platform's kernel ships (scope `system`): the commonest lock-and-clone source. */
71+ const KERNEL = 'com.objectstack.plugin-security' ;
72+ const KERNEL_SET = { name : 'member_default' , label : 'Member' , objects : { account : { allowRead : true } } , _packageId : KERNEL , _lock : 'full' } ;
73+ const CATALOG : TestSecurityCatalog = { permissions : [ PACKAGED , ENV_SET , OWNED_SET , SYS_ONLY_SET , CRM_SYS_SET , KERNEL_SET ] } ;
7174
7275/**
7376 * The package registry the door reads: `crm` is a booted CODE package
@@ -82,6 +85,7 @@ const PACKAGES: Record<string, { manifest: Record<string, unknown> }> = {
8285 'com.acme.ext' : { manifest : { id : 'com.acme.ext' , dependencies : { crm : '^1' } } } ,
8386 'com.acme.island' : { manifest : { id : 'com.acme.island' } } ,
8487 'com.vendor.app' : { manifest : { id : 'com.vendor.app' , scope : 'cloud' } } ,
88+ [ KERNEL ] : { manifest : { id : KERNEL , namespace : 'sys' , version : '18.3.0' , scope : 'system' } } ,
8589} ;
8690
8791interface Saved { type : string ; name : string ; item : Record < string , unknown > ; parentVersion ?: string | null ; packageId ?: string ; inheritedGrantObjects ?: readonly string [ ] }
@@ -238,6 +242,22 @@ describe('the permission-set clone door — success', () => {
238242 expect ( ( res as any ) . response . body . data . notice ) . toBe ( permissionSetCloneNotice ( { packageId : null , created : false } ) ) ;
239243 } ) ;
240244
245+ it ( '[#29594] a set a kernel package ships copies environment-wide, with no ensure: the kernel has no pair' , async ( ) => {
246+ const h = boot ( ) ;
247+
248+ const res = await clone ( h , HOLDER ( ) , KERNEL_SET . name , { name : 'my_member' , label : 'My Member' } ) ;
249+
250+ expect ( statusOf ( res ) ) . toBe ( 200 ) ;
251+ expect ( h . ensures ) . toEqual ( [ ] ) ;
252+ expect ( h . saves [ 0 ] ) . not . toHaveProperty ( 'packageId' ) ;
253+ expect ( h . saves [ 0 ] . item ) . toEqual ( { name : 'my_member' , label : 'My Member' , objects : KERNEL_SET . objects } ) ;
254+ const data = ( res as any ) . response . body . data ;
255+ expect ( data . package ) . toBeNull ( ) ;
256+ expect ( data . noticeCode ) . toBe ( 'PERMISSION_SET_CLONE_ENVIRONMENT_WIDE_KERNEL_SOURCE' ) ;
257+ expect ( data . notice ) . toBe ( permissionSetCloneNotice ( { packageId : null , created : false , kernelSource : KERNEL } ) ) ;
258+ expect ( data . notice ) . toContain ( `kernel package '${ KERNEL } '` ) ;
259+ } ) ;
260+
241261 it ( 'a set already in a writable package copies into that package, with no ensure' , async ( ) => {
242262 const h = boot ( ) ;
243263
@@ -331,7 +351,7 @@ describe('the permission-set clone door — authority', () => {
331351} ) ;
332352
333353describe ( '[#29727] the clone notice is named by one stable code per landing' , ( ) => {
334- // CONTROL: the three sentences, spelled out as they were served before the
354+ // CONTROL: the sentences (the fourth since #29594) , spelled out as they were served before the
335355 // codes arrived, so a change to `notice` while adding a code reds here.
336356 const TAIL =
337357 'The copy is a new permission set authored in this system, with no link to the set it was copied '
@@ -344,6 +364,13 @@ describe('[#29727] the clone notice is named by one stable code per landing', ()
344364 code : 'PERMISSION_SET_CLONE_ENVIRONMENT_WIDE' ,
345365 notice : 'The copy was saved environment-wide, in no package, as the set it was copied from is. ' + TAIL ,
346366 } ,
367+ {
368+ landing : { packageId : null , created : false , kernelSource : 'com.objectstack.plugin-security' } ,
369+ code : 'PERMISSION_SET_CLONE_ENVIRONMENT_WIDE_KERNEL_SOURCE' ,
370+ notice : "The copy was saved environment-wide, in no package: the set it was copied from is shipped by kernel "
371+ + "package 'com.objectstack.plugin-security', which has no paired customization package in this version. "
372+ + 'Name a writable package with `package` to keep the copy in it instead. ' + TAIL ,
373+ } ,
347374 {
348375 landing : { packageId : 'com.acme.base' , created : false } ,
349376 code : 'PERMISSION_SET_CLONE_IN_PACKAGE' ,
@@ -363,9 +390,9 @@ describe('[#29727] the clone notice is named by one stable code per landing', ()
363390 expect ( permissionSetCloneNotice ( landing ) ) . toBe ( notice ) ;
364391 } ) ;
365392
366- it ( 'the three codes are distinct and the table holds exactly them' , ( ) => {
393+ it ( 'the four codes are distinct and the table holds exactly them' , ( ) => {
367394 expect ( Object . values ( PERMISSION_SET_CLONE_NOTICE_CODES ) . sort ( ) ) . toEqual ( VARIANTS . map ( ( v ) => v . code ) . sort ( ) ) ;
368- expect ( new Set ( VARIANTS . map ( ( v ) => permissionSetCloneNotice ( v . landing ) ) ) . size ) . toBe ( 3 ) ;
395+ expect ( new Set ( VARIANTS . map ( ( v ) => permissionSetCloneNotice ( v . landing ) ) ) . size ) . toBe ( 4 ) ;
369396 } ) ;
370397} ) ;
371398
0 commit comments