Skip to content

Commit 1cc70e6

Browse files
committed
fix(e2e): use ocsRequest for openssl endpoint via ocs/v2.php prefix
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent cb7d7b4 commit 1cc70e6

1 file changed

Lines changed: 5 additions & 33 deletions

File tree

playwright/support/nc-provisioning.ts

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -56,38 +56,6 @@ async function ocsRequest(
5656
return JSON.parse(text) as OcsResponse
5757
}
5858

59-
async function libresignRequest(
60-
request: APIRequestContext,
61-
method: 'GET' | 'POST' | 'PUT' | 'DELETE',
62-
path: string,
63-
adminUser = process.env.NEXTCLOUD_ADMIN_USER ?? 'admin',
64-
adminPassword = process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin',
65-
jsonBody?: unknown,
66-
): Promise<unknown> {
67-
const url = `.${path}`
68-
const auth = 'Basic ' + Buffer.from(`${adminUser}:${adminPassword}`).toString('base64')
69-
const headers: Record<string, string> = {
70-
Accept: 'application/json',
71-
Authorization: auth,
72-
}
73-
if (jsonBody !== undefined) {
74-
headers['Content-Type'] = 'application/json'
75-
}
76-
const response = await request[method.toLowerCase() as 'get' | 'post' | 'put' | 'delete'](url, {
77-
headers,
78-
...(jsonBody !== undefined ? { data: JSON.stringify(jsonBody) } : {}),
79-
failOnStatusCode: false,
80-
})
81-
82-
if (!response.ok()) {
83-
throw new Error(`LibreSign API request failed: ${method} ${path}${response.status()} ${await response.text()}`)
84-
}
85-
86-
const text = await response.text()
87-
if (!text) return {}
88-
return JSON.parse(text)
89-
}
90-
9159
// ---------------------------------------------------------------------------
9260
// Users
9361
// ---------------------------------------------------------------------------
@@ -193,12 +161,16 @@ export async function configureOpenSsl(
193161
.filter(([, val]) => val !== undefined)
194162
.map(([id, value]) => ({ id, value }))
195163

196-
await libresignRequest(
164+
const result = await ocsRequest(
197165
request,
198166
'POST',
199167
'/apps/libresign/api/v1/admin/certificate/openssl',
200168
undefined,
201169
undefined,
170+
undefined,
202171
{ rootCert: { commonName, names: namesArray } },
203172
)
173+
if (result.ocs.meta.statuscode !== 200) {
174+
throw new Error(`Failed to configure OpenSSL: ${result.ocs.meta.message}`)
175+
}
204176
}

0 commit comments

Comments
 (0)