Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion web/src/pages/studio/SslSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const SslSettingsPage = () => {
certificateExpiry: '2025-12-31',
certificateIssuer: "Let's Encrypt",
});
const clientAuth = Form.useWatch('clientAuth', form) ?? sslConfig.clientAuth;
const { t } = useLang();
const { message } = App.useApp();

Expand Down Expand Up @@ -230,7 +231,7 @@ const SslSettingsPage = () => {
</Upload>
</Form.Item>

{form.getFieldValue('clientAuth') !== 'none' && (
{clientAuth !== 'none' && (
<>
<Divider orientation="left">{t('ssl.truststoreConfig')}</Divider>

Expand Down
26 changes: 25 additions & 1 deletion web/src/pages/studio/__tests__/SslSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { describe, it, expect, vi, beforeAll } from 'vitest';
import { render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { App } from 'antd';
import { LangProvider } from '../../../i18n/LangContext';
Expand Down Expand Up @@ -95,4 +95,28 @@ describe('SslSettings Page', () => {
expect(screen.getByText('KeyStore 路径')).toBeInTheDocument();
expect(screen.getByText('KeyStore 密码')).toBeInTheDocument();
});

it('should show TrustStore fields when client authentication is required', async () => {
const user = userEvent.setup();
renderWithProviders(<SslSettings />);

await user.click(screen.getByRole('switch'));
expect(screen.queryByText('TrustStore 配置')).not.toBeInTheDocument();

await user.click(screen.getByLabelText('客户端认证'));
await user.click(await screen.findByText('必需'));

expect(await screen.findByText('TrustStore 配置')).toBeInTheDocument();
expect(screen.getByText('TrustStore 类型')).toBeInTheDocument();
expect(screen.getByText('TrustStore 路径')).toBeInTheDocument();
expect(screen.getByText('TrustStore 密码')).toBeInTheDocument();

await user.click(screen.getByLabelText('客户端认证'));
await user.click(await screen.findByText('无'));
await waitFor(() => expect(screen.queryByText('TrustStore 配置')).not.toBeInTheDocument());

await user.click(screen.getByLabelText('客户端认证'));
await user.click(await screen.findByText('可选'));
expect(await screen.findByText('TrustStore 配置')).toBeInTheDocument();
});
});
Loading