Skip to content
Open
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
53 changes: 33 additions & 20 deletions .oagen-manifest.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
{
"version": 2,
"language": "node",
"generatedAt": "2026-05-19T16:22:01.987Z",
"generatedAt": "2026-05-20T19:41:46.064Z",
"files": [
"src/webhooks/fixtures/create-webhook-endpoint.json",
"src/webhooks/fixtures/list-webhook-endpoint.json",
"src/webhooks/fixtures/update-webhook-endpoint.json",
"src/webhooks/fixtures/webhook-endpoint.json",
"src/webhooks/interfaces/create-webhook-endpoint-events.interface.ts",
"src/webhooks/interfaces/create-webhook-endpoint.interface.ts",
"src/webhooks/interfaces/index.ts",
"src/webhooks/interfaces/update-webhook-endpoint-events.interface.ts",
"src/webhooks/interfaces/update-webhook-endpoint-status.interface.ts",
"src/webhooks/interfaces/update-webhook-endpoint.interface.ts",
"src/webhooks/interfaces/webhook-endpoint-status.interface.ts",
"src/webhooks/interfaces/webhook-endpoint.interface.ts",
"src/webhooks/serializers.spec.ts",
"src/webhooks/serializers/create-webhook-endpoint.serializer.ts",
"src/webhooks/serializers/index.ts",
"src/webhooks/serializers/update-webhook-endpoint.serializer.ts",
"src/webhooks/serializers/webhook-endpoint.serializer.ts",
"src/webhooks/webhooks.spec.ts",
"src/webhooks/webhooks.ts"
"src/connect/connect.spec.ts",
"src/connect/connect.ts",
"src/connect/interfaces/application-credentials-list-item.interface.ts",
"src/connect/interfaces/connect-application.interface.ts",
"src/connect/interfaces/create-application-secret.interface.ts",
"src/connect/interfaces/create-m2m-application.interface.ts",
"src/connect/interfaces/create-oauth-application.interface.ts",
"src/connect/interfaces/external-auth-complete-response.interface.ts",
"src/connect/interfaces/index.ts",
"src/connect/interfaces/list-applications-options.interface.ts",
"src/connect/interfaces/new-connect-application-secret.interface.ts",
"src/connect/interfaces/redirect-uri-input.interface.ts",
"src/connect/interfaces/update-oauth-application.interface.ts",
"src/connect/interfaces/user-consent-option-choice.interface.ts",
"src/connect/interfaces/user-consent-option.interface.ts",
"src/connect/interfaces/user-management-login-request.interface.ts",
"src/connect/interfaces/user-object.interface.ts",
"src/connect/serializers.spec.ts",
"src/connect/serializers/application-credentials-list-item.serializer.ts",
"src/connect/serializers/connect-application.serializer.ts",
"src/connect/serializers/create-application-secret.serializer.ts",
"src/connect/serializers/create-m2m-application.serializer.ts",
"src/connect/serializers/create-oauth-application.serializer.ts",
"src/connect/serializers/external-auth-complete-response.serializer.ts",
"src/connect/serializers/index.ts",
"src/connect/serializers/new-connect-application-secret.serializer.ts",
"src/connect/serializers/redirect-uri-input.serializer.ts",
"src/connect/serializers/update-oauth-application.serializer.ts",
"src/connect/serializers/user-consent-option-choice.serializer.ts",
"src/connect/serializers/user-consent-option.serializer.ts",
"src/connect/serializers/user-management-login-request.serializer.ts",
"src/connect/serializers/user-object.serializer.ts"
],
"operations": {}
}
210 changes: 210 additions & 0 deletions src/connect/connect.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
// This file is auto-generated by oagen. Do not edit.

import fetch from 'jest-fetch-mock';
import {
fetchOnce,
fetchURL,
fetchMethod,
fetchSearchParams,
fetchBody,
} from '../common/utils/test-utils';
import { WorkOS } from '../workos';

import externalAuthCompleteResponseFixture from './fixtures/external-auth-complete-response.json';
import listConnectApplicationFixture from './fixtures/list-connect-application.json';
import connectApplicationFixture from './fixtures/connect-application.json';
import applicationCredentialsListItemFixture from './fixtures/application-credentials-list-item.json';
import newConnectApplicationSecretFixture from './fixtures/new-connect-application-secret.json';

const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');

function expectConnectApplication(result: any) {
expect(result.object).toBe('connect_application');
expect(result.id).toBe('conn_app_01HXYZ123456789ABCDEFGHIJ');
expect(result.clientId).toBe('client_01HXYZ123456789ABCDEFGHIJ');
expect(result.description).toBe('An application for managing user access');
expect(result.name).toBe('My Application');
expect(result.scopes).toEqual(['openid', 'profile', 'email']);
expect(result.createdAt.toISOString()).toBe('2026-01-15T12:00:00.000Z');
expect(result.updatedAt.toISOString()).toBe('2026-01-15T12:00:00.000Z');
}

describe('Connect', () => {
beforeEach(() => fetch.resetMocks());

describe('completeOAuth2', () => {
it('sends the correct request and returns result', async () => {
fetchOnce(externalAuthCompleteResponseFixture);

const result = await workos.connect.completeOAuth2({
externalAuthId: 'external_auth_id_01234',
user: { id: '01234', email: 'test@example.com' },
});

expect(fetchMethod()).toBe('POST');
expect(new URL(String(fetchURL())).pathname).toBe(
'/authkit/oauth2/complete',
);
expect(fetchBody()).toEqual(
expect.objectContaining({
external_auth_id: 'external_auth_id_01234',
user: { id: '01234', email: 'test@example.com' },
}),
);
expect(result.redirectUri).toBe(
'https://your-authkit-domain.workos.com/oauth/authorize/complete?state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdGF0ZSI6InJhbmRvbV9zdGF0ZV9zdHJpbmciLCJpYXQiOjE3NDI2MDQ4NTN9.abc123def456ghi789',
);
});
});

describe('listApplications', () => {
it('returns paginated results', async () => {
fetchOnce(listConnectApplicationFixture);

const { data, listMetadata } = await workos.connect.listApplications();

expect(fetchMethod()).toBe('GET');
expect(new URL(String(fetchURL())).pathname).toBe(
'/connect/applications',
);
expect(fetchSearchParams()).toHaveProperty('order');
expect(Array.isArray(data)).toBe(true);
expect(listMetadata).toBeDefined();
expect(data.length).toBeGreaterThan(0);
expectConnectApplication(data[0]);
});
});

describe('createApplication', () => {
it('sends the correct request and returns result', async () => {
fetchOnce(connectApplicationFixture);

const result = await workos.connect.createApplication({
name: 'Test',
applicationType: 'oauth',
isFirstParty: true,
});

expect(fetchMethod()).toBe('POST');
expect(new URL(String(fetchURL())).pathname).toBe(
'/connect/applications',
);
expect(fetchBody()).toEqual(
expect.objectContaining({
name: 'Test',
application_type: 'oauth',
is_first_party: true,
}),
);
expectConnectApplication(result);
});
});

describe('getApplication', () => {
it('returns the expected result', async () => {
fetchOnce(connectApplicationFixture);

const result = await workos.connect.getApplication('test_id');

expect(fetchMethod()).toBe('GET');
expect(new URL(String(fetchURL())).pathname).toBe(
'/connect/applications/test_id',
);
expectConnectApplication(result);
});
});

describe('updateApplication', () => {
it('sends the correct request and returns result', async () => {
fetchOnce(connectApplicationFixture);

const result = await workos.connect.updateApplication('test_id', {
name: 'Test',
});

expect(fetchMethod()).toBe('PUT');
expect(new URL(String(fetchURL())).pathname).toBe(
'/connect/applications/test_id',
);
expect(fetchBody()).toEqual(expect.objectContaining({ name: 'Test' }));
expectConnectApplication(result);
});
});

describe('deleteApplication', () => {
it('sends a DELETE request', async () => {
fetchOnce({}, { status: 204 });

await workos.connect.deleteApplication('test_id');

expect(fetchMethod()).toBe('DELETE');
expect(new URL(String(fetchURL())).pathname).toBe(
'/connect/applications/test_id',
);
});
});

describe('listApplicationClientSecrets', () => {
it('returns the expected result', async () => {
fetchOnce([applicationCredentialsListItemFixture]);

const result =
await workos.connect.listApplicationClientSecrets('test_id');

expect(fetchMethod()).toBe('GET');
expect(new URL(String(fetchURL())).pathname).toBe(
'/connect/applications/test_id/client_secrets',
);
expect(Array.isArray(result)).toBe(true);
expect(result[0].object).toBe('connect_application_secret');
expect(result[0].id).toBe('secret_01J9Q2Z3X4Y5W6V7U8T9S0R1Q');
expect(result[0].secretHint).toBe('abc123');
expect(result[0].lastUsedAt).toBe(null);
expect(result[0].createdAt.toISOString()).toBe(
'2026-01-15T12:00:00.000Z',
);
expect(result[0].updatedAt.toISOString()).toBe(
'2026-01-15T12:00:00.000Z',
);
});
});

describe('createApplicationClientSecret', () => {
it('sends the correct request and returns result', async () => {
fetchOnce(newConnectApplicationSecretFixture);

const result = await workos.connect.createApplicationClientSecret(
'test_id',
{},
);

expect(fetchMethod()).toBe('POST');
expect(new URL(String(fetchURL())).pathname).toBe(
'/connect/applications/test_id/client_secrets',
);
expect(fetchBody()).toBeDefined();
expect(result.object).toBe('connect_application_secret');
expect(result.id).toBe('secret_01J9Q2Z3X4Y5W6V7U8T9S0R1Q');
expect(result.secretHint).toBe('abc123');
expect(result.lastUsedAt).toBe(null);
expect(result.createdAt.toISOString()).toBe('2026-01-15T12:00:00.000Z');
expect(result.updatedAt.toISOString()).toBe('2026-01-15T12:00:00.000Z');
expect(result.secret).toBe(
'abc123def456ghi789jkl012mno345pqr678stu901vwx234yz',
);
});
});

describe('deleteClientSecret', () => {
it('sends a DELETE request', async () => {
fetchOnce({}, { status: 204 });

await workos.connect.deleteClientSecret('test_id');

expect(fetchMethod()).toBe('DELETE');
expect(new URL(String(fetchURL())).pathname).toBe(
'/connect/client_secrets/test_id',
);
});
});
});
Loading