@@ -550,4 +550,68 @@ describe('POST /api/credentials', () => {
550550 expect ( dbChainMockFns . insert ) . not . toHaveBeenCalled ( )
551551 } )
552552 } )
553+
554+ it ( 'forwards OCI API-key fields without returning secret material' , async ( ) => {
555+ mockVerifyAndBuildServiceAccountSecret . mockResolvedValueOnce ( {
556+ providerId : 'oci-api-key-service-account' ,
557+ encryptedServiceAccountKey : 'encrypted-oci-blob' ,
558+ displayName : 'ocid1.user.oc1..principal' ,
559+ auditMetadata : {
560+ principalKind : 'user' ,
561+ principalId : 'ocid1.user.oc1..principal' ,
562+ } ,
563+ principal : { kind : 'user' , id : 'ocid1.user.oc1..principal' } ,
564+ } )
565+ queueTableRows ( credential , [ ] )
566+ queueTableRows ( credential , [ ] )
567+ queueTableRows ( credential , [
568+ {
569+ id : 'credential-oci' ,
570+ workspaceId : WORKSPACE_ID ,
571+ type : 'service_account' ,
572+ displayName : 'ocid1.user.oc1..principal' ,
573+ description : null ,
574+ unredacted : false ,
575+ providerId : 'oci-api-key-service-account' ,
576+ accountId : null ,
577+ envKey : null ,
578+ envOwnerUserId : null ,
579+ encryptedServiceAccountKey : 'encrypted-oci-blob' ,
580+ createdBy : 'user-1' ,
581+ createdAt : new Date ( '2026-08-11T00:00:00.000Z' ) ,
582+ updatedAt : new Date ( '2026-08-11T00:00:00.000Z' ) ,
583+ } ,
584+ ] )
585+
586+ const response = await POST (
587+ createMockRequest ( 'POST' , {
588+ workspaceId : WORKSPACE_ID ,
589+ type : 'service_account' ,
590+ providerId : 'oci-api-key-service-account' ,
591+ tenancyOcid : 'ocid1.tenancy.oc1..tenant' ,
592+ userOcid : 'ocid1.user.oc1..principal' ,
593+ fingerprint : '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff' ,
594+ privateKey : '-----BEGIN PRIVATE KEY-----\nkey\n-----END PRIVATE KEY-----' ,
595+ privateKeyPassphrase : ' exact passphrase ' ,
596+ region : 'us-ashburn-1' ,
597+ } )
598+ )
599+ const body = await response . text ( )
600+
601+ expect ( response . status ) . toBe ( 201 )
602+ expect ( mockVerifyAndBuildServiceAccountSecret ) . toHaveBeenCalledWith (
603+ 'oci-api-key-service-account' ,
604+ expect . objectContaining ( {
605+ tenancyOcid : 'ocid1.tenancy.oc1..tenant' ,
606+ userOcid : 'ocid1.user.oc1..principal' ,
607+ fingerprint : '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff' ,
608+ privateKey : '-----BEGIN PRIVATE KEY-----\nkey\n-----END PRIVATE KEY-----' ,
609+ privateKeyPassphrase : ' exact passphrase ' ,
610+ region : 'us-ashburn-1' ,
611+ } )
612+ )
613+ expect ( body ) . not . toContain ( 'PRIVATE KEY' )
614+ expect ( body ) . not . toContain ( 'exact passphrase' )
615+ expect ( body ) . not . toContain ( 'encrypted-oci-blob' )
616+ } )
553617} )
0 commit comments