diff --git a/packages/core/src/routes/interaction/utils/social-verification.test.ts b/packages/core/src/routes/interaction/utils/social-verification.test.ts index 7df4a16a6..cd913c181 100644 --- a/packages/core/src/routes/interaction/utils/social-verification.test.ts +++ b/packages/core/src/routes/interaction/utils/social-verification.test.ts @@ -1,6 +1,7 @@ import { ConnectorType, GoogleConnector } from '@logto/connector-kit'; import { createMockUtils } from '@logto/shared/esm'; +import { mockConnector } from '#src/__mocks__/connector.js'; import type { WithLogContext } from '#src/middleware/koa-audit-log.js'; import createMockContext from '#src/test-utils/jest-koa-mocks/create-mock-context.js'; import { createMockLogContext } from '#src/test-utils/koa-audit-log.js'; @@ -10,9 +11,10 @@ const { jest } = import.meta; const { mockEsm } = createMockUtils(jest); const getUserInfo = jest.fn().mockResolvedValue({ id: 'foo' }); +const getConnector = jest.fn().mockResolvedValue(mockConnector); const tenant = new MockTenant(undefined, undefined, undefined, { - socials: { getUserInfo }, + socials: { getUserInfo, getConnector }, }); mockEsm('#src/libraries/connector.js', () => ({ @@ -49,12 +51,19 @@ describe('verifySocialIdentity', () => { // @ts-expect-error test mock context cookies: { get: jest.fn().mockReturnValue('token') }, }; - const connectorId = GoogleConnector.factoryId; + + getConnector.mockResolvedValueOnce({ + ...mockConnector, + metadata: { + ...mockConnector.metadata, + id: GoogleConnector.factoryId, + }, + }); const connectorData = { credential: 'credential' }; - await expect(verifySocialIdentity({ connectorId, connectorData }, ctx, tenant)).rejects.toThrow( - 'CSRF token mismatch.' - ); + await expect( + verifySocialIdentity({ connectorId: 'google', connectorData }, ctx, tenant) + ).rejects.toThrow('CSRF token mismatch.'); }); it('should verify Google One Tap verification', async () => {