Files
grafana/public/app/plugins/datasource/azuremonitor/components/AzureCredentialsForm.test.tsx
T
Andreas Christou 0908615b59 [v10.0.x] Azure: Add support for Workload Identity authentication (#75732)
* Azure: Add support for Workload Identity authentication (#75681)

* Update Azure Monitor

* Update Prometheus

* Update README

* Update docs/sources/datasources/azure-monitor/_index.md

Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com>

* Update docs/sources/datasources/azure-monitor/_index.md

Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com>

* Update docs/sources/datasources/azure-monitor/_index.md

Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com>

* Update docs/sources/datasources/azure-monitor/_index.md

Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com>

* README updates

* Fix prettier

* memoize options

---------

Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com>
Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com>
(cherry picked from commit 5796836662)

# Conflicts:
#	public/app/plugins/datasource/azuremonitor/components/AzureCredentialsForm.tsx
#	public/app/plugins/datasource/prometheus/configuration/AzureCredentialsForm.tsx

* Fix types
2023-10-11 13:42:27 +02:00

66 lines
1.8 KiB
TypeScript

import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import AzureCredentialsForm, { Props } from './AzureCredentialsForm';
const setup = (propsFunc?: (props: Props) => Props) => {
let props: Props = {
managedIdentityEnabled: false,
workloadIdentityEnabled: false,
credentials: {
authType: 'clientsecret',
azureCloud: 'azuremonitor',
tenantId: 'e7f3f661-a933-3h3f-0294-31c4f962ec48',
clientId: '34509fad-c0r9-45df-9e25-f1ee34af6900',
clientSecret: undefined,
},
azureCloudOptions: [
{ value: 'azuremonitor', label: 'Azure' },
{ value: 'govazuremonitor', label: 'Azure US Government' },
{ value: 'chinaazuremonitor', label: 'Azure China' },
],
onCredentialsChange: jest.fn(),
};
if (propsFunc) {
props = propsFunc(props);
}
return render(<AzureCredentialsForm {...props} />);
};
describe('Render', () => {
it('should render component', () => {
setup();
expect(screen.getByText('Azure Cloud')).toBeInTheDocument();
});
it('should disable azure monitor secret input', async () => {
setup((props) => ({
...props,
credentials: {
authType: 'clientsecret',
azureCloud: 'azuremonitor',
tenantId: 'e7f3f661-a933-3h3f-0294-31c4f962ec48',
clientId: '34509fad-c0r9-45df-9e25-f1ee34af6900',
clientSecret: Symbol(),
},
}));
await waitFor(() => screen.getByTestId('client-secret'));
expect(screen.getByTestId('client-secret')).toBeDisabled();
});
describe('when disabled', () => {
it('should disable inputs', async () => {
setup((props) => ({
...props,
disabled: true,
}));
await waitFor(() => screen.getByLabelText('Azure Cloud'));
expect(screen.getByLabelText('Azure Cloud')).toBeDisabled();
});
});
});