cloudflare/cloudflare-typescript

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
17a67863c4f3fb405564d00fe9ff581260edf3c4

Branches

Tags

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

Clone

HTTPS

Download ZIP

tests/api-resources/access/groups.test.ts

199lines · 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 groups', () => {
15 // skipped: tests are disabled for the time being
16 test.skip('retrieve', async () => {
17 const responsePromise = cloudflare.access.groups.retrieve(
18 'string',
19 '023e105f4ecef8ad9ca31a8372d0c353',
20 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
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('retrieve: request options instead of params are passed correctly', async () => {
33 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
34 await expect(
35 cloudflare.access.groups.retrieve(
36 'string',
37 '023e105f4ecef8ad9ca31a8372d0c353',
38 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
39 { path: '/_stainless_unknown_path' },
40 ),
41 ).rejects.toThrow(Cloudflare.NotFoundError);
42 });
43
44 // skipped: tests are disabled for the time being
45 test.skip('update: only required params', async () => {
46 const responsePromise = cloudflare.access.groups.update(
47 'string',
48 '023e105f4ecef8ad9ca31a8372d0c353',
49 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
50 {
51 include: [
52 { email: { email: 'test@example.com' } },
53 { email: { email: 'test@example.com' } },
54 { email: { email: 'test@example.com' } },
55 ],
56 name: 'Allow devs',
57 },
58 );
59 const rawResponse = await responsePromise.asResponse();
60 expect(rawResponse).toBeInstanceOf(Response);
61 const response = await responsePromise;
62 expect(response).not.toBeInstanceOf(Response);
63 const dataAndResponse = await responsePromise.withResponse();
64 expect(dataAndResponse.data).toBe(response);
65 expect(dataAndResponse.response).toBe(rawResponse);
66 });
67
68 // skipped: tests are disabled for the time being
69 test.skip('update: required and optional params', async () => {
70 const response = await cloudflare.access.groups.update(
71 'string',
72 '023e105f4ecef8ad9ca31a8372d0c353',
73 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
74 {
75 include: [
76 { email: { email: 'test@example.com' } },
77 { email: { email: 'test@example.com' } },
78 { email: { email: 'test@example.com' } },
79 ],
80 name: 'Allow devs',
81 exclude: [
82 { email: { email: 'test@example.com' } },
83 { email: { email: 'test@example.com' } },
84 { email: { email: 'test@example.com' } },
85 ],
86 is_default: true,
87 require: [
88 { email: { email: 'test@example.com' } },
89 { email: { email: 'test@example.com' } },
90 { email: { email: 'test@example.com' } },
91 ],
92 },
93 );
94 });
95
96 // skipped: tests are disabled for the time being
97 test.skip('delete', async () => {
98 const responsePromise = cloudflare.access.groups.delete(
99 'string',
100 '023e105f4ecef8ad9ca31a8372d0c353',
101 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
102 );
103 const rawResponse = await responsePromise.asResponse();
104 expect(rawResponse).toBeInstanceOf(Response);
105 const response = await responsePromise;
106 expect(response).not.toBeInstanceOf(Response);
107 const dataAndResponse = await responsePromise.withResponse();
108 expect(dataAndResponse.data).toBe(response);
109 expect(dataAndResponse.response).toBe(rawResponse);
110 });
111
112 // skipped: tests are disabled for the time being
113 test.skip('delete: request options instead of params are passed correctly', async () => {
114 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
115 await expect(
116 cloudflare.access.groups.delete(
117 'string',
118 '023e105f4ecef8ad9ca31a8372d0c353',
119 'f174e90a-fafe-4643-bbbc-4a0ed4fc8415',
120 { path: '/_stainless_unknown_path' },
121 ),
122 ).rejects.toThrow(Cloudflare.NotFoundError);
123 });
124
125 // skipped: tests are disabled for the time being
126 test.skip('accessGroupsCreateAnAccessGroup: only required params', async () => {
127 const responsePromise = cloudflare.access.groups.accessGroupsCreateAnAccessGroup(
128 'string',
129 '023e105f4ecef8ad9ca31a8372d0c353',
130 {
131 include: [
132 { email: { email: 'test@example.com' } },
133 { email: { email: 'test@example.com' } },
134 { email: { email: 'test@example.com' } },
135 ],
136 name: 'Allow devs',
137 },
138 );
139 const rawResponse = await responsePromise.asResponse();
140 expect(rawResponse).toBeInstanceOf(Response);
141 const response = await responsePromise;
142 expect(response).not.toBeInstanceOf(Response);
143 const dataAndResponse = await responsePromise.withResponse();
144 expect(dataAndResponse.data).toBe(response);
145 expect(dataAndResponse.response).toBe(rawResponse);
146 });
147
148 // skipped: tests are disabled for the time being
149 test.skip('accessGroupsCreateAnAccessGroup: required and optional params', async () => {
150 const response = await cloudflare.access.groups.accessGroupsCreateAnAccessGroup(
151 'string',
152 '023e105f4ecef8ad9ca31a8372d0c353',
153 {
154 include: [
155 { email: { email: 'test@example.com' } },
156 { email: { email: 'test@example.com' } },
157 { email: { email: 'test@example.com' } },
158 ],
159 name: 'Allow devs',
160 exclude: [
161 { email: { email: 'test@example.com' } },
162 { email: { email: 'test@example.com' } },
163 { email: { email: 'test@example.com' } },
164 ],
165 is_default: true,
166 require: [
167 { email: { email: 'test@example.com' } },
168 { email: { email: 'test@example.com' } },
169 { email: { email: 'test@example.com' } },
170 ],
171 },
172 );
173 });
174
175 // skipped: tests are disabled for the time being
176 test.skip('accessGroupsListAccessGroups', async () => {
177 const responsePromise = cloudflare.access.groups.accessGroupsListAccessGroups(
178 'string',
179 '023e105f4ecef8ad9ca31a8372d0c353',
180 );
181 const rawResponse = await responsePromise.asResponse();
182 expect(rawResponse).toBeInstanceOf(Response);
183 const response = await responsePromise;
184 expect(response).not.toBeInstanceOf(Response);
185 const dataAndResponse = await responsePromise.withResponse();
186 expect(dataAndResponse.data).toBe(response);
187 expect(dataAndResponse.response).toBe(rawResponse);
188 });
189
190 // skipped: tests are disabled for the time being
191 test.skip('accessGroupsListAccessGroups: request options instead of params are passed correctly', async () => {
192 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
193 await expect(
194 cloudflare.access.groups.accessGroupsListAccessGroups('string', '023e105f4ecef8ad9ca31a8372d0c353', {
195 path: '/_stainless_unknown_path',
196 }),
197 ).rejects.toThrow(Cloudflare.NotFoundError);
198 });
199});
200