55
66import { expect , request , test , type APIRequestContext , type Page } from '@playwright/test'
77import { login } from '../support/nc-login'
8- import { configureOpenSsl , setAppConfig } from '../support/nc-provisioning'
8+ import {
9+ configureOpenSsl ,
10+ ensureGroupExists ,
11+ ensureSubadminOfGroup ,
12+ ensureUserExists ,
13+ ensureUserInGroup ,
14+ setAppConfig ,
15+ } from '../support/nc-provisioning'
916
1017const POLICY_KEY = 'signature_flow'
18+ const GROUP_ADMIN_USER = 'signature-flow-e2e-group-admin'
19+ const GROUP_ADMIN_PASSWORD = '123456'
20+ const GROUP_ADMIN_GROUP = 'signature-flow-e2e-group'
1121
1222test . setTimeout ( 120_000 )
23+ test . describe . configure ( { mode : 'serial' } )
1324
1425type OcsPolicyResponse = {
1526 ocs ?: {
@@ -31,7 +42,6 @@ async function createAuthenticatedRequestContext(authUser: string, authPassword:
3142 'OCS-ApiRequest' : 'true' ,
3243 Accept : 'application/json' ,
3344 Authorization : auth ,
34- 'Content-Type' : 'application/json' ,
3545 } ,
3646 } )
3747}
@@ -43,7 +53,13 @@ async function policyRequest(
4353 body ?: Record < string , unknown > ,
4454) {
4555 const response = method === 'POST'
46- ? await requestContext . post ( `./ocs/v2.php${ path } ` , { data : body , failOnStatusCode : false } )
56+ ? await requestContext . post ( `./ocs/v2.php${ path } ` , {
57+ data : body ,
58+ headers : {
59+ 'Content-Type' : 'application/json' ,
60+ } ,
61+ failOnStatusCode : false ,
62+ } )
4763 : await requestContext . delete ( `./ocs/v2.php${ path } ` , { failOnStatusCode : false } )
4864
4965 const text = await response . text ( )
@@ -108,7 +124,7 @@ test('request sidebar persists signature flow preference through policies endpoi
108124
109125 await login ( page . request , adminUser , adminPassword )
110126
111- await configureOpenSsl ( page . request , 'LibreSign Test' , {
127+ await configureOpenSsl ( adminRequest , 'LibreSign Test' , {
112128 C : 'BR' ,
113129 OU : [ 'Organization Unit' ] ,
114130 ST : 'Rio de Janeiro' ,
@@ -117,7 +133,7 @@ test('request sidebar persists signature flow preference through policies endpoi
117133 } )
118134
119135 await setAppConfig (
120- page . request ,
136+ adminRequest ,
121137 'libresign' ,
122138 'identify_methods' ,
123139 JSON . stringify ( [
@@ -167,12 +183,16 @@ for (const systemFlow of ['ordered_numeric', 'parallel'] as const) {
167183 test ( `fixed system ${ systemFlow } signature flow hides request toggles for groupadmin` , async ( { page } ) => {
168184 const adminUser = process . env . NEXTCLOUD_ADMIN_USER ?? 'admin'
169185 const adminPassword = process . env . NEXTCLOUD_ADMIN_PASSWORD ?? 'admin'
170- const groupAdminUser = 'groupadmin'
171- const groupAdminPassword = 'groupadmin'
186+
172187 const adminRequest = await createAuthenticatedRequestContext ( adminUser , adminPassword )
173- const groupAdminRequest = await createAuthenticatedRequestContext ( groupAdminUser , groupAdminPassword )
188+ const groupAdminRequest = await createAuthenticatedRequestContext ( GROUP_ADMIN_USER , GROUP_ADMIN_PASSWORD )
174189
175- await configureOpenSsl ( page . request , 'LibreSign Test' , {
190+ await ensureUserExists ( adminRequest , GROUP_ADMIN_USER , GROUP_ADMIN_PASSWORD )
191+ await ensureGroupExists ( adminRequest , GROUP_ADMIN_GROUP )
192+ await ensureUserInGroup ( adminRequest , GROUP_ADMIN_USER , GROUP_ADMIN_GROUP )
193+ await ensureSubadminOfGroup ( adminRequest , GROUP_ADMIN_USER , GROUP_ADMIN_GROUP )
194+
195+ await configureOpenSsl ( adminRequest , 'LibreSign Test' , {
176196 C : 'BR' ,
177197 OU : [ 'Organization Unit' ] ,
178198 ST : 'Rio de Janeiro' ,
@@ -181,7 +201,7 @@ for (const systemFlow of ['ordered_numeric', 'parallel'] as const) {
181201 } )
182202
183203 await setAppConfig (
184- page . request ,
204+ adminRequest ,
185205 'libresign' ,
186206 'identify_methods' ,
187207 JSON . stringify ( [
@@ -190,12 +210,20 @@ for (const systemFlow of ['ordered_numeric', 'parallel'] as const) {
190210 ] ) ,
191211 )
192212
213+ await setAppConfig (
214+ adminRequest ,
215+ 'libresign' ,
216+ 'groups_request_sign' ,
217+ JSON . stringify ( [ 'admin' , GROUP_ADMIN_GROUP ] ) ,
218+ )
219+
193220 try {
194221 await setSystemSignatureFlowPolicy ( adminRequest , systemFlow , false )
195222 await clearOwnPreference ( groupAdminRequest )
196223
197- await login ( page . request , groupAdminUser , groupAdminPassword )
198- await page . goto ( './apps/libresign' )
224+ await login ( page . request , GROUP_ADMIN_USER , GROUP_ADMIN_PASSWORD )
225+ await page . goto ( './apps/libresign/f/request' )
226+ await expect ( page . getByRole ( 'heading' , { name : 'Request Signatures' } ) ) . toBeVisible ( )
199227 await page . getByRole ( 'button' , { name : 'Upload from URL' } ) . click ( )
200228 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' )
201229 await page . getByRole ( 'button' , { name : 'Send' } ) . click ( )
@@ -240,6 +268,7 @@ for (const systemFlow of ['ordered_numeric', 'parallel'] as const) {
240268 } finally {
241269 await clearOwnPreference ( groupAdminRequest )
242270 await setSystemSignatureFlowPolicy ( adminRequest , 'none' , true )
271+ await setAppConfig ( adminRequest , 'libresign' , 'groups_request_sign' , JSON . stringify ( [ 'admin' ] ) )
243272 await Promise . all ( [
244273 adminRequest . dispose ( ) ,
245274 groupAdminRequest . dispose ( ) ,
0 commit comments