cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
7609e84ab3db53e79aefce6a112e90cb2a2bbba0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

tests/api-resources/access/identity-providers.test.ts

187lines · modecode

1// File generated from our OpenAPI spec by Stainless.
2
3import Cloudflare from 'cloudflare';
4import { Response } from 'node-fetch';
5
6const cloudflare = new Cloudflare({
7 apiKey: '144c9defac04969c7bfad8efaa8ea194',
8 apiEmail: 'dev@cloudflare.com',
9 apiToken: 'Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY',
10 userServiceKey: 'My User Service Key',
11 baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
12});
13
14describe('resource identityProviders', () => {
15 // skipped: tests are disabled for the time being
16 test.skip('create: only required params', async () => {
17 const responsePromise = cloudflare.access.identityProviders.create(
18 'string',
19 '023e105f4ecef8ad9ca31a8372d0c353',
20 { config: {}, name: 'Widget Corps IDP', type: 'onetimepin' },
21 );
22 const rawResponse = await responsePromise.asResponse();
23 expect(rawResponse).toBeInstanceOf(Response);
24 const response = await responsePromise;
25 expect(response).not.toBeInstanceOf(Response);
26 const dataAndResponse = await responsePromise.withResponse();
27 expect(dataAndResponse.data).toBe(response);
28 expect(dataAndResponse.response).toBe(rawResponse);
29 });
30
31 // skipped: tests are disabled for the time being
32 test.skip('create: required and optional params', async () => {
33 const response = await cloudflare.access.identityProviders.create(
34 'string',
35 '023e105f4ecef8ad9ca31a8372d0c353',
36 {
37 config: {
38 client_id: '<your client id>',
39 client_secret: '<your client secret>',
40 claims: ['email_verified', 'preferred_username', 'custom_claim_name'],
41 email_claim_name: 'custom_claim_name',
42 conditional_access_enabled: true,
43 directory_id: '<your azure directory uuid>',
44 support_groups: true,
45 },
46 name: 'Widget Corps IDP',
47 type: 'onetimepin',
48 scim_config: {
49 enabled: true,
50 group_member_deprovision: true,
51 seat_deprovision: true,
52 secret: 'string',
53 user_deprovision: true,
54 },
55 },
56 );
57 });
58
59 // skipped: tests are disabled for the time being
60 test.skip('list', async () => {
61 const responsePromise = cloudflare.access.identityProviders.list(
62 'string',
63 '023e105f4ecef8ad9ca31a8372d0c353',
64 );
65 const rawResponse = await responsePromise.asResponse();
66 expect(rawResponse).toBeInstanceOf(Response);
67 const response = await responsePromise;
68 expect(response).not.toBeInstanceOf(Response);
69 const dataAndResponse = await responsePromise.withResponse();
70 expect(dataAndResponse.data).toBe(response);
71 expect(dataAndResponse.response).toBe(rawResponse);
72 });
73
74 // skipped: tests are disabled for the time being
75 test.skip('list: request options instead of params are passed correctly', async () => {
76 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
77 await expect(
78 cloudflare.access.identityProviders.list('string', '023e105f4ecef8ad9ca31a8372d0c353', {
79 path: '/_stainless_unknown_path',
80 }),
81 ).rejects.toThrow(Cloudflare.NotFoundError);
82 });
83
84 // skipped: tests are disabled for the time being
85 test.skip('delete', async () => {
86 const responsePromise = cloudflare.access.identityProviders.delete(
87 'string',
88 '023e105f4ecef8ad9ca31a8372d0c353',
89 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
90 );
91 const rawResponse = await responsePromise.asResponse();
92 expect(rawResponse).toBeInstanceOf(Response);
93 const response = await responsePromise;
94 expect(response).not.toBeInstanceOf(Response);
95 const dataAndResponse = await responsePromise.withResponse();
96 expect(dataAndResponse.data).toBe(response);
97 expect(dataAndResponse.response).toBe(rawResponse);
98 });
99
100 // skipped: tests are disabled for the time being
101 test.skip('delete: request options instead of params are passed correctly', async () => {
102 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
103 await expect(
104 cloudflare.access.identityProviders.delete(
105 'string',
106 '023e105f4ecef8ad9ca31a8372d0c353',
107 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
108 { path: '/_stainless_unknown_path' },
109 ),
110 ).rejects.toThrow(Cloudflare.NotFoundError);
111 });
112
113 // skipped: tests are disabled for the time being
114 test.skip('get', async () => {
115 const responsePromise = cloudflare.access.identityProviders.get(
116 'string',
117 '023e105f4ecef8ad9ca31a8372d0c353',
118 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
119 );
120 const rawResponse = await responsePromise.asResponse();
121 expect(rawResponse).toBeInstanceOf(Response);
122 const response = await responsePromise;
123 expect(response).not.toBeInstanceOf(Response);
124 const dataAndResponse = await responsePromise.withResponse();
125 expect(dataAndResponse.data).toBe(response);
126 expect(dataAndResponse.response).toBe(rawResponse);
127 });
128
129 // skipped: tests are disabled for the time being
130 test.skip('get: request options instead of params are passed correctly', async () => {
131 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
132 await expect(
133 cloudflare.access.identityProviders.get(
134 'string',
135 '023e105f4ecef8ad9ca31a8372d0c353',
136 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
137 { path: '/_stainless_unknown_path' },
138 ),
139 ).rejects.toThrow(Cloudflare.NotFoundError);
140 });
141
142 // skipped: tests are disabled for the time being
143 test.skip('replace: only required params', async () => {
144 const responsePromise = cloudflare.access.identityProviders.replace(
145 'string',
146 '023e105f4ecef8ad9ca31a8372d0c353',
147 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
148 { config: {}, name: 'Widget Corps IDP', type: 'onetimepin' },
149 );
150 const rawResponse = await responsePromise.asResponse();
151 expect(rawResponse).toBeInstanceOf(Response);
152 const response = await responsePromise;
153 expect(response).not.toBeInstanceOf(Response);
154 const dataAndResponse = await responsePromise.withResponse();
155 expect(dataAndResponse.data).toBe(response);
156 expect(dataAndResponse.response).toBe(rawResponse);
157 });
158
159 // skipped: tests are disabled for the time being
160 test.skip('replace: required and optional params', async () => {
161 const response = await cloudflare.access.identityProviders.replace(
162 'string',
163 '023e105f4ecef8ad9ca31a8372d0c353',
164 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
165 {
166 config: {
167 client_id: '<your client id>',
168 client_secret: '<your client secret>',
169 claims: ['email_verified', 'preferred_username', 'custom_claim_name'],
170 email_claim_name: 'custom_claim_name',
171 conditional_access_enabled: true,
172 directory_id: '<your azure directory uuid>',
173 support_groups: true,
174 },
175 name: 'Widget Corps IDP',
176 type: 'onetimepin',
177 scim_config: {
178 enabled: true,
179 group_member_deprovision: true,
180 seat_deprovision: true,
181 secret: 'string',
182 user_deprovision: true,
183 },
184 },
185 );
186 });
187});