refactor(admin): remove auth migration reports
This commit is contained in:
@@ -1,112 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
const { get, post } = vi.hoisted(() => ({
|
||||
get: vi.fn(),
|
||||
post: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/api/client', () => ({
|
||||
apiClient: {
|
||||
get,
|
||||
post,
|
||||
},
|
||||
}))
|
||||
|
||||
import {
|
||||
bindUserAuthIdentity,
|
||||
getAuthIdentityMigrationReportSummary,
|
||||
listAuthIdentityMigrationReports,
|
||||
resolveAuthIdentityMigrationReport,
|
||||
} from '@/api/admin/users'
|
||||
|
||||
describe('admin users auth identity migration reports API', () => {
|
||||
beforeEach(() => {
|
||||
get.mockReset()
|
||||
post.mockReset()
|
||||
})
|
||||
|
||||
it('lists migration reports with pagination and report type filter', async () => {
|
||||
const response = {
|
||||
items: [],
|
||||
total: 0,
|
||||
page: 2,
|
||||
page_size: 10,
|
||||
pages: 0,
|
||||
}
|
||||
get.mockResolvedValue({ data: response })
|
||||
|
||||
const result = await listAuthIdentityMigrationReports({
|
||||
page: 2,
|
||||
pageSize: 10,
|
||||
reportType: 'oidc_synthetic_email_requires_manual_recovery',
|
||||
})
|
||||
|
||||
expect(get).toHaveBeenCalledWith('/admin/users/auth-identity-migration-reports', {
|
||||
params: {
|
||||
page: 2,
|
||||
page_size: 10,
|
||||
report_type: 'oidc_synthetic_email_requires_manual_recovery',
|
||||
},
|
||||
})
|
||||
expect(result).toBe(response)
|
||||
})
|
||||
|
||||
it('loads migration report summary', async () => {
|
||||
const response = {
|
||||
total: 2,
|
||||
open_total: 1,
|
||||
resolved_total: 1,
|
||||
by_type: {
|
||||
oidc_synthetic_email_requires_manual_recovery: 2,
|
||||
},
|
||||
}
|
||||
get.mockResolvedValue({ data: response })
|
||||
|
||||
const result = await getAuthIdentityMigrationReportSummary()
|
||||
|
||||
expect(get).toHaveBeenCalledWith('/admin/users/auth-identity-migration-reports/summary')
|
||||
expect(result).toBe(response)
|
||||
})
|
||||
|
||||
it('submits report resolution note', async () => {
|
||||
const response = {
|
||||
id: 7,
|
||||
resolution_note: 'resolved by admin',
|
||||
}
|
||||
post.mockResolvedValue({ data: response })
|
||||
|
||||
const result = await resolveAuthIdentityMigrationReport(7, 'resolved by admin')
|
||||
|
||||
expect(post).toHaveBeenCalledWith('/admin/users/auth-identity-migration-reports/7/resolve', {
|
||||
resolution_note: 'resolved by admin',
|
||||
})
|
||||
expect(result).toBe(response)
|
||||
})
|
||||
|
||||
it('binds a canonical auth identity to a user for remediation', async () => {
|
||||
const response = {
|
||||
identity_id: 11,
|
||||
provider_type: 'oidc',
|
||||
provider_key: 'https://issuer.example',
|
||||
provider_subject: 'subject-123',
|
||||
}
|
||||
post.mockResolvedValue({ data: response })
|
||||
|
||||
const result = await bindUserAuthIdentity(42, {
|
||||
provider_type: 'oidc',
|
||||
provider_key: 'https://issuer.example',
|
||||
provider_subject: 'subject-123',
|
||||
issuer: 'https://issuer.example',
|
||||
metadata: { source: 'migration-report' },
|
||||
})
|
||||
|
||||
expect(post).toHaveBeenCalledWith('/admin/users/42/auth-identities', {
|
||||
provider_type: 'oidc',
|
||||
provider_key: 'https://issuer.example',
|
||||
provider_subject: 'subject-123',
|
||||
issuer: 'https://issuer.example',
|
||||
metadata: { source: 'migration-report' },
|
||||
})
|
||||
expect(result).toBe(response)
|
||||
})
|
||||
})
|
||||
@@ -6,24 +6,6 @@
|
||||
import { apiClient } from '../client'
|
||||
import type { AdminUser, UpdateUserRequest, PaginatedResponse, ApiKey } from '@/types'
|
||||
|
||||
export interface AuthIdentityMigrationReport {
|
||||
id: number
|
||||
report_type: string
|
||||
report_key: string
|
||||
details: Record<string, unknown>
|
||||
created_at: string
|
||||
resolved_at?: string | null
|
||||
resolved_by_user_id?: number | null
|
||||
resolution_note?: string
|
||||
}
|
||||
|
||||
export interface AuthIdentityMigrationReportSummary {
|
||||
total: number
|
||||
open_total: number
|
||||
resolved_total: number
|
||||
by_type: Record<string, number>
|
||||
}
|
||||
|
||||
export interface AdminBindAuthIdentityChannelRequest {
|
||||
channel: string
|
||||
channel_app_id?: string
|
||||
@@ -48,12 +30,6 @@ export interface AdminBoundAuthIdentity {
|
||||
channel_id?: number | null
|
||||
}
|
||||
|
||||
export interface ListAuthIdentityMigrationReportsParams {
|
||||
page?: number
|
||||
pageSize?: number
|
||||
reportType?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* List all users with pagination
|
||||
* @param page - Page number (default: 1)
|
||||
@@ -296,42 +272,6 @@ export async function replaceGroup(
|
||||
return data
|
||||
}
|
||||
|
||||
export async function getAuthIdentityMigrationReportSummary(): Promise<AuthIdentityMigrationReportSummary> {
|
||||
const { data } = await apiClient.get<AuthIdentityMigrationReportSummary>(
|
||||
'/admin/users/auth-identity-migration-reports/summary'
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function listAuthIdentityMigrationReports(
|
||||
params: ListAuthIdentityMigrationReportsParams = {}
|
||||
): Promise<PaginatedResponse<AuthIdentityMigrationReport>> {
|
||||
const { data } = await apiClient.get<PaginatedResponse<AuthIdentityMigrationReport>>(
|
||||
'/admin/users/auth-identity-migration-reports',
|
||||
{
|
||||
params: {
|
||||
page: params.page ?? 1,
|
||||
page_size: params.pageSize ?? 20,
|
||||
report_type: params.reportType ?? ''
|
||||
}
|
||||
}
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function resolveAuthIdentityMigrationReport(
|
||||
id: number,
|
||||
resolutionNote: string
|
||||
): Promise<AuthIdentityMigrationReport> {
|
||||
const { data } = await apiClient.post<AuthIdentityMigrationReport>(
|
||||
`/admin/users/auth-identity-migration-reports/${id}/resolve`,
|
||||
{
|
||||
resolution_note: resolutionNote
|
||||
}
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function bindUserAuthIdentity(
|
||||
userId: number,
|
||||
input: AdminBindAuthIdentityRequest
|
||||
@@ -356,10 +296,7 @@ export const usersAPI = {
|
||||
getUserUsageStats,
|
||||
getUserBalanceHistory,
|
||||
replaceGroup,
|
||||
bindUserAuthIdentity,
|
||||
getAuthIdentityMigrationReportSummary,
|
||||
listAuthIdentityMigrationReports,
|
||||
resolveAuthIdentityMigrationReport
|
||||
bindUserAuthIdentity
|
||||
}
|
||||
|
||||
export default usersAPI
|
||||
|
||||
Reference in New Issue
Block a user