@@ -217,28 +217,44 @@ describe('verifyAndBuildServiceAccountSecret', () => {
217217 expect ( mockVerifyAndEncryptOci ) . not . toHaveBeenCalled ( )
218218 } )
219219
220- it ( 'classifies OCI verification outages without exposing provider details ', async ( ) => {
221- const { OciCredentialVerificationError } = await import (
222- '@/lib/credentials/oci-api-key-service-account.server'
223- )
224- mockVerifyAndEncryptOci . mockRejectedValue (
225- new OciCredentialVerificationError ( 'service_unavailable' )
226- )
220+ it . each ( [ 'service_unavailable ', 'invalid_response' ] as const ) (
221+ 'classifies OCI %s failures as provider outages without exposing provider details' ,
222+ async ( code ) => {
223+ const { OciCredentialVerificationError } = await import (
224+ '@/lib/credentials/oci-api-key-service-account.server'
225+ )
226+ mockVerifyAndEncryptOci . mockRejectedValue ( new OciCredentialVerificationError ( code ) )
227227
228- const failure = await verifyAndBuildServiceAccountSecret ( 'oci-api-key-service-account' , {
229- tenancyOcid : 'ocid1.tenancy.oc1..tenant' ,
230- userOcid : 'ocid1.user.oc1..principal' ,
231- fingerprint : '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff' ,
232- privateKey : 'provider-secret-key' ,
233- region : 'us-ashburn-1' ,
234- } ) . catch ( ( error : unknown ) => error )
228+ const failure = await verifyAndBuildServiceAccountSecret ( 'oci-api-key-service-account' , {
229+ tenancyOcid : 'ocid1.tenancy.oc1..tenant' ,
230+ userOcid : 'ocid1.user.oc1..principal' ,
231+ fingerprint : '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff' ,
232+ privateKey : 'provider-secret-key' ,
233+ region : 'us-ashburn-1' ,
234+ } ) . catch ( ( error : unknown ) => error )
235235
236- expect ( failure ) . toBeInstanceOf ( ServiceAccountSecretError )
237- expect ( failure ) . toMatchObject ( {
238- message : 'OCI is temporarily unavailable for credential verification' ,
239- providerErrorCode : 'provider_unavailable' ,
240- } )
241- expect ( JSON . stringify ( failure ) ) . not . toContain ( 'provider-secret-key' )
236+ expect ( failure ) . toBeInstanceOf ( ServiceAccountSecretError )
237+ expect ( failure ) . toMatchObject ( {
238+ message : 'OCI is temporarily unavailable for credential verification' ,
239+ providerErrorCode : 'provider_unavailable' ,
240+ } )
241+ expect ( JSON . stringify ( failure ) ) . not . toContain ( 'provider-secret-key' )
242+ }
243+ )
244+
245+ it ( 'does not misclassify an internal OCI credential failure as rejected credentials' , async ( ) => {
246+ const internalFailure = new Error ( 'internal encryption failure' )
247+ mockVerifyAndEncryptOci . mockRejectedValue ( internalFailure )
248+
249+ await expect (
250+ verifyAndBuildServiceAccountSecret ( 'oci-api-key-service-account' , {
251+ tenancyOcid : 'ocid1.tenancy.oc1..tenant' ,
252+ userOcid : 'ocid1.user.oc1..principal' ,
253+ fingerprint : '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff' ,
254+ privateKey : 'provider-secret-key' ,
255+ region : 'us-ashburn-1' ,
256+ } )
257+ ) . rejects . toBe ( internalFailure )
242258 } )
243259
244260 it ( 'rejects an unknown non-empty providerId instead of persisting it as Google' , async ( ) => {
0 commit comments