@@ -7,8 +7,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
77
88const mocks = vi . hoisted ( ( ) => ( {
99 coalesceLocally : vi . fn ( ) ,
10- clientCredentialMinter : vi . fn ( ) ,
11- decryptSecret : vi . fn ( ) ,
1210 getFreshestSlackChain : vi . fn ( ) ,
1311 getRecentTerminalError : vi . fn ( ) ,
1412 logger : {
@@ -35,19 +33,6 @@ vi.mock('@/lib/concurrency/leader-lock', () => ({
3533 withLeaderLock : mocks . withLeaderLock ,
3634} ) )
3735
38- vi . mock ( '@/lib/core/security/encryption' , ( ) => ( {
39- decryptSecret : mocks . decryptSecret ,
40- } ) )
41-
42- vi . mock ( '@/lib/credentials/client-credential-accounts/server' , async ( importOriginal ) => {
43- const actual =
44- await importOriginal < typeof import ( '@/lib/credentials/client-credential-accounts/server' ) > ( )
45- return {
46- ...actual ,
47- getClientCredentialAccountMinter : vi . fn ( ( ) => mocks . clientCredentialMinter ) ,
48- }
49- } )
50-
5136vi . mock ( '@/lib/oauth/instagram' , ( ) => ( {
5237 isInstagramProvider : vi . fn ( ( ) => false ) ,
5338 shouldProactivelyRefreshInstagramToken : vi . fn ( ( ) => false ) ,
@@ -79,10 +64,7 @@ vi.mock('@/lib/oauth/terminal-errors', () => ({
7964 markCredentialDead : vi . fn ( ) ,
8065} ) )
8166
82- import {
83- resolveCredentialTokenBundle ,
84- resolveServiceAccountToken ,
85- } from '@/lib/oauth/credential-service'
67+ import { resolveCredentialTokenBundle } from '@/lib/oauth/credential-service'
8668
8769const RAW_CREDENTIAL_ID = 'credential-raw-secret-id'
8870const RAW_ACCOUNT_ID = 'account-raw-secret-id'
@@ -218,64 +200,3 @@ describe('resolveCredentialTokenBundle selector privacy', () => {
218200 expect ( slack . logs ) . toContain ( RAW_PROVIDER_ERROR )
219201 } )
220202} )
221-
222- describe ( 'Oracle EPM client-credential token cache' , ( ) => {
223- const providerId = 'oracle-epm-service-account'
224- const blob = JSON . stringify ( {
225- type : 'client_credential_account' ,
226- providerId,
227- clientId : 'integration.user@example.com' ,
228- clientSecret : 'password' ,
229- orgId : 'https://epm.example.com' ,
230- } )
231-
232- beforeEach ( ( ) => {
233- vi . clearAllMocks ( )
234- resetDbChainMock ( )
235- mocks . coalesceLocally . mockImplementation (
236- async ( _key : string , producer : ( ) => Promise < unknown > ) => producer ( )
237- )
238- mocks . decryptSecret . mockResolvedValue ( { decrypted : blob } )
239- } )
240-
241- it ( 'reuses the conservative synthetic token while its safety window remains' , async ( ) => {
242- const credentialId = 'oracle-epm-cache-credential'
243- const encrypted = 'cache-secret-fingerprint-000000000000000000000000000000000'
244- queueTableRows ( credential , [ { encryptedServiceAccountKey : encrypted } ] )
245- queueTableRows ( credential , [ { encryptedServiceAccountKey : encrypted } ] )
246- mocks . clientCredentialMinter . mockResolvedValue ( {
247- accessToken : 'basic-token' ,
248- expiresInSeconds : 600 ,
249- instanceUrl : 'https://epm.example.com' ,
250- } )
251-
252- await expect ( resolveServiceAccountToken ( credentialId , providerId ) ) . resolves . toMatchObject ( {
253- accessToken : 'basic-token' ,
254- } )
255- await expect ( resolveServiceAccountToken ( credentialId , providerId ) ) . resolves . toMatchObject ( {
256- accessToken : 'basic-token' ,
257- } )
258- expect ( mocks . clientCredentialMinter ) . toHaveBeenCalledTimes ( 1 )
259- } )
260-
261- it ( 'invalidates the cached token immediately when encrypted credentials rotate' , async ( ) => {
262- const credentialId = 'oracle-epm-rotation-credential'
263- queueTableRows ( credential , [
264- { encryptedServiceAccountKey : 'old-secret-fingerprint-000000000000000000000000000000000' } ,
265- ] )
266- queueTableRows ( credential , [
267- { encryptedServiceAccountKey : 'new-secret-fingerprint-000000000000000000000000000000000' } ,
268- ] )
269- mocks . clientCredentialMinter
270- . mockResolvedValueOnce ( { accessToken : 'old-token' , expiresInSeconds : 600 } )
271- . mockResolvedValueOnce ( { accessToken : 'new-token' , expiresInSeconds : 600 } )
272-
273- await expect ( resolveServiceAccountToken ( credentialId , providerId ) ) . resolves . toMatchObject ( {
274- accessToken : 'old-token' ,
275- } )
276- await expect ( resolveServiceAccountToken ( credentialId , providerId ) ) . resolves . toMatchObject ( {
277- accessToken : 'new-token' ,
278- } )
279- expect ( mocks . clientCredentialMinter ) . toHaveBeenCalledTimes ( 2 )
280- } )
281- } )
0 commit comments