Skip to content

Commit c686aa8

Browse files
feat: [UIE-9244] - Iam Delegation mock data (linode#12914)
* factories * seeds and handlers * wrap up seeds and handlers * better handling before seeding * load seeding * fixes and cleanup * Added changeset: IAM delegation mock data
1 parent 1648552 commit c686aa8

File tree

15 files changed

+608
-43
lines changed

15 files changed

+608
-43
lines changed

packages/api-v4/src/iam/delegation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const getChildAccountDelegates = ({
4747
euuid,
4848
params,
4949
}: GetChildAccountDelegatesParams) =>
50-
Request<Page<string[]>>(
50+
Request<Page<string>>(
5151
setURL(
5252
`${BETA_API_ROOT}/iam/delegation/child-accounts/${encodeURIComponent(euuid)}/users`,
5353
),
@@ -59,7 +59,7 @@ export const updateChildAccountDelegates = ({
5959
euuid,
6060
data,
6161
}: UpdateChildAccountDelegatesParams) =>
62-
Request<Page<string[]>>(
62+
Request<Page<string>>(
6363
setURL(
6464
`${BETA_API_ROOT}/iam/delegation/child-accounts/${encodeURIComponent(euuid)}/users`,
6565
),
@@ -87,7 +87,7 @@ export const getDelegatedChildAccount = ({ euuid }: { euuid: string }) =>
8787
export const generateChildAccountToken = ({ euuid }: { euuid: string }) =>
8888
Request<Token>(
8989
setURL(
90-
`${BETA_API_ROOT}/iam/delegation/child-accounts/child-accounts/${encodeURIComponent(euuid)}/token`,
90+
`${BETA_API_ROOT}/iam/delegation/profile/child-accounts/${encodeURIComponent(euuid)}/token`,
9191
),
9292
setMethod('POST'),
9393
setData(euuid),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Added
3+
---
4+
5+
IAM delegation mock data ([#12914](https://github.com/linode/manager/pull/12914))

packages/manager/src/dev-tools/load.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ export async function loadDevTools() {
7979
// Merge the contexts
8080
const mergedContext: MockState = {
8181
...initialContext,
82+
childAccounts: [
83+
...initialContext.childAccounts,
84+
...(seedContext?.childAccounts || []),
85+
],
86+
delegations: [
87+
...initialContext.delegations,
88+
...(seedContext?.delegations || []),
89+
],
8290
domains: [...initialContext.domains, ...(seedContext?.domains || [])],
8391
eventQueue: [
8492
...initialContext.eventQueue,

packages/manager/src/mocks/mockState.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ export const getStateSeederGroups = (
2222
};
2323

2424
export const emptyStore: MockState = {
25+
childAccounts: [],
2526
cloudnats: [],
2627
configInterfaces: [],
28+
delegations: [],
2729
destinations: [],
2830
domainRecords: [],
2931
domains: [],

packages/manager/src/mocks/presets/baseline/crud.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
import { linodeCrudPreset } from 'src/mocks/presets/crud/linodes';
77

88
import { cloudNATCrudPreset } from '../crud/cloudnats';
9+
import { childAccountsCrudPreset } from '../crud/delegation';
910
import { domainCrudPreset } from '../crud/domains';
1011
import { entityCrudPreset } from '../crud/entities';
1112
import { firewallCrudPreset } from '../crud/firewalls';
@@ -22,6 +23,7 @@ import type { MockPresetBaseline } from 'src/mocks/types';
2223
export const baselineCrudPreset: MockPresetBaseline = {
2324
group: { id: 'General' },
2425
handlers: [
26+
...childAccountsCrudPreset.handlers,
2527
...cloudNATCrudPreset.handlers,
2628
...domainCrudPreset.handlers,
2729
...deliveryCrudPreset.handlers,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
childAccountDelegates,
3+
defaultDelegationAccess,
4+
delegatedChildAccounts,
5+
generateChildAccountToken,
6+
getChildAccounts,
7+
getDelegatedChildAccountsForUser,
8+
} from 'src/mocks/presets/crud/handlers/delegation';
9+
10+
import type { MockPresetCrud } from 'src/mocks/types';
11+
12+
export const childAccountsCrudPreset: MockPresetCrud = {
13+
group: { id: 'Child Accounts' },
14+
handlers: [
15+
getChildAccounts,
16+
getDelegatedChildAccountsForUser,
17+
childAccountDelegates,
18+
delegatedChildAccounts,
19+
generateChildAccountToken,
20+
defaultDelegationAccess,
21+
],
22+
id: 'child-accounts:crud',
23+
label: 'Child Accounts CRUD',
24+
};

0 commit comments

Comments
 (0)