@scalekit-sdk/node 2.2.0-beta.1 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/{reference.md → REFERENCE.md} +530 -748
- package/lib/auth.d.ts +9 -6
- package/lib/auth.js +4 -20
- package/lib/auth.js.map +1 -1
- package/lib/connect.d.ts +3 -3
- package/lib/connect.js +1 -2
- package/lib/connect.js.map +1 -1
- package/lib/connection.d.ts +2 -2
- package/lib/connection.js +4 -4
- package/lib/connection.js.map +1 -1
- package/lib/core.js +2 -2
- package/lib/core.js.map +1 -1
- package/lib/directory.d.ts +2 -2
- package/lib/directory.js +7 -7
- package/lib/directory.js.map +1 -1
- package/lib/domain.d.ts +6 -5
- package/lib/domain.js +4 -5
- package/lib/domain.js.map +1 -1
- package/lib/errors/base-exception.d.ts +1 -1
- package/lib/errors/base-exception.js +1 -1
- package/lib/errors/base-exception.js.map +1 -1
- package/lib/organization.d.ts +10 -9
- package/lib/organization.js +11 -9
- package/lib/organization.js.map +1 -1
- package/lib/passwordless.d.ts +2 -2
- package/lib/passwordless.js +8 -7
- package/lib/passwordless.js.map +1 -1
- package/lib/permission.d.ts +6 -5
- package/lib/permission.js +10 -11
- package/lib/permission.js.map +1 -1
- package/lib/pkg/grpc/buf/validate/validate_pb.d.ts +7 -0
- package/lib/pkg/grpc/buf/validate/validate_pb.js +25 -0
- package/lib/pkg/grpc/buf/validate/validate_pb.js.map +1 -0
- package/lib/pkg/grpc/google/api/annotations_pb.d.ts +7 -0
- package/lib/pkg/grpc/google/api/annotations_pb.js +25 -0
- package/lib/pkg/grpc/google/api/annotations_pb.js.map +1 -0
- package/lib/pkg/grpc/google/api/field_behavior_pb.d.ts +7 -0
- package/lib/pkg/grpc/google/api/field_behavior_pb.js +25 -0
- package/lib/pkg/grpc/google/api/field_behavior_pb.js.map +1 -0
- package/lib/pkg/grpc/google/api/visibility_pb.d.ts +7 -0
- package/lib/pkg/grpc/google/api/visibility_pb.js +25 -0
- package/lib/pkg/grpc/google/api/visibility_pb.js.map +1 -0
- package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.d.ts +7 -0
- package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.js +25 -0
- package/lib/pkg/grpc/protoc-gen-openapiv2/options/annotations_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.d.ts +48 -42
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js +27 -263
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +371 -325
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +132 -835
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.d.ts +113 -87
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.js +45 -201
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +262 -265
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +92 -938
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +162 -157
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +42 -313
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +1488 -1459
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +353 -2362
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.d.ts +520 -483
- package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.js +224 -1555
- package/lib/pkg/grpc/scalekit/v1/directories/directories_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.d.ts +219 -191
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js +96 -553
- package/lib/pkg/grpc/scalekit/v1/domains/domains_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.d.ts +76 -102
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js +37 -393
- package/lib/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.d.ts +36 -26
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js +20 -69
- package/lib/pkg/grpc/scalekit/v1/options/options_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.d.ts +447 -400
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js +163 -1238
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.d.ts +622 -556
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js +201 -1718
- package/lib/pkg/grpc/scalekit/v1/roles/roles_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.d.ts +135 -132
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js +55 -518
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +445 -413
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +142 -1490
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
- package/lib/role.d.ts +8 -7
- package/lib/role.js +14 -14
- package/lib/role.js.map +1 -1
- package/lib/scalekit.d.ts +0 -4
- package/lib/scalekit.js +0 -4
- package/lib/scalekit.js.map +1 -1
- package/lib/session.js +15 -24
- package/lib/session.js.map +1 -1
- package/lib/user.d.ts +6 -5
- package/lib/user.js +17 -20
- package/lib/user.js.map +1 -1
- package/lib/webauthn.js +6 -5
- package/lib/webauthn.js.map +1 -1
- package/package.json +12 -10
- package/.github/dependabot.yml +0 -10
- package/.nvmrc +0 -1
- package/buf.gen.yaml +0 -24
- package/jest.config.js +0 -15
- package/lib/connected-accounts.d.ts +0 -119
- package/lib/connected-accounts.js +0 -241
- package/lib/connected-accounts.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.d.ts +0 -19
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.js +0 -27
- package/lib/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +0 -118
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +0 -126
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.d.ts +0 -37
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.js +0 -45
- package/lib/pkg/grpc/scalekit/v1/auth/passwordless_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +0 -82
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +0 -90
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.d.ts +0 -87
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js +0 -95
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.d.ts +0 -718
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js +0 -893
- package/lib/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +0 -172
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -180
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.d.ts +0 -154
- package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.js +0 -162
- package/lib/pkg/grpc/scalekit/v1/directories/directories_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.d.ts +0 -73
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js +0 -81
- package/lib/pkg/grpc/scalekit/v1/domains/domains_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.d.ts +0 -171
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js +0 -179
- package/lib/pkg/grpc/scalekit/v1/organizations/organizations_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.d.ts +0 -250
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js +0 -258
- package/lib/pkg/grpc/scalekit/v1/roles/roles_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.d.ts +0 -46
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.js +0 -54
- package/lib/pkg/grpc/scalekit/v1/sessions/sessions_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.d.ts +0 -75
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js +0 -83
- package/lib/pkg/grpc/scalekit/v1/tools/tools_connect.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.d.ts +0 -431
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js +0 -627
- package/lib/pkg/grpc/scalekit/v1/tools/tools_pb.js.map +0 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.d.ts +0 -173
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.js +0 -181
- package/lib/pkg/grpc/scalekit/v1/users/users_connect.js.map +0 -1
- package/lib/tools.d.ts +0 -75
- package/lib/tools.js +0 -127
- package/lib/tools.js.map +0 -1
- package/src/auth.ts +0 -99
- package/src/connect.ts +0 -33
- package/src/connected-accounts.ts +0 -358
- package/src/connection.ts +0 -267
- package/src/constants/user.ts +0 -22
- package/src/core.ts +0 -139
- package/src/directory.ts +0 -431
- package/src/domain.ts +0 -272
- package/src/errors/base-exception.ts +0 -262
- package/src/errors/index.ts +0 -3
- package/src/errors/specific-exceptions.ts +0 -88
- package/src/index.ts +0 -10
- package/src/organization.ts +0 -568
- package/src/passwordless.ts +0 -138
- package/src/permission.ts +0 -310
- package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_connect.ts +0 -26
- package/src/pkg/grpc/scalekit/v1/auditlogs/auditlogs_pb.ts +0 -342
- package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +0 -125
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +0 -1213
- package/src/pkg/grpc/scalekit/v1/auth/passwordless_connect.ts +0 -44
- package/src/pkg/grpc/scalekit/v1/auth/passwordless_pb.ts +0 -336
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +0 -89
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +0 -1263
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +0 -573
- package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_connect.ts +0 -94
- package/src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb.ts +0 -1294
- package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +0 -179
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +0 -3846
- package/src/pkg/grpc/scalekit/v1/directories/directories_connect.ts +0 -161
- package/src/pkg/grpc/scalekit/v1/directories/directories_pb.ts +0 -2119
- package/src/pkg/grpc/scalekit/v1/domains/domains_connect.ts +0 -80
- package/src/pkg/grpc/scalekit/v1/domains/domains_pb.ts +0 -855
- package/src/pkg/grpc/scalekit/v1/errdetails/errdetails_pb.ts +0 -524
- package/src/pkg/grpc/scalekit/v1/options/options_pb.ts +0 -230
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_connect.ts +0 -178
- package/src/pkg/grpc/scalekit/v1/organizations/organizations_pb.ts +0 -1766
- package/src/pkg/grpc/scalekit/v1/roles/roles_connect.ts +0 -257
- package/src/pkg/grpc/scalekit/v1/roles/roles_pb.ts +0 -2395
- package/src/pkg/grpc/scalekit/v1/sessions/sessions_connect.ts +0 -53
- package/src/pkg/grpc/scalekit/v1/sessions/sessions_pb.ts +0 -749
- package/src/pkg/grpc/scalekit/v1/tools/tools_connect.ts +0 -82
- package/src/pkg/grpc/scalekit/v1/tools/tools_pb.ts +0 -847
- package/src/pkg/grpc/scalekit/v1/users/users_connect.ts +0 -180
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +0 -2151
- package/src/role.ts +0 -461
- package/src/scalekit.ts +0 -809
- package/src/session.ts +0 -337
- package/src/tools.ts +0 -166
- package/src/types/auth.ts +0 -73
- package/src/types/organization.ts +0 -12
- package/src/types/scalekit.ts +0 -50
- package/src/types/user.ts +0 -21
- package/src/user.ts +0 -825
- package/src/webauthn.ts +0 -98
- package/tests/README.md +0 -25
- package/tests/connected-accounts.test.ts +0 -472
- package/tests/connection.test.ts +0 -42
- package/tests/directory.test.ts +0 -46
- package/tests/domain.test.ts +0 -293
- package/tests/organization.test.ts +0 -81
- package/tests/passwordless.test.ts +0 -108
- package/tests/permission.test.ts +0 -399
- package/tests/role.test.ts +0 -323
- package/tests/scalekit.test.ts +0 -104
- package/tests/setup.ts +0 -34
- package/tests/tools.test.ts +0 -239
- package/tests/users.test.ts +0 -168
- package/tests/utils/test-data.ts +0 -481
- package/tsconfig.json +0 -19
package/src/webauthn.ts
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { PromiseClient } from '@connectrpc/connect';
|
|
2
|
-
import GrpcConnect from './connect';
|
|
3
|
-
import CoreClient from './core';
|
|
4
|
-
import { WebAuthnService } from './pkg/grpc/scalekit/v1/auth/webauthn_connect';
|
|
5
|
-
import {
|
|
6
|
-
ListCredentialsRequest,
|
|
7
|
-
ListCredentialsResponse,
|
|
8
|
-
UpdateCredentialRequest,
|
|
9
|
-
UpdateCredentialResponse,
|
|
10
|
-
DeleteCredentialRequest,
|
|
11
|
-
DeleteCredentialResponse
|
|
12
|
-
} from './pkg/grpc/scalekit/v1/auth/webauthn_pb';
|
|
13
|
-
|
|
14
|
-
export default class WebAuthnClient {
|
|
15
|
-
private client: PromiseClient<typeof WebAuthnService>;
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
private readonly grpcConnect: GrpcConnect,
|
|
19
|
-
private readonly coreClient: CoreClient
|
|
20
|
-
) {
|
|
21
|
-
this.client = this.grpcConnect.createClient(WebAuthnService);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* List all WebAuthn credentials for a user
|
|
26
|
-
* @param {string} userId The user ID to list credentials for
|
|
27
|
-
* @returns {Promise<ListCredentialsResponse>} The response containing:
|
|
28
|
-
* - credentials: Array of WebAuthn credentials
|
|
29
|
-
* - allAcceptedCredentialsOptions: Options for all accepted credentials
|
|
30
|
-
*/
|
|
31
|
-
async listCredentials(userId: string): Promise<ListCredentialsResponse> {
|
|
32
|
-
if (!userId || typeof userId !== 'string') {
|
|
33
|
-
throw new Error('userId must be a non-empty string');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const request = new ListCredentialsRequest({
|
|
37
|
-
userId
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return this.coreClient.connectExec(
|
|
41
|
-
this.client.listCredentials,
|
|
42
|
-
request
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Update a WebAuthn credential's display name
|
|
48
|
-
* @param {string} credentialId The credential ID to update
|
|
49
|
-
* @param {string} displayName The new display name for the credential
|
|
50
|
-
* @returns {Promise<UpdateCredentialResponse>} The response containing:
|
|
51
|
-
* - credential: The updated WebAuthn credential
|
|
52
|
-
*/
|
|
53
|
-
async updateCredential(
|
|
54
|
-
credentialId: string,
|
|
55
|
-
displayName: string
|
|
56
|
-
): Promise<UpdateCredentialResponse> {
|
|
57
|
-
if (!credentialId || typeof credentialId !== 'string') {
|
|
58
|
-
throw new Error('credentialId must be a non-empty string');
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!displayName || typeof displayName !== 'string') {
|
|
62
|
-
throw new Error('displayName must be a non-empty string');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const request = new UpdateCredentialRequest({
|
|
66
|
-
credentialId,
|
|
67
|
-
displayName
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return this.coreClient.connectExec(
|
|
71
|
-
this.client.updateCredential,
|
|
72
|
-
request
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Delete a WebAuthn credential
|
|
78
|
-
* @param {string} credentialId The credential ID to delete
|
|
79
|
-
* @returns {Promise<DeleteCredentialResponse>} The response containing:
|
|
80
|
-
* - success: Boolean indicating if the deletion was successful
|
|
81
|
-
* - unknownCredentialOptions: Options if the credential was not found
|
|
82
|
-
*/
|
|
83
|
-
async deleteCredential(credentialId: string): Promise<DeleteCredentialResponse> {
|
|
84
|
-
if (!credentialId || typeof credentialId !== 'string') {
|
|
85
|
-
throw new Error('credentialId must be a non-empty string');
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const request = new DeleteCredentialRequest({
|
|
89
|
-
credentialId
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
return this.coreClient.connectExec(
|
|
93
|
-
this.client.deleteCredential,
|
|
94
|
-
request
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
package/tests/README.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Scalekit Node SDK Tests
|
|
2
|
-
|
|
3
|
-
This directory contains the test suite for the Scalekit Node SDK.
|
|
4
|
-
|
|
5
|
-
## Setup
|
|
6
|
-
|
|
7
|
-
1. Create a `.env` file in the root directory with the following environment variables:
|
|
8
|
-
|
|
9
|
-
```env
|
|
10
|
-
# Required for client initialization
|
|
11
|
-
SCALEKIT_ENVIRONMENT_URL= "Your Scalekit environment URL."
|
|
12
|
-
SCALEKIT_CLIENT_ID= " Your Scalekit environment client id "
|
|
13
|
-
SCALEKIT_CLIENT_SECRET= " Your Scalekit environment client secret "
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
2. Install dependencies:
|
|
17
|
-
```bash
|
|
18
|
-
npm install
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Running Tests
|
|
22
|
-
|
|
23
|
-
- Run all tests: `npm test`
|
|
24
|
-
- Run tests in watch mode: `npm run test:watch`
|
|
25
|
-
|
|
@@ -1,472 +0,0 @@
|
|
|
1
|
-
import ScalekitClient from '../src/scalekit';
|
|
2
|
-
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
|
|
3
|
-
import { TestOrganizationManager } from './utils/test-data';
|
|
4
|
-
import {
|
|
5
|
-
CreateConnectedAccount,
|
|
6
|
-
UpdateConnectedAccount,
|
|
7
|
-
AuthorizationDetails,
|
|
8
|
-
OauthToken,
|
|
9
|
-
} from '../src/pkg/grpc/scalekit/v1/connected_accounts/connected_accounts_pb';
|
|
10
|
-
|
|
11
|
-
describe('Connected Accounts', () => {
|
|
12
|
-
let client: ScalekitClient;
|
|
13
|
-
let testOrg: string;
|
|
14
|
-
let testConnectedAccountId: string | null = null;
|
|
15
|
-
let testConnector: string | null = null;
|
|
16
|
-
let testIdentifier: string | null = null;
|
|
17
|
-
|
|
18
|
-
beforeEach(async () => {
|
|
19
|
-
// Use global client
|
|
20
|
-
client = global.client;
|
|
21
|
-
|
|
22
|
-
// Create test organization for each test
|
|
23
|
-
testOrg = await TestOrganizationManager.createTestOrganization(client);
|
|
24
|
-
|
|
25
|
-
// Reset test state
|
|
26
|
-
testConnectedAccountId = null;
|
|
27
|
-
testConnector = null;
|
|
28
|
-
testIdentifier = null;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
afterEach(async () => {
|
|
32
|
-
// Clean up test connected account if created
|
|
33
|
-
if (testConnectedAccountId && testConnector && testIdentifier) {
|
|
34
|
-
try {
|
|
35
|
-
await client.connectedAccounts.deleteConnectedAccount({
|
|
36
|
-
connector: testConnector,
|
|
37
|
-
identifier: testIdentifier,
|
|
38
|
-
connectedAccountId: testConnectedAccountId,
|
|
39
|
-
});
|
|
40
|
-
} catch (error) {
|
|
41
|
-
// Account may already be deleted or not exist
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Reset test state
|
|
46
|
-
testConnectedAccountId = null;
|
|
47
|
-
testConnector = null;
|
|
48
|
-
testIdentifier = null;
|
|
49
|
-
|
|
50
|
-
// Clean up test organization
|
|
51
|
-
await TestOrganizationManager.cleanupTestOrganization(client, testOrg);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('listConnectedAccounts', () => {
|
|
55
|
-
it('should list connected accounts', async () => {
|
|
56
|
-
const response = await client.connectedAccounts.listConnectedAccounts();
|
|
57
|
-
|
|
58
|
-
expect(response).toBeDefined();
|
|
59
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
60
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
61
|
-
expect(response.totalSize).toBeDefined();
|
|
62
|
-
expect(typeof response.totalSize).toBe('number');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should list connected accounts with organization filter', async () => {
|
|
66
|
-
const response = await client.connectedAccounts.listConnectedAccounts({
|
|
67
|
-
organizationId: testOrg,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
expect(response).toBeDefined();
|
|
71
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
72
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should list connected accounts with connector filter', async () => {
|
|
76
|
-
const response = await client.connectedAccounts.listConnectedAccounts({
|
|
77
|
-
connector: 'notion',
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
expect(response).toBeDefined();
|
|
81
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
82
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should list connected accounts with provider filter', async () => {
|
|
86
|
-
const response = await client.connectedAccounts.listConnectedAccounts({
|
|
87
|
-
provider: 'google',
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(response).toBeDefined();
|
|
91
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
92
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should list connected accounts with pagination', async () => {
|
|
96
|
-
const firstPage = await client.connectedAccounts.listConnectedAccounts({
|
|
97
|
-
pageSize: 10,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
expect(firstPage).toBeDefined();
|
|
101
|
-
expect(firstPage.connectedAccounts).toBeDefined();
|
|
102
|
-
expect(firstPage.connectedAccounts.length).toBeLessThanOrEqual(10);
|
|
103
|
-
|
|
104
|
-
if (firstPage.nextPageToken) {
|
|
105
|
-
const secondPage = await client.connectedAccounts.listConnectedAccounts({
|
|
106
|
-
pageSize: 10,
|
|
107
|
-
pageToken: firstPage.nextPageToken,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
expect(secondPage).toBeDefined();
|
|
111
|
-
expect(secondPage.connectedAccounts).toBeDefined();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should list connected accounts with query search', async () => {
|
|
116
|
-
const response = await client.connectedAccounts.listConnectedAccounts({
|
|
117
|
-
query: 'test',
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
expect(response).toBeDefined();
|
|
121
|
-
expect(response.connectedAccounts).toBeDefined();
|
|
122
|
-
expect(Array.isArray(response.connectedAccounts)).toBe(true);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe('createConnectedAccount', () => {
|
|
127
|
-
it('should handle create connected account request', async () => {
|
|
128
|
-
const connector = 'test_connector';
|
|
129
|
-
const identifier = `test_${Date.now()}`;
|
|
130
|
-
|
|
131
|
-
const oauthToken = new OauthToken({
|
|
132
|
-
accessToken: 'test_access_token',
|
|
133
|
-
refreshToken: 'test_refresh_token',
|
|
134
|
-
scopes: ['read', 'write'],
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const authorizationDetails = new AuthorizationDetails({
|
|
138
|
-
details: {
|
|
139
|
-
case: 'oauthToken',
|
|
140
|
-
value: oauthToken,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const connectedAccount = new CreateConnectedAccount({
|
|
145
|
-
authorizationDetails,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
const response = await client.connectedAccounts.createConnectedAccount({
|
|
150
|
-
connector,
|
|
151
|
-
identifier,
|
|
152
|
-
connectedAccount,
|
|
153
|
-
organizationId: testOrg,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
expect(response).toBeDefined();
|
|
157
|
-
expect(response.connectedAccount).toBeDefined();
|
|
158
|
-
expect(response.connectedAccount?.id).toBeDefined();
|
|
159
|
-
|
|
160
|
-
if (response.connectedAccount?.id) {
|
|
161
|
-
testConnectedAccountId = response.connectedAccount.id;
|
|
162
|
-
testConnector = connector;
|
|
163
|
-
testIdentifier = identifier;
|
|
164
|
-
}
|
|
165
|
-
} catch (error: any) {
|
|
166
|
-
// Expected errors: connector not found, invalid credentials, etc.
|
|
167
|
-
expect(error).toBeDefined();
|
|
168
|
-
// Verify it's a proper error response, not a request structure issue
|
|
169
|
-
expect(error.message || error.toString()).toBeDefined();
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
it('should handle create connected account with user ID', async () => {
|
|
174
|
-
const connector = 'test_connector';
|
|
175
|
-
const identifier = `test_user_${Date.now()}`;
|
|
176
|
-
|
|
177
|
-
const oauthToken = new OauthToken({
|
|
178
|
-
accessToken: 'test_access_token',
|
|
179
|
-
refreshToken: 'test_refresh_token',
|
|
180
|
-
scopes: ['read'],
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const authorizationDetails = new AuthorizationDetails({
|
|
184
|
-
details: {
|
|
185
|
-
case: 'oauthToken',
|
|
186
|
-
value: oauthToken,
|
|
187
|
-
},
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
const connectedAccount = new CreateConnectedAccount({
|
|
191
|
-
authorizationDetails,
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
try {
|
|
195
|
-
const response = await client.connectedAccounts.createConnectedAccount({
|
|
196
|
-
connector,
|
|
197
|
-
identifier,
|
|
198
|
-
connectedAccount,
|
|
199
|
-
userId: 'usr_test123',
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
expect(response).toBeDefined();
|
|
203
|
-
if (response.connectedAccount?.id) {
|
|
204
|
-
testConnectedAccountId = response.connectedAccount.id;
|
|
205
|
-
testConnector = connector;
|
|
206
|
-
testIdentifier = identifier;
|
|
207
|
-
}
|
|
208
|
-
} catch (error: any) {
|
|
209
|
-
// Expected errors: connector not found, invalid credentials, etc.
|
|
210
|
-
expect(error).toBeDefined();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
describe('getOrCreateConnectedAccount', () => {
|
|
216
|
-
it('should throw when connector is empty', async () => {
|
|
217
|
-
await expect(
|
|
218
|
-
client.connectedAccounts.getOrCreateConnectedAccount({
|
|
219
|
-
connector: '',
|
|
220
|
-
identifier: 'user_123',
|
|
221
|
-
})
|
|
222
|
-
).rejects.toThrow('connector is required');
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('should throw when identifier is empty', async () => {
|
|
226
|
-
await expect(
|
|
227
|
-
client.connectedAccounts.getOrCreateConnectedAccount({
|
|
228
|
-
connector: 'gmail',
|
|
229
|
-
identifier: '',
|
|
230
|
-
})
|
|
231
|
-
).rejects.toThrow('identifier is required');
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('should return existing account when found (get path)', async () => {
|
|
235
|
-
const connector = 'gmail';
|
|
236
|
-
const identifier = 'get-or-create-test@example.com';
|
|
237
|
-
try {
|
|
238
|
-
const response = await client.connectedAccounts.getOrCreateConnectedAccount({
|
|
239
|
-
connector,
|
|
240
|
-
identifier,
|
|
241
|
-
organizationId: testOrg,
|
|
242
|
-
});
|
|
243
|
-
expect(response).toBeDefined();
|
|
244
|
-
expect(response.connectedAccount).toBeDefined();
|
|
245
|
-
expect(response.connectedAccount?.identifier).toBe(identifier);
|
|
246
|
-
expect(response.connectedAccount?.connector).toBe(connector);
|
|
247
|
-
} catch (error: unknown) {
|
|
248
|
-
expect(error).toBeDefined();
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
describe('updateConnectedAccount', () => {
|
|
254
|
-
it('should handle update connected account request', async () => {
|
|
255
|
-
const connector = 'test_connector';
|
|
256
|
-
const identifier = 'test_identifier';
|
|
257
|
-
|
|
258
|
-
const oauthToken = new OauthToken({
|
|
259
|
-
accessToken: 'updated_access_token',
|
|
260
|
-
refreshToken: 'updated_refresh_token',
|
|
261
|
-
scopes: ['read', 'write', 'admin'],
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
const authorizationDetails = new AuthorizationDetails({
|
|
265
|
-
details: {
|
|
266
|
-
case: 'oauthToken',
|
|
267
|
-
value: oauthToken,
|
|
268
|
-
},
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
const connectedAccount = new UpdateConnectedAccount({
|
|
272
|
-
authorizationDetails,
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
try {
|
|
276
|
-
const response = await client.connectedAccounts.updateConnectedAccount({
|
|
277
|
-
connector,
|
|
278
|
-
identifier,
|
|
279
|
-
connectedAccount,
|
|
280
|
-
organizationId: testOrg,
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
expect(response).toBeDefined();
|
|
284
|
-
expect(response.connectedAccount).toBeDefined();
|
|
285
|
-
} catch (error: any) {
|
|
286
|
-
// Expected errors: connected account not found, invalid credentials, etc.
|
|
287
|
-
expect(error).toBeDefined();
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it('should handle update connected account with ID', async () => {
|
|
292
|
-
const connector = 'test_connector';
|
|
293
|
-
const identifier = 'test_identifier';
|
|
294
|
-
|
|
295
|
-
const oauthToken = new OauthToken({
|
|
296
|
-
accessToken: 'updated_access_token',
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
const authorizationDetails = new AuthorizationDetails({
|
|
300
|
-
details: {
|
|
301
|
-
case: 'oauthToken',
|
|
302
|
-
value: oauthToken,
|
|
303
|
-
},
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
const connectedAccount = new UpdateConnectedAccount({
|
|
307
|
-
authorizationDetails,
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
try {
|
|
311
|
-
const response = await client.connectedAccounts.updateConnectedAccount({
|
|
312
|
-
connector,
|
|
313
|
-
identifier,
|
|
314
|
-
connectedAccount,
|
|
315
|
-
connectedAccountId: 'ca_test123',
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
expect(response).toBeDefined();
|
|
319
|
-
} catch (error: any) {
|
|
320
|
-
// Expected errors: connected account not found, etc.
|
|
321
|
-
expect(error).toBeDefined();
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
describe('deleteConnectedAccount', () => {
|
|
327
|
-
it('should handle delete connected account request', async () => {
|
|
328
|
-
const connector = 'test_connector';
|
|
329
|
-
const identifier = 'test_identifier';
|
|
330
|
-
|
|
331
|
-
try {
|
|
332
|
-
const response = await client.connectedAccounts.deleteConnectedAccount({
|
|
333
|
-
connector,
|
|
334
|
-
identifier,
|
|
335
|
-
organizationId: testOrg,
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
expect(response).toBeDefined();
|
|
339
|
-
} catch (error: any) {
|
|
340
|
-
// Expected errors: connected account not found, etc.
|
|
341
|
-
expect(error).toBeDefined();
|
|
342
|
-
}
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it('should handle delete connected account with ID', async () => {
|
|
346
|
-
try {
|
|
347
|
-
const response = await client.connectedAccounts.deleteConnectedAccount({
|
|
348
|
-
connector: 'test_connector',
|
|
349
|
-
identifier: 'test_identifier',
|
|
350
|
-
connectedAccountId: 'ca_test123',
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
expect(response).toBeDefined();
|
|
354
|
-
} catch (error: any) {
|
|
355
|
-
// Expected errors: connected account not found, etc.
|
|
356
|
-
expect(error).toBeDefined();
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
describe('getMagicLinkForConnectedAccount', () => {
|
|
362
|
-
it('should handle get magic link request', async () => {
|
|
363
|
-
const connector = 'test_connector';
|
|
364
|
-
const identifier = 'test_identifier';
|
|
365
|
-
|
|
366
|
-
try {
|
|
367
|
-
const response = await client.connectedAccounts.getMagicLinkForConnectedAccount({
|
|
368
|
-
connector,
|
|
369
|
-
identifier,
|
|
370
|
-
organizationId: testOrg,
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
expect(response).toBeDefined();
|
|
374
|
-
expect(response.link).toBeDefined();
|
|
375
|
-
expect(typeof response.link).toBe('string');
|
|
376
|
-
expect(response.expiry).toBeDefined();
|
|
377
|
-
} catch (error: any) {
|
|
378
|
-
// Expected errors: connector not found, invalid parameters, etc.
|
|
379
|
-
expect(error).toBeDefined();
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
|
|
383
|
-
it('should handle get magic link with user ID', async () => {
|
|
384
|
-
try {
|
|
385
|
-
const response = await client.connectedAccounts.getMagicLinkForConnectedAccount({
|
|
386
|
-
connector: 'test_connector',
|
|
387
|
-
identifier: 'test_identifier',
|
|
388
|
-
userId: 'usr_test123',
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
expect(response).toBeDefined();
|
|
392
|
-
if (response.link) {
|
|
393
|
-
expect(typeof response.link).toBe('string');
|
|
394
|
-
}
|
|
395
|
-
} catch (error: any) {
|
|
396
|
-
// Expected errors: connector not found, etc.
|
|
397
|
-
expect(error).toBeDefined();
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
it('should handle get magic link with connected account ID', async () => {
|
|
402
|
-
try {
|
|
403
|
-
const response = await client.connectedAccounts.getMagicLinkForConnectedAccount({
|
|
404
|
-
connector: 'test_connector',
|
|
405
|
-
identifier: 'test_identifier',
|
|
406
|
-
connectedAccountId: 'ca_test123',
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
expect(response).toBeDefined();
|
|
410
|
-
} catch (error: any) {
|
|
411
|
-
// Expected errors: connected account not found, etc.
|
|
412
|
-
expect(error).toBeDefined();
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
describe('getConnectedAccountByIdentifier', () => {
|
|
418
|
-
it('should handle get connected account by identifier request', async () => {
|
|
419
|
-
const connector = 'test_connector';
|
|
420
|
-
const identifier = 'test_identifier';
|
|
421
|
-
|
|
422
|
-
try {
|
|
423
|
-
const response = await client.connectedAccounts.getConnectedAccountByIdentifier({
|
|
424
|
-
connector,
|
|
425
|
-
identifier,
|
|
426
|
-
organizationId: testOrg,
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
expect(response).toBeDefined();
|
|
430
|
-
expect(response.connectedAccount).toBeDefined();
|
|
431
|
-
expect(response.connectedAccount?.id).toBeDefined();
|
|
432
|
-
expect(response.connectedAccount?.authorizationDetails).toBeDefined();
|
|
433
|
-
} catch (error: any) {
|
|
434
|
-
// Expected errors: connected account not found, etc.
|
|
435
|
-
expect(error).toBeDefined();
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
it('should handle get connected account with user ID', async () => {
|
|
440
|
-
try {
|
|
441
|
-
const response = await client.connectedAccounts.getConnectedAccountByIdentifier({
|
|
442
|
-
connector: 'test_connector',
|
|
443
|
-
identifier: 'test_identifier',
|
|
444
|
-
userId: 'usr_test123',
|
|
445
|
-
});
|
|
446
|
-
|
|
447
|
-
expect(response).toBeDefined();
|
|
448
|
-
if (response.connectedAccount) {
|
|
449
|
-
expect(response.connectedAccount.id).toBeDefined();
|
|
450
|
-
}
|
|
451
|
-
} catch (error: any) {
|
|
452
|
-
// Expected errors: connected account not found, etc.
|
|
453
|
-
expect(error).toBeDefined();
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
it('should handle get connected account with connected account ID', async () => {
|
|
458
|
-
try {
|
|
459
|
-
const response = await client.connectedAccounts.getConnectedAccountByIdentifier({
|
|
460
|
-
connector: 'test_connector',
|
|
461
|
-
identifier: 'test_identifier',
|
|
462
|
-
connectedAccountId: 'ca_test123',
|
|
463
|
-
});
|
|
464
|
-
|
|
465
|
-
expect(response).toBeDefined();
|
|
466
|
-
} catch (error: any) {
|
|
467
|
-
// Expected errors: connected account not found, etc.
|
|
468
|
-
expect(error).toBeDefined();
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
});
|
|
472
|
-
});
|
package/tests/connection.test.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import ScalekitClient from '../src/scalekit';
|
|
2
|
-
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
|
|
3
|
-
import { TestOrganizationManager } from './utils/test-data';
|
|
4
|
-
|
|
5
|
-
describe('Connections', () => {
|
|
6
|
-
let client: ScalekitClient;
|
|
7
|
-
let testOrg: string;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
// Use global client
|
|
11
|
-
client = global.client;
|
|
12
|
-
|
|
13
|
-
// Create test organization for each test
|
|
14
|
-
testOrg = await TestOrganizationManager.createTestOrganization(client);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(async () => {
|
|
18
|
-
// Clean up test organization
|
|
19
|
-
await TestOrganizationManager.cleanupTestOrganization(client, testOrg);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('listConnections', () => {
|
|
23
|
-
it('should list connections by organization', async () => {
|
|
24
|
-
const connections = await client.connection.listConnections(testOrg);
|
|
25
|
-
|
|
26
|
-
expect(connections).toBeDefined();
|
|
27
|
-
expect(connections.connections).toBeDefined();
|
|
28
|
-
expect(Array.isArray(connections.connections)).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('listConnectionsByDomain', () => {
|
|
33
|
-
it('should list connections by domain', async () => {
|
|
34
|
-
const domain = 'example.com';
|
|
35
|
-
const connections = await client.connection.listConnectionsByDomain(domain);
|
|
36
|
-
|
|
37
|
-
expect(connections).toBeDefined();
|
|
38
|
-
expect(connections.connections).toBeDefined();
|
|
39
|
-
expect(Array.isArray(connections.connections)).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
package/tests/directory.test.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import ScalekitClient from '../src/scalekit';
|
|
2
|
-
import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
|
|
3
|
-
import { TestOrganizationManager } from './utils/test-data';
|
|
4
|
-
|
|
5
|
-
describe('Directories', () => {
|
|
6
|
-
let client: ScalekitClient;
|
|
7
|
-
let testOrg: string;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
// Use global client
|
|
11
|
-
client = global.client;
|
|
12
|
-
|
|
13
|
-
// Create test organization for each test
|
|
14
|
-
testOrg = await TestOrganizationManager.createTestOrganization(client);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
afterEach(async () => {
|
|
18
|
-
// Clean up test organization
|
|
19
|
-
await TestOrganizationManager.cleanupTestOrganization(client, testOrg);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
describe('listDirectories', () => {
|
|
23
|
-
it('should list directories', async () => {
|
|
24
|
-
const directories = await client.directory.listDirectories(testOrg);
|
|
25
|
-
|
|
26
|
-
expect(directories).toBeDefined();
|
|
27
|
-
expect(directories.directories).toBeDefined();
|
|
28
|
-
expect(Array.isArray(directories.directories)).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe('getPrimaryDirectoryByOrganizationId', () => {
|
|
33
|
-
it('should get primary directory by organization id', async () => {
|
|
34
|
-
try {
|
|
35
|
-
const primaryDirectory = await client.directory.getPrimaryDirectoryByOrganizationId(testOrg);
|
|
36
|
-
|
|
37
|
-
expect(primaryDirectory).toBeDefined();
|
|
38
|
-
expect(primaryDirectory.id).toBeDefined();
|
|
39
|
-
expect(primaryDirectory.organizationId).toBe(testOrg);
|
|
40
|
-
} catch (error) {
|
|
41
|
-
// Expected when no directories exist
|
|
42
|
-
expect(error).toBeDefined();
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|