Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/machine-tests-rate-limit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
25 changes: 15 additions & 10 deletions integration/testUtils/machineAuthHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { EnvironmentConfig } from '../models/environment';
import { appConfigs } from '../presets';
import { instanceKeys } from '../presets/envs';
import { createTestUtils } from './index';
import { withRetry } from './retryableClerkClient';
import type { FakeAPIKey, FakeUser } from './usersService';

export type FakeMachineNetwork = {
Expand Down Expand Up @@ -182,24 +183,28 @@ export type MachineAuthTestAdapter = {
const createApiKeysEnv = (): EnvironmentConfig => appConfigs.envs.withAPIKeys.clone();

export const createMachineClient = () =>
createClerkClient({
secretKey: instanceKeys.get('with-api-keys').sk,
});
withRetry(
createClerkClient({
secretKey: instanceKeys.get('with-api-keys').sk,
}),
);

const buildApp = async (adapter: MachineAuthTestAdapter, addRoutes: RouteBuilder): Promise<Application> => {
const config = addRoutes(adapter.baseConfig.clone());
return config.commit();
};

const createOAuthClient = (app: Application) =>
createClerkClient({
secretKey: app.env.privateVariables.get('CLERK_SECRET_KEY'),
publishableKey: app.env.publicVariables.get('CLERK_PUBLISHABLE_KEY'),
});
withRetry(
createClerkClient({
secretKey: app.env.privateVariables.get('CLERK_SECRET_KEY'),
publishableKey: app.env.publicVariables.get('CLERK_PUBLISHABLE_KEY'),
}),
);

export const registerApiKeyAuthTests = (adapter: MachineAuthTestAdapter): void => {
test.describe('API key auth', () => {
test.describe.configure({ mode: 'parallel' });
test.describe.configure({ mode: 'default' });
let app: Application;
let fakeUser: FakeUser;
let fakeBapiUser: User;
Expand Down Expand Up @@ -293,7 +298,7 @@ export const registerApiKeyAuthTests = (adapter: MachineAuthTestAdapter): void =

export const registerM2MAuthTests = (adapter: MachineAuthTestAdapter): void => {
test.describe('M2M auth', () => {
test.describe.configure({ mode: 'parallel' });
test.describe.configure({ mode: 'default' });
let app: Application;
let network: FakeMachineNetwork;

Expand Down Expand Up @@ -376,7 +381,7 @@ export const registerM2MAuthTests = (adapter: MachineAuthTestAdapter): void => {

export const registerOAuthAuthTests = (adapter: MachineAuthTestAdapter): void => {
test.describe('OAuth auth', () => {
test.describe.configure({ mode: 'parallel' });
test.describe.configure({ mode: 'default' });
let app: Application;
let fakeUser: FakeUser;
let fakeOAuth: FakeOAuthApp;
Expand Down
4 changes: 2 additions & 2 deletions integration/tests/next-machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ test.describe('Next.js machine authentication @machine', () => {
registerOAuthAuthTests(adapter);

test.describe('auth.protect() authorization with API keys', () => {
test.describe.configure({ mode: 'parallel' });
test.describe.configure({ mode: 'default' });
let app: Application;
let fakeUser: FakeUser;
let fakeBapiUser: User;
Expand Down Expand Up @@ -198,7 +198,7 @@ test.describe('Next.js machine authentication @machine', () => {
});

test.describe('session helpers with machine tokens', () => {
test.describe.configure({ mode: 'parallel' });
test.describe.configure({ mode: 'default' });
let app: Application;
let network: FakeMachineNetwork;
let jwtToken: string;
Expand Down
Loading