@@ -153,48 +153,40 @@ describe('listCredentialGroupCredentials', () => {
153153 expect ( mocks . listCredentials ) . not . toHaveBeenCalled ( )
154154 } )
155155
156- it ( 'rejects workflows whose original principal has no human subject' , async ( ) => {
156+ it ( 'lists credentials when the original principal has no human subject' , async ( ) => {
157157 const principal = executorPrincipal ( )
158+ principal . subjectUserId = undefined
158159 principal . delegationContext . principal = {
159160 kind : 'workspace_api_key' ,
160161 workspaceId : 'workspace-1' ,
161162 keyId : 'workspace-key-1' ,
162163 }
163164
164- await expect (
165- listCredentialGroupCredentials . execute ( { principal, input } )
166- ) . rejects . toMatchObject ( {
167- code : 'forbidden' ,
168- message : 'Credential Group enrollment access required' ,
169- } )
165+ await listCredentialGroupCredentials . execute ( { principal, input } )
166+
170167 expect ( mocks . loadEnrollmentAccess ) . not . toHaveBeenCalled ( )
171- expect ( mocks . listCredentials ) . not . toHaveBeenCalled ( )
168+ expect ( mocks . listCredentials ) . toHaveBeenCalledWith (
169+ expect . not . objectContaining ( { credentialGroupEnrollmentId : expect . anything ( ) } )
170+ )
172171 } )
173172
174- it ( 'rejects a user who is not enrolled in the group ' , async ( ) => {
173+ it ( 'lists credentials without requiring the actor to be enrolled ' , async ( ) => {
175174 mocks . loadEnrollmentAccess . mockResolvedValueOnce ( null )
176175
177- await expect (
178- listCredentialGroupCredentials . execute ( { principal : executorPrincipal ( ) , input } )
179- ) . rejects . toMatchObject ( {
180- code : 'forbidden' ,
181- message : 'Credential Group enrollment access required' ,
182- } )
183- expect ( mocks . listCredentials ) . not . toHaveBeenCalled ( )
176+ await listCredentialGroupCredentials . execute ( { principal : executorPrincipal ( ) , input } )
177+
178+ expect ( mocks . loadEnrollmentAccess ) . not . toHaveBeenCalled ( )
179+ expect ( mocks . listCredentials ) . toHaveBeenCalled ( )
184180 } )
185181
186- it ( 'rejects an executor subject that does not match the original workflow principal ' , async ( ) => {
182+ it ( 'does not use the executor subject to filter credential references ' , async ( ) => {
187183 const principal = executorPrincipal ( )
188184 principal . subjectUserId = 'different-user'
189185
190- await expect (
191- listCredentialGroupCredentials . execute ( { principal, input } )
192- ) . rejects . toMatchObject ( {
193- code : 'forbidden' ,
194- message : 'Credential Group enrollment access required' ,
195- } )
186+ await listCredentialGroupCredentials . execute ( { principal, input } )
187+
196188 expect ( mocks . loadEnrollmentAccess ) . not . toHaveBeenCalled ( )
197- expect ( mocks . listCredentials ) . not . toHaveBeenCalled ( )
189+ expect ( mocks . listCredentials ) . toHaveBeenCalled ( )
198190 } )
199191
200192 it ( 'returns a bounded page after current workspace and entitlement checks' , async ( ) => {
@@ -211,7 +203,6 @@ describe('listCredentialGroupCredentials', () => {
211203 credentialGroupId : 'group-1' ,
212204 limit : 50 ,
213205 cursor : undefined ,
214- credentialGroupEnrollmentId : 'enrollment-1' ,
215206 credentialProviderIds : undefined ,
216207 credentialGroupOptionIds : [ 'option-1' ] ,
217208 } )
@@ -243,14 +234,14 @@ describe('listCredentialGroupCredentials', () => {
243234 )
244235 } )
245236
246- it ( 'ignores caller-supplied email and uses the principal enrollment ' , async ( ) => {
237+ it ( 'does not use caller-supplied identity fields to filter credential references ' , async ( ) => {
247238 await listCredentialGroupCredentials . execute ( {
248239 principal : executorPrincipal ( ) ,
249240 input : { ...input , email : ' Person@Example.COM ' } ,
250241 } )
251242
252243 expect ( mocks . listCredentials ) . toHaveBeenCalledWith (
253- expect . objectContaining ( { credentialGroupEnrollmentId : 'enrollment-1' } )
244+ expect . not . objectContaining ( { credentialGroupEnrollmentId : expect . anything ( ) } )
254245 )
255246 } )
256247
0 commit comments