feat(domain): virus-scan and PDF-check uploaded diplomas with ClamAV (closes #192) #194
@@ -1,5 +1,6 @@
|
||||
import { signal } from '@angular/core';
|
||||
import { fireEvent, render, screen } from '@testing-library/angular';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { AuthService } from 'auth';
|
||||
import { BffApiV1Service } from 'api-client';
|
||||
@@ -142,6 +143,28 @@ describe('RegistrationPage', () => {
|
||||
expect(screen.getByRole('button', { name: /documenten aanleveren/i })).toBeTruthy();
|
||||
});
|
||||
|
||||
// S-29 (#192): the domain refuses an infected or non-PDF file (422 + reason) or cannot scan it (503);
|
||||
// the citizen is told which, so they know whether to pick another file or simply retry.
|
||||
it.each([
|
||||
[422, { reason: 'infected' }, /virus/i],
|
||||
[422, { reason: 'not-a-pdf' }, /geen PDF/i],
|
||||
[503, null, /tijdelijk/i],
|
||||
])('explains a refused diploma upload (%i %o)', async (status, error, message) => {
|
||||
const { providers: p } = providers(
|
||||
vi.fn().mockReturnValue(of({ registrationId: 'reg-9', status: 'Ingediend' })),
|
||||
vi.fn().mockReturnValue(of(undefined)),
|
||||
vi.fn().mockReturnValue(throwError(() => new HttpErrorResponse({ status, error }))),
|
||||
);
|
||||
await render(RegistrationPage, { providers: p });
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /indienen/i }));
|
||||
await screen.findByText(/ontvangen/i);
|
||||
fireEvent.change(screen.getByLabelText(/diploma/i), { target: { files: [diploma()] } });
|
||||
fireEvent.click(await screen.findByRole('button', { name: /documenten aanleveren/i }));
|
||||
|
||||
expect((await screen.findByRole('alert')).textContent).toMatch(message);
|
||||
});
|
||||
|
||||
it('surfaces a withdraw failure and keeps the action available', async () => {
|
||||
const { providers: p } = providers(
|
||||
vi.fn().mockReturnValue(of({ registrationId: 'reg-9', status: 'Ingediend' })),
|
||||
|
||||
Reference in New Issue
Block a user