Skip to content

Commit 621de23

Browse files
authored
Merge pull request #7111 from LibreSign/backport/7044/stable32
[stable32] test: sign with pkcs12 certificate
2 parents af0f68c + bd8567a commit 621de23

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { expect, test } from '@playwright/test'
7+
import { login } from '../support/nc-login'
8+
import { configureOpenSsl, deleteUserPfx, setAppConfig } from '../support/nc-provisioning'
9+
10+
test('sign herself with pkcs12 certificate', async ({ page }) => {
11+
const adminUser = process.env.NEXTCLOUD_ADMIN_USER ?? 'admin'
12+
const adminPassword = process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin'
13+
14+
await login(page.request, adminUser, adminPassword)
15+
16+
await configureOpenSsl(page.request, 'LibreSign Test', {
17+
C: 'BR',
18+
OU: ['Organization Unit'],
19+
ST: 'Rio de Janeiro',
20+
O: 'LibreSign',
21+
L: 'Rio de Janeiro',
22+
})
23+
24+
await setAppConfig(
25+
page.request,
26+
'libresign',
27+
'identify_methods',
28+
JSON.stringify([
29+
{ name: 'account', enabled: true, mandatory: true, signatureMethods: { password: { enabled: true } } },
30+
{ name: 'email', enabled: false, mandatory: false },
31+
]),
32+
)
33+
34+
// Ensure the user has no existing certificate so the test always goes
35+
// through the "create password" flow.
36+
await deleteUserPfx(page.request, adminUser, adminPassword)
37+
38+
await page.goto('./apps/libresign')
39+
40+
await page.getByRole('button', { name: 'Upload from URL' }).click()
41+
await page.getByRole('textbox', { name: 'URL of a PDF file' }).fill('https://raw.githubusercontent.com/LibreSign/libresign/main/tests/php/fixtures/pdfs/small_valid.pdf')
42+
await page.getByRole('button', { name: 'Send' }).click()
43+
await page.getByRole('button', { name: 'Add signer' }).click()
44+
await page.getByPlaceholder('Account').fill(adminUser)
45+
await page.getByText('[email protected]').click()
46+
await page.getByRole('button', { name: 'Save' }).click()
47+
await page.getByRole('button', { name: 'Request signatures' }).click()
48+
await page.getByRole('button', { name: 'Send' }).click()
49+
await page.getByRole('button', { name: 'Sign document' }).click()
50+
await page.getByRole('button', { name: 'Define a password and sign the document.' }).click()
51+
await page.getByLabel('Enter a password').fill('Password1234')
52+
await page.getByRole('button', { name: 'Confirm' }).click()
53+
await page.getByRole('button', { name: 'Sign the document.' }).click()
54+
await page.getByLabel('Signature password').fill('Password1234')
55+
await page.getByRole('button', { name: 'Sign document' }).click()
56+
await page.waitForURL('**/validation/**')
57+
await expect(page.getByText('This document is valid')).toBeVisible()
58+
await page.getByRole('button', { name: 'Expand details' }).click()
59+
await page.getByRole('button', { name: 'Expand validation status', exact: true }).click()
60+
await expect(page.getByRole('link', { name: 'Document integrity verified' })).toBeVisible()
61+
await page.getByRole('button', { name: 'Expand document certification', exact: true }).click()
62+
await expect(page.getByRole('link', { name: 'Document has not been' })).toBeVisible()
63+
})

playwright/support/nc-provisioning.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ type OpenSslCertNames = {
143143
L?: string
144144
}
145145

146+
/**
147+
* Deletes the PFX certificate of a user so the next signing attempt
148+
* starts without an existing certificate.
149+
* Equivalent to: DELETE /ocs/v2.php/apps/libresign/api/v1/account/pfx
150+
*/
151+
export async function deleteUserPfx(
152+
request: APIRequestContext,
153+
userId: string,
154+
password: string,
155+
): Promise<void> {
156+
await ocsRequest(request, 'DELETE', '/apps/libresign/api/v1/account/pfx', userId, password)
157+
}
158+
146159
/**
147160
* Configures the OpenSSL certificate engine.
148161
* Equivalent to: `occ libresign:configure:openssl --cn=... --c=... ...`

0 commit comments

Comments
 (0)