feat: enhance type safety in security API and related tests

This commit is contained in:
GitHub Actions
2025-12-06 02:57:51 +00:00
parent 8e2ba14ae5
commit 8ef1e7cda0
12 changed files with 67 additions and 50 deletions

View File

@@ -162,7 +162,7 @@ describe('security API', () => {
describe('createDecision', () => {
it('should call POST /security/decisions with payload', async () => {
const payload = { ip: '1.2.3.4', duration: '4h', type: 'ban' }
const payload = { value: '1.2.3.4', duration: '4h', type: 'ban' }
const mockData = { success: true }
vi.mocked(client.post).mockResolvedValue({ data: mockData })

View File

@@ -55,13 +55,13 @@ export const generateBreakGlassToken = async () => {
return response.data
}
export const enableCerberus = async (payload?: any) => {
const response = await client.post('/security/enable', payload || {} as unknown) // Specify a more accurate type
export const enableCerberus = async (payload?: Record<string, unknown>) => {
const response = await client.post('/security/enable', payload || {})
return response.data
}
export const disableCerberus = async (payload?: any) => {
const response = await client.post('/security/disable', payload || {} as unknown) // Specify a more accurate type
export const disableCerberus = async (payload?: Record<string, unknown>) => {
const response = await client.post('/security/disable', payload || {})
return response.data
}
@@ -70,7 +70,14 @@ export const getDecisions = async (limit = 50) => {
return response.data
}
export const createDecision = async (payload: any) => {
export interface CreateDecisionPayload {
type: string
value: string
duration: string
reason?: string
}
export const createDecision = async (payload: CreateDecisionPayload) => {
const response = await client.post('/security/decisions', payload)
return response.data
}