cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
tests/api-resources/access/groups.test.ts
176lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. |
| 2 | |
| 3 | import Cloudflare from 'cloudflare'; |
| 4 | import { Response } from 'node-fetch'; |
| 5 | |
| 6 | const cloudflare = new Cloudflare({ |
| 7 | apiKey: '144c9defac04969c7bfad8efaa8ea194', |
| 8 | apiEmail: 'user@example.com', |
| 9 | apiToken: 'Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY', |
| 10 | userServiceKey: |
| 11 | 'v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719', |
| 12 | baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', |
| 13 | }); |
| 14 | |
| 15 | describe('resource groups', () => { |
| 16 | // skipped: tests are disabled for the time being |
| 17 | test.skip('create: only required params', async () => { |
| 18 | const responsePromise = cloudflare.access.groups.create({ |
| 19 | account_id: 'string', |
| 20 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 21 | include: [ |
| 22 | { email: { email: 'test@example.com' } }, |
| 23 | { email: { email: 'test@example.com' } }, |
| 24 | { email: { email: 'test@example.com' } }, |
| 25 | ], |
| 26 | name: 'Allow devs', |
| 27 | }); |
| 28 | const rawResponse = await responsePromise.asResponse(); |
| 29 | expect(rawResponse).toBeInstanceOf(Response); |
| 30 | const response = await responsePromise; |
| 31 | expect(response).not.toBeInstanceOf(Response); |
| 32 | const dataAndResponse = await responsePromise.withResponse(); |
| 33 | expect(dataAndResponse.data).toBe(response); |
| 34 | expect(dataAndResponse.response).toBe(rawResponse); |
| 35 | }); |
| 36 | |
| 37 | // skipped: tests are disabled for the time being |
| 38 | test.skip('create: required and optional params', async () => { |
| 39 | const response = await cloudflare.access.groups.create({ |
| 40 | account_id: 'string', |
| 41 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 42 | include: [ |
| 43 | { email: { email: 'test@example.com' } }, |
| 44 | { email: { email: 'test@example.com' } }, |
| 45 | { email: { email: 'test@example.com' } }, |
| 46 | ], |
| 47 | name: 'Allow devs', |
| 48 | exclude: [ |
| 49 | { email: { email: 'test@example.com' } }, |
| 50 | { email: { email: 'test@example.com' } }, |
| 51 | { email: { email: 'test@example.com' } }, |
| 52 | ], |
| 53 | is_default: true, |
| 54 | require: [ |
| 55 | { email: { email: 'test@example.com' } }, |
| 56 | { email: { email: 'test@example.com' } }, |
| 57 | { email: { email: 'test@example.com' } }, |
| 58 | ], |
| 59 | }); |
| 60 | }); |
| 61 | |
| 62 | // skipped: tests are disabled for the time being |
| 63 | test.skip('update: only required params', async () => { |
| 64 | const responsePromise = cloudflare.access.groups.update('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { |
| 65 | account_id: 'string', |
| 66 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 67 | include: [ |
| 68 | { email: { email: 'test@example.com' } }, |
| 69 | { email: { email: 'test@example.com' } }, |
| 70 | { email: { email: 'test@example.com' } }, |
| 71 | ], |
| 72 | name: 'Allow devs', |
| 73 | }); |
| 74 | const rawResponse = await responsePromise.asResponse(); |
| 75 | expect(rawResponse).toBeInstanceOf(Response); |
| 76 | const response = await responsePromise; |
| 77 | expect(response).not.toBeInstanceOf(Response); |
| 78 | const dataAndResponse = await responsePromise.withResponse(); |
| 79 | expect(dataAndResponse.data).toBe(response); |
| 80 | expect(dataAndResponse.response).toBe(rawResponse); |
| 81 | }); |
| 82 | |
| 83 | // skipped: tests are disabled for the time being |
| 84 | test.skip('update: required and optional params', async () => { |
| 85 | const response = await cloudflare.access.groups.update('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { |
| 86 | account_id: 'string', |
| 87 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 88 | include: [ |
| 89 | { email: { email: 'test@example.com' } }, |
| 90 | { email: { email: 'test@example.com' } }, |
| 91 | { email: { email: 'test@example.com' } }, |
| 92 | ], |
| 93 | name: 'Allow devs', |
| 94 | exclude: [ |
| 95 | { email: { email: 'test@example.com' } }, |
| 96 | { email: { email: 'test@example.com' } }, |
| 97 | { email: { email: 'test@example.com' } }, |
| 98 | ], |
| 99 | is_default: true, |
| 100 | require: [ |
| 101 | { email: { email: 'test@example.com' } }, |
| 102 | { email: { email: 'test@example.com' } }, |
| 103 | { email: { email: 'test@example.com' } }, |
| 104 | ], |
| 105 | }); |
| 106 | }); |
| 107 | |
| 108 | // skipped: tests are disabled for the time being |
| 109 | test.skip('list: only required params', async () => { |
| 110 | const responsePromise = cloudflare.access.groups.list({ |
| 111 | account_id: 'string', |
| 112 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 113 | }); |
| 114 | const rawResponse = await responsePromise.asResponse(); |
| 115 | expect(rawResponse).toBeInstanceOf(Response); |
| 116 | const response = await responsePromise; |
| 117 | expect(response).not.toBeInstanceOf(Response); |
| 118 | const dataAndResponse = await responsePromise.withResponse(); |
| 119 | expect(dataAndResponse.data).toBe(response); |
| 120 | expect(dataAndResponse.response).toBe(rawResponse); |
| 121 | }); |
| 122 | |
| 123 | // skipped: tests are disabled for the time being |
| 124 | test.skip('list: required and optional params', async () => { |
| 125 | const response = await cloudflare.access.groups.list({ |
| 126 | account_id: 'string', |
| 127 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 128 | }); |
| 129 | }); |
| 130 | |
| 131 | // skipped: tests are disabled for the time being |
| 132 | test.skip('delete: only required params', async () => { |
| 133 | const responsePromise = cloudflare.access.groups.delete('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { |
| 134 | account_id: 'string', |
| 135 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 136 | }); |
| 137 | const rawResponse = await responsePromise.asResponse(); |
| 138 | expect(rawResponse).toBeInstanceOf(Response); |
| 139 | const response = await responsePromise; |
| 140 | expect(response).not.toBeInstanceOf(Response); |
| 141 | const dataAndResponse = await responsePromise.withResponse(); |
| 142 | expect(dataAndResponse.data).toBe(response); |
| 143 | expect(dataAndResponse.response).toBe(rawResponse); |
| 144 | }); |
| 145 | |
| 146 | // skipped: tests are disabled for the time being |
| 147 | test.skip('delete: required and optional params', async () => { |
| 148 | const response = await cloudflare.access.groups.delete('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { |
| 149 | account_id: 'string', |
| 150 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 151 | }); |
| 152 | }); |
| 153 | |
| 154 | // skipped: tests are disabled for the time being |
| 155 | test.skip('get: only required params', async () => { |
| 156 | const responsePromise = cloudflare.access.groups.get('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { |
| 157 | account_id: 'string', |
| 158 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 159 | }); |
| 160 | const rawResponse = await responsePromise.asResponse(); |
| 161 | expect(rawResponse).toBeInstanceOf(Response); |
| 162 | const response = await responsePromise; |
| 163 | expect(response).not.toBeInstanceOf(Response); |
| 164 | const dataAndResponse = await responsePromise.withResponse(); |
| 165 | expect(dataAndResponse.data).toBe(response); |
| 166 | expect(dataAndResponse.response).toBe(rawResponse); |
| 167 | }); |
| 168 | |
| 169 | // skipped: tests are disabled for the time being |
| 170 | test.skip('get: required and optional params', async () => { |
| 171 | const response = await cloudflare.access.groups.get('f174e90a-fafe-4643-bbbc-4a0ed4fc8415', { |
| 172 | account_id: 'string', |
| 173 | zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 174 | }); |
| 175 | }); |
| 176 | }); |
| 177 | |