Skip to content

Commit 72e5cd7

Browse files
box-sdk-buildbox-sdk-build
andauthored
test: Add Shield Lists tests (box/box-codegen#720) (#626)
Co-authored-by: box-sdk-build <[email protected]>
1 parent a0307d0 commit 72e5cd7

File tree

4 files changed

+204
-25
lines changed

4 files changed

+204
-25
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "70390f5", "specHash": "630fc85", "version": "1.15.1" }
1+
{ "engineHash": "c17f683", "specHash": "630fc85", "version": "1.15.1" }

docs/shieldLists.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ This operation is performed by calling function `getShieldListsV2025R0`.
1515
See the endpoint docs at
1616
[API Reference](https://developer.box.com/reference/v2025.0/get-shield-lists/).
1717

18-
_Currently we don't have an example for calling `getShieldListsV2025R0` in integration tests_
18+
<!-- sample get_shield_lists_v2025.0 -->
19+
20+
```ts
21+
await client.shieldLists.getShieldListsV2025R0();
22+
```
1923

2024
### Arguments
2125

@@ -39,7 +43,18 @@ This operation is performed by calling function `createShieldListV2025R0`.
3943
See the endpoint docs at
4044
[API Reference](https://developer.box.com/reference/v2025.0/post-shield-lists/).
4145

42-
_Currently we don't have an example for calling `createShieldListV2025R0` in integration tests_
46+
<!-- sample post_shield_lists_v2025.0 -->
47+
48+
```ts
49+
await client.shieldLists.createShieldListV2025R0({
50+
name: shieldListCountryName,
51+
description: 'A list of things that are shielded',
52+
content: new ShieldListContentCountryV2025R0({
53+
type: 'country' as ShieldListContentCountryV2025R0TypeField,
54+
countryCodes: ['US' as string, 'PL' as string],
55+
}),
56+
} satisfies ShieldListsCreateV2025R0);
57+
```
4358

4459
### Arguments
4560

@@ -63,7 +78,11 @@ This operation is performed by calling function `getShieldListByIdV2025R0`.
6378
See the endpoint docs at
6479
[API Reference](https://developer.box.com/reference/v2025.0/get-shield-lists-id/).
6580

66-
_Currently we don't have an example for calling `getShieldListByIdV2025R0` in integration tests_
81+
<!-- sample get_shield_lists_id_v2025.0 -->
82+
83+
```ts
84+
await client.shieldLists.getShieldListByIdV2025R0(shieldListCountry.id);
85+
```
6786

6887
### Arguments
6988

@@ -87,7 +106,11 @@ This operation is performed by calling function `deleteShieldListByIdV2025R0`.
87106
See the endpoint docs at
88107
[API Reference](https://developer.box.com/reference/v2025.0/delete-shield-lists-id/).
89108

90-
_Currently we don't have an example for calling `deleteShieldListByIdV2025R0` in integration tests_
109+
<!-- sample delete_shield_lists_id_v2025.0 -->
110+
111+
```ts
112+
await client.shieldLists.deleteShieldListByIdV2025R0(shieldListCountry.id);
113+
```
91114

92115
### Arguments
93116

@@ -111,7 +134,18 @@ This operation is performed by calling function `updateShieldListByIdV2025R0`.
111134
See the endpoint docs at
112135
[API Reference](https://developer.box.com/reference/v2025.0/put-shield-lists-id/).
113136

114-
_Currently we don't have an example for calling `updateShieldListByIdV2025R0` in integration tests_
137+
<!-- sample put_shield_lists_id_v2025.0 -->
138+
139+
```ts
140+
await client.shieldLists.updateShieldListByIdV2025R0(shieldListCountry.id, {
141+
name: shieldListCountryName,
142+
description: 'Updated description',
143+
content: new ShieldListContentCountryV2025R0({
144+
type: 'country' as ShieldListContentCountryV2025R0TypeField,
145+
countryCodes: ['US' as string],
146+
}),
147+
} satisfies ShieldListsUpdateV2025R0);
148+
```
115149

116150
### Arguments
117151

package-lock.json

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import { serializeShieldListV2025R0 } from '../schemas/v2025R0/shieldListV2025R0.generated.js';
2+
import { deserializeShieldListV2025R0 } from '../schemas/v2025R0/shieldListV2025R0.generated.js';
3+
import { serializeShieldListsCreateV2025R0 } from '../schemas/v2025R0/shieldListsCreateV2025R0.generated.js';
4+
import { deserializeShieldListsCreateV2025R0 } from '../schemas/v2025R0/shieldListsCreateV2025R0.generated.js';
5+
import { serializeShieldListContentCountryV2025R0TypeField } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js';
6+
import { deserializeShieldListContentCountryV2025R0TypeField } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js';
7+
import { serializeShieldListContentDomainV2025R0TypeField } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js';
8+
import { deserializeShieldListContentDomainV2025R0TypeField } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js';
9+
import { serializeShieldListContentEmailV2025R0TypeField } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js';
10+
import { deserializeShieldListContentEmailV2025R0TypeField } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js';
11+
import { serializeShieldListContentIpV2025R0TypeField } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js';
12+
import { deserializeShieldListContentIpV2025R0TypeField } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js';
13+
import { serializeShieldListsV2025R0 } from '../schemas/v2025R0/shieldListsV2025R0.generated.js';
14+
import { deserializeShieldListsV2025R0 } from '../schemas/v2025R0/shieldListsV2025R0.generated.js';
15+
import { serializeShieldListsUpdateV2025R0 } from '../schemas/v2025R0/shieldListsUpdateV2025R0.generated.js';
16+
import { deserializeShieldListsUpdateV2025R0 } from '../schemas/v2025R0/shieldListsUpdateV2025R0.generated.js';
17+
import { serializeShieldListContentCountryV2025R0 } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js';
18+
import { deserializeShieldListContentCountryV2025R0 } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js';
19+
import { serializeShieldListContentDomainV2025R0 } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js';
20+
import { deserializeShieldListContentDomainV2025R0 } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js';
21+
import { serializeShieldListContentEmailV2025R0 } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js';
22+
import { deserializeShieldListContentEmailV2025R0 } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js';
23+
import { serializeShieldListContentIpV2025R0 } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js';
24+
import { deserializeShieldListContentIpV2025R0 } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js';
25+
import { BoxClient } from '../client.generated.js';
26+
import { ShieldListV2025R0 } from '../schemas/v2025R0/shieldListV2025R0.generated.js';
27+
import { ShieldListsCreateV2025R0 } from '../schemas/v2025R0/shieldListsCreateV2025R0.generated.js';
28+
import { ShieldListContentCountryV2025R0TypeField } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js';
29+
import { ShieldListContentDomainV2025R0TypeField } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js';
30+
import { ShieldListContentEmailV2025R0TypeField } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js';
31+
import { ShieldListContentIpV2025R0TypeField } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js';
32+
import { ShieldListsV2025R0 } from '../schemas/v2025R0/shieldListsV2025R0.generated.js';
33+
import { ShieldListsUpdateV2025R0 } from '../schemas/v2025R0/shieldListsUpdateV2025R0.generated.js';
34+
import { getUuid } from '../internal/utils.js';
35+
import { getEnvVar } from '../internal/utils.js';
36+
import { uploadNewFile } from './commons.generated.js';
37+
import { createNewFolder } from './commons.generated.js';
38+
import { getDefaultClientWithUserSubject } from './commons.generated.js';
39+
import { ShieldListContentCountryV2025R0 } from '../schemas/v2025R0/shieldListContentCountryV2025R0.generated.js';
40+
import { ShieldListContentDomainV2025R0 } from '../schemas/v2025R0/shieldListContentDomainV2025R0.generated.js';
41+
import { ShieldListContentEmailV2025R0 } from '../schemas/v2025R0/shieldListContentEmailV2025R0.generated.js';
42+
import { ShieldListContentIpV2025R0 } from '../schemas/v2025R0/shieldListContentIpV2025R0.generated.js';
43+
import { SerializedData } from '../serialization/json.js';
44+
import { sdIsEmpty } from '../serialization/json.js';
45+
import { sdIsBoolean } from '../serialization/json.js';
46+
import { sdIsNumber } from '../serialization/json.js';
47+
import { sdIsString } from '../serialization/json.js';
48+
import { sdIsList } from '../serialization/json.js';
49+
import { sdIsMap } from '../serialization/json.js';
50+
export const userId: string = getEnvVar('USER_ID');
51+
export const client: BoxClient = getDefaultClientWithUserSubject(userId);
52+
test('testCreateGetUpdateDeleteShieldList', async function testCreateGetUpdateDeleteShieldList(): Promise<any> {
53+
const shieldListCountryName: string = ''.concat(
54+
getUuid(),
55+
'shieldListCountry',
56+
) as string;
57+
const shieldListCountry: ShieldListV2025R0 =
58+
await client.shieldLists.createShieldListV2025R0({
59+
name: shieldListCountryName,
60+
description: 'A list of things that are shielded',
61+
content: new ShieldListContentCountryV2025R0({
62+
type: 'country' as ShieldListContentCountryV2025R0TypeField,
63+
countryCodes: ['US' as string, 'PL' as string],
64+
}),
65+
} satisfies ShieldListsCreateV2025R0);
66+
const shieldListContentDomainName: string = ''.concat(
67+
getUuid(),
68+
'shieldListContentDomain',
69+
) as string;
70+
const shieldListContentDomain: ShieldListV2025R0 =
71+
await client.shieldLists.createShieldListV2025R0({
72+
name: shieldListContentDomainName,
73+
description: 'A list of things that are shielded',
74+
content: new ShieldListContentDomainV2025R0({
75+
type: 'domain' as ShieldListContentDomainV2025R0TypeField,
76+
domains: ['box.com' as string, 'example.com' as string],
77+
}),
78+
} satisfies ShieldListsCreateV2025R0);
79+
const shieldListContentEmailName: string = ''.concat(
80+
getUuid(),
81+
'shieldListContentEmail',
82+
) as string;
83+
const shieldListContentEmail: ShieldListV2025R0 =
84+
await client.shieldLists.createShieldListV2025R0({
85+
name: shieldListContentEmailName,
86+
description: 'A list of things that are shielded',
87+
content: new ShieldListContentEmailV2025R0({
88+
type: 'email' as ShieldListContentEmailV2025R0TypeField,
89+
emailAddresses: [
90+
'[email protected]' as string,
91+
'[email protected]' as string,
92+
],
93+
}),
94+
} satisfies ShieldListsCreateV2025R0);
95+
const shieldListContentIpName: string = ''.concat(
96+
getUuid(),
97+
'shieldListContentIp',
98+
) as string;
99+
const shieldListContentIp: ShieldListV2025R0 =
100+
await client.shieldLists.createShieldListV2025R0({
101+
name: shieldListContentIpName,
102+
description: 'A list of things that are shielded',
103+
content: new ShieldListContentIpV2025R0({
104+
type: 'ip' as ShieldListContentIpV2025R0TypeField,
105+
ipAddresses: ['127.0.0.1' as string, '80.12.12.12/24' as string],
106+
}),
107+
} satisfies ShieldListsCreateV2025R0);
108+
const shieldLists: ShieldListsV2025R0 =
109+
await client.shieldLists.getShieldListsV2025R0();
110+
if (!(shieldLists.entries!.length > 0)) {
111+
throw new Error('Assertion failed');
112+
}
113+
const getShieldListCountry: ShieldListV2025R0 =
114+
await client.shieldLists.getShieldListByIdV2025R0(shieldListCountry.id);
115+
if (!(getShieldListCountry.name == shieldListCountryName)) {
116+
throw new Error('Assertion failed');
117+
}
118+
if (
119+
!(getShieldListCountry.description == 'A list of things that are shielded')
120+
) {
121+
throw new Error('Assertion failed');
122+
}
123+
await client.shieldLists.updateShieldListByIdV2025R0(shieldListCountry.id, {
124+
name: shieldListCountryName,
125+
description: 'Updated description',
126+
content: new ShieldListContentCountryV2025R0({
127+
type: 'country' as ShieldListContentCountryV2025R0TypeField,
128+
countryCodes: ['US' as string],
129+
}),
130+
} satisfies ShieldListsUpdateV2025R0);
131+
const getShieldListCountryUpdated: ShieldListV2025R0 =
132+
await client.shieldLists.getShieldListByIdV2025R0(shieldListCountry.id);
133+
if (!(getShieldListCountryUpdated.description == 'Updated description')) {
134+
throw new Error('Assertion failed');
135+
}
136+
await client.shieldLists.deleteShieldListByIdV2025R0(shieldListCountry.id);
137+
await client.shieldLists.deleteShieldListByIdV2025R0(
138+
shieldListContentDomain.id,
139+
);
140+
await client.shieldLists.deleteShieldListByIdV2025R0(
141+
shieldListContentEmail.id,
142+
);
143+
await client.shieldLists.deleteShieldListByIdV2025R0(shieldListContentIp.id);
144+
});
145+
export {};

0 commit comments

Comments
 (0)