Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
MonPote committed Aug 27, 2024
1 parent 2a2fb5b commit e91edbc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/js/managementClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class UiFacingApiWrapper extends UiFacingApi {
public baseUrl: string,
public fetchFn: typeof window.fetch,
) {
super(configuration);
super(configuration, baseUrl, fetchFn);
}

setToken(token: string) {
Expand Down
28 changes: 28 additions & 0 deletions src/react/locations/__tests__/LocationList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { setupServer } from 'msw/node';
import { rest } from 'msw';
import {
ACCOUNT_ID,
getConfigOverlay,
getStorageConsumptionMetricsHandlers,
} from '../../../js/mock/managementClientMSWHandlers';
Expand All @@ -18,6 +19,7 @@ import {
} from '../../utils/testUtil';
import { INSTANCE_ID } from '../../actions/__tests__/utils/testUtil';
import { LocationsList } from '../LocationsList';
import { debug } from 'jest-preview';

const server = setupServer(
getConfigOverlay(TEST_API_BASE_URL, INSTANCE_ID),
Expand All @@ -29,6 +31,32 @@ const server = setupServer(
`${TEST_API_BASE_URL}/api/v1/instance/${INSTANCE_ID}/status`,
(req, res, ctx) => res(ctx.json({})),
),
rest.post(`${TEST_API_BASE_URL}/`, (req, res, ctx) => {
const params = new URLSearchParams(req.body);
console.log(req.body);

if (params.get('Action') === 'GetRolesForWebIdentity') {
const TEST_ACCOUNT = 'Test Account';
const TEST_ACCOUNT_CREATION_DATE = '2022-03-18T12:51:44Z';
return res(
ctx.json({
IsTruncated: false,
Accounts: [
{
Name: TEST_ACCOUNT,
CreationDate: TEST_ACCOUNT_CREATION_DATE,
Roles: [
{
Name: 'storage-manager-role',
Arn: `arn:aws:iam::${ACCOUNT_ID}:role/scality-internal/storage-manager-role`,
},
],
},
],
}),
);
}
}),
);

describe('LocationList', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/react/utils/testUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import userEvent from '@testing-library/user-event';
import { applyMiddleware, compose, createStore } from 'redux';
import ZenkoClient from '../../js/ZenkoClient';
import { VEEAM_FEATURE, XDM_FEATURE } from '../../js/config';
import { UiFacingApi } from '../../js/managementClient/api';
import { UiFacingApiWrapper } from '../../js/managementClient';
import { Configuration } from '../../js/managementClient/configuration';
import { _DataServiceRoleContext } from '../DataServiceRoleProvider';
import { _ManagementContext } from '../ManagementProvider';
Expand Down Expand Up @@ -143,7 +143,7 @@ const params = {
};
const iamClient = new IAMClient(TEST_API_BASE_URL);
iamClient.login(params);
export const TEST_MANAGEMENT_CLIENT = new UiFacingApi(
export const TEST_MANAGEMENT_CLIENT = new UiFacingApiWrapper(
new Configuration({
apiKey: 'token',
basePath: `${TEST_API_BASE_URL}/api/v1`,
Expand Down

0 comments on commit e91edbc

Please sign in to comment.