@@ -345,4 +345,68 @@ describe('POST /api/credentials', () => {
345345 expect ( dbChainMockFns . insert ) . not . toHaveBeenCalled ( )
346346 } )
347347 } )
348+
349+ it ( 'forwards OCI API-key fields without returning secret material' , async ( ) => {
350+ mockVerifyAndBuildServiceAccountSecret . mockResolvedValueOnce ( {
351+ providerId : 'oci-api-key-service-account' ,
352+ encryptedServiceAccountKey : 'encrypted-oci-blob' ,
353+ displayName : 'ocid1.user.oc1..principal' ,
354+ auditMetadata : {
355+ principalKind : 'user' ,
356+ principalId : 'ocid1.user.oc1..principal' ,
357+ } ,
358+ principal : { kind : 'user' , id : 'ocid1.user.oc1..principal' } ,
359+ } )
360+ queueTableRows ( credential , [ ] )
361+ queueTableRows ( credential , [ ] )
362+ queueTableRows ( credential , [
363+ {
364+ id : 'credential-oci' ,
365+ workspaceId : WORKSPACE_ID ,
366+ type : 'service_account' ,
367+ displayName : 'ocid1.user.oc1..principal' ,
368+ description : null ,
369+ unredacted : false ,
370+ providerId : 'oci-api-key-service-account' ,
371+ accountId : null ,
372+ envKey : null ,
373+ envOwnerUserId : null ,
374+ encryptedServiceAccountKey : 'encrypted-oci-blob' ,
375+ createdBy : 'user-1' ,
376+ createdAt : new Date ( '2026-08-11T00:00:00.000Z' ) ,
377+ updatedAt : new Date ( '2026-08-11T00:00:00.000Z' ) ,
378+ } ,
379+ ] )
380+
381+ const response = await POST (
382+ createMockRequest ( 'POST' , {
383+ workspaceId : WORKSPACE_ID ,
384+ type : 'service_account' ,
385+ providerId : 'oci-api-key-service-account' ,
386+ tenancyOcid : 'ocid1.tenancy.oc1..tenant' ,
387+ userOcid : 'ocid1.user.oc1..principal' ,
388+ fingerprint : '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff' ,
389+ privateKey : '-----BEGIN PRIVATE KEY-----\nkey\n-----END PRIVATE KEY-----' ,
390+ privateKeyPassphrase : ' exact passphrase ' ,
391+ region : 'us-ashburn-1' ,
392+ } )
393+ )
394+ const body = await response . text ( )
395+
396+ expect ( response . status ) . toBe ( 201 )
397+ expect ( mockVerifyAndBuildServiceAccountSecret ) . toHaveBeenCalledWith (
398+ 'oci-api-key-service-account' ,
399+ expect . objectContaining ( {
400+ tenancyOcid : 'ocid1.tenancy.oc1..tenant' ,
401+ userOcid : 'ocid1.user.oc1..principal' ,
402+ fingerprint : '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff' ,
403+ privateKey : '-----BEGIN PRIVATE KEY-----\nkey\n-----END PRIVATE KEY-----' ,
404+ privateKeyPassphrase : ' exact passphrase ' ,
405+ region : 'us-ashburn-1' ,
406+ } )
407+ )
408+ expect ( body ) . not . toContain ( 'PRIVATE KEY' )
409+ expect ( body ) . not . toContain ( 'exact passphrase' )
410+ expect ( body ) . not . toContain ( 'encrypted-oci-blob' )
411+ } )
348412} )
0 commit comments