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

75lines · 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 keys', () => {
15 // skipped: tests are disabled for the time being
16 test.skip('list', async () => {
17 const responsePromise = cloudflare.access.keys.list('023e105f4ecef8ad9ca31a8372d0c353');
18 const rawResponse = await responsePromise.asResponse();
19 expect(rawResponse).toBeInstanceOf(Response);
20 const response = await responsePromise;
21 expect(response).not.toBeInstanceOf(Response);
22 const dataAndResponse = await responsePromise.withResponse();
23 expect(dataAndResponse.data).toBe(response);
24 expect(dataAndResponse.response).toBe(rawResponse);
25 });
26
27 // skipped: tests are disabled for the time being
28 test.skip('list: request options instead of params are passed correctly', async () => {
29 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
30 await expect(
31 cloudflare.access.keys.list('023e105f4ecef8ad9ca31a8372d0c353', { path: '/_stainless_unknown_path' }),
32 ).rejects.toThrow(Cloudflare.NotFoundError);
33 });
34
35 // skipped: tests are disabled for the time being
36 test.skip('replace: only required params', async () => {
37 const responsePromise = cloudflare.access.keys.replace('023e105f4ecef8ad9ca31a8372d0c353', {
38 key_rotation_interval_days: 30,
39 });
40 const rawResponse = await responsePromise.asResponse();
41 expect(rawResponse).toBeInstanceOf(Response);
42 const response = await responsePromise;
43 expect(response).not.toBeInstanceOf(Response);
44 const dataAndResponse = await responsePromise.withResponse();
45 expect(dataAndResponse.data).toBe(response);
46 expect(dataAndResponse.response).toBe(rawResponse);
47 });
48
49 // skipped: tests are disabled for the time being
50 test.skip('replace: required and optional params', async () => {
51 const response = await cloudflare.access.keys.replace('023e105f4ecef8ad9ca31a8372d0c353', {
52 key_rotation_interval_days: 30,
53 });
54 });
55
56 // skipped: tests are disabled for the time being
57 test.skip('rotate', async () => {
58 const responsePromise = cloudflare.access.keys.rotate('023e105f4ecef8ad9ca31a8372d0c353');
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('rotate: request options instead of params are passed correctly', async () => {
70 // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
71 await expect(
72 cloudflare.access.keys.rotate('023e105f4ecef8ad9ca31a8372d0c353', { path: '/_stainless_unknown_path' }),
73 ).rejects.toThrow(Cloudflare.NotFoundError);
74 });
75});
76