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/groups.test.ts

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