From 556242db4a023c3538e1c40fee707daac5897b84 Mon Sep 17 00:00:00 2001 From: Luis Amorim Date: Tue, 10 Nov 2026 10:51:13 -0300 Subject: [PATCH 1/4] test(sdk): evaluate generated typescript axios client Signed-off-by: Luis Amorim --- REUSE.toml | 2 + tests/sdk-generation/README.md | 45 ++ tests/sdk-generation/REPORT.md | 163 +++++ tests/sdk-generation/anyof-negative.ts | 10 + tests/sdk-generation/generate.sh | 13 + tests/sdk-generation/inventory.cjs | 46 ++ tests/sdk-generation/inventory.md | 101 +++ tests/sdk-generation/live.ts | 62 ++ tests/sdk-generation/package-lock.json | 873 +++++++++++++++++++++++++ tests/sdk-generation/package.json | 20 + tests/sdk-generation/setup.sh | 10 + tests/sdk-generation/transport.ts | 68 ++ tests/sdk-generation/types.ts | 30 + 13 files changed, 1443 insertions(+) create mode 100644 tests/sdk-generation/README.md create mode 100644 tests/sdk-generation/REPORT.md create mode 100644 tests/sdk-generation/anyof-negative.ts create mode 100755 tests/sdk-generation/generate.sh create mode 100644 tests/sdk-generation/inventory.cjs create mode 100644 tests/sdk-generation/inventory.md create mode 100644 tests/sdk-generation/live.ts create mode 100644 tests/sdk-generation/package-lock.json create mode 100644 tests/sdk-generation/package.json create mode 100755 tests/sdk-generation/setup.sh create mode 100644 tests/sdk-generation/transport.ts create mode 100644 tests/sdk-generation/types.ts diff --git a/REUSE.toml b/REUSE.toml index c6e2cb5919..6a1b4ffad8 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -42,6 +42,8 @@ path = [ "openapi-full.json", "openapi.json", "package-lock.json", + "tests/sdk-generation/package.json", + "tests/sdk-generation/package-lock.json", "package.json", "patches.json", "patches.lock.json", diff --git a/tests/sdk-generation/README.md b/tests/sdk-generation/README.md new file mode 100644 index 0000000000..4e79926aa0 --- /dev/null +++ b/tests/sdk-generation/README.md @@ -0,0 +1,45 @@ + + +# TypeScript Axios generation evaluation + +This harness evaluates disposable generated code; it is not an SDK. Docker, +Node.js and npm are required. From the repository root: + +```sh +tests/sdk-generation/setup.sh +tests/sdk-generation/generate.sh +tests/sdk-generation/generate.sh build/sdk-generation/repeat +diff -qr build/sdk-generation/typescript build/sdk-generation/repeat +npm run compile --prefix tests/sdk-generation +npm test --prefix tests/sdk-generation +npm run test:anyof --prefix tests/sdk-generation +``` + +The last command currently **fails intentionally**: TS2578 demonstrates that +an invalid array is accepted by the generated `EffectivePolicyValue`. Any other +failure must be investigated separately. `npm test` checks transport and writes +the generated operation inventory to `build/sdk-generation/inventory.md`. +Compare that inventory with the checked-in evaluation snapshot when changing the +specification. This does not prove every operation's runtime serialization. + +The generator validates the full specification first and never uses +`--skip-validate-spec`. Its Docker image digest pins OpenAPI Generator 7.15.0; +`useSingleRequestParameter=true` is enabled. npm dependencies are pinned by +`package-lock.json`. Use fresh output directories: the generator does not remove +stale files. Generated code stays under ignored `build/` and must not be edited. +See [REPORT.md](REPORT.md) and [inventory.md](inventory.md) for results. + +## Optional live Nextcloud check + +After generation and setup, set `SDK_TEST_URL` to the local HTTPS Nextcloud +base URL, and `SDK_TEST_USER` / `SDK_TEST_PASSWORD` to a local administrator's +credentials, then run `npm run test:live --prefix tests/sdk-generation`. Do not +store credentials in files or commit them. The live test performs read-only +requests plus one deliberately invalid authentication attempt. It requires a +local instance and is not part of the deterministic harness. It accepts only +localhost hostnames and disables TLS certificate verification for the local +development proxy; do not use it with remote systems. The PDF check reports a +404 as unverified when no certificate policy PDF is configured. diff --git a/tests/sdk-generation/REPORT.md b/tests/sdk-generation/REPORT.md new file mode 100644 index 0000000000..19777c4da2 --- /dev/null +++ b/tests/sdk-generation/REPORT.md @@ -0,0 +1,163 @@ + + +# Compatibility evaluation + +## Decision: No-Go + +OpenAPI Generator 7.15.0's `typescript-axios` output in the evaluated +configuration is not a sufficiently faithful SDK foundation: critical `anyOf` +models are incorrect. This does not prevent planning an SDK using a different +generator or a reviewed mitigation. Multipart omissions are separate gaps in +the input contract, not evidence that the generator mishandles declared uploads. +This decision does not assert that every operation is broken, nor does it +change backend authorization. + +## Input and reproducibility + +- Application revision: `b02d0b82e3abe346085c8bfe059e7ca4bf8f6bfd`. +- `openapi-full.json` SHA-256: `2501bc11fcee0545dfb703a28d93018a80e62f6e14ba81bae549d1b130de9243`. +- Generator: Docker image `openapitools/openapi-generator-cli` 7.15.0, + SHA-256 `509f01c3c7eee9d1ad286506a7b6aa4624a95b410be9a238a306d209e900621f`; + generator `typescript-axios`, `useSingleRequestParameter=true`. +- TypeScript 5.8.3, Axios 1.9.0, tsx 4.19.4, Node 24.22.2; exact npm + dependencies and transitives are in the lockfile. +- The commands in README were run, except that the first two output directories + were generated before the setup script was written with equivalent pinned + tooling. A third generation used the final script. Validation succeeded with + warnings for unused `Capabilities` and `PublicCapabilities` models. A full + recursive diff of the first and third output directories was empty, without + excluding metadata. Generated code was not edited. +- Warm local timings: validation and generation together 4.40 seconds; + compilation 1.20 seconds; transport and inventory 0.56 seconds. These are + wall-clock observations from one machine, excluding npm installation and image + download, not CI benchmarks. No recurring CI job is proposed without + measuring cold-start cost and benefit. + +## Inventory and models + +The input contains 90 operations, rather than the 88 in the issue. The +[inventory](inventory.md) matches HTTP method and path to the generator's +actual documentation and checks for a corresponding public class method in the +TypeScript AST: 90 matched, no duplicate input operation IDs, missing methods or +wrong functional class among the ten approved tags. This is a presence/grouping +check, not an exhaustive signature or runtime-serialization audit. In +particular, the generated Markdown examples use positional arguments despite +`useSingleRequestParameter=true`; use the actual class signatures instead. + +Generated code and positive/negative checks in `types.ts` compile under strict +TypeScript (with `skipLibCheck`); `NewFile.nodeId` accepts number/string and +rejects boolean; `SignerDetail` includes required inherited and local fields; +nullable/optional and enum examples reject invalid values. These tests sample +contracts and do not validate numerical minima or runtime JSON. + +`EffectivePolicyValue` is generated as an empty interface even though the +schema is a nullable `anyOf` of boolean, number, string and object. An invalid +array is accepted. `npm run test:anyof` fails with TS2578 (unused +`@ts-expect-error`), proving the negative test is not enforced. This is a +critical type-fidelity failure, not a passing acceptance test. No generated +code was patched to hide it. + +## Transport + +Tests invoke generated class methods through a synthetic Axios adapter, with +synthetic credentials and data. They check: + +- `IdentityApi.accountMe`: GET, versioned OCS URL, explicit + `OCS-APIRequest: true`, injected basic auth and typed `ocs.data` envelope. +- `PoliciesApi.policyGetSystem`: encoded path parameter, bearer configuration, + and a simulated HTTP 403 rejection. Authorization remains the server's job; + no server authorization was tested. The encoded sample exercises serialization + and is not claimed to satisfy the policy key's server-side pattern. +- `RequestsApi.requestSignatureRequestSignature`: JSON body and content type. +- `CertificatesApi.certificatePolicyGetCertificatePolicy`: non-OCS path and + explicit `responseType: arraybuffer`, with synthetic binary data. +- Root and `/nextcloud` URLs, including an injected Axios instance with its own + `baseURL`. A supplied instance's `baseURL` takes precedence over the generated + configuration's base path. An Axios-compatible injected instance is exercised; + the real `@nextcloud/axios` package and a live Nextcloud server were not tested. + +The generated client does not unwrap `ocs.data`, and the caller must supply the +required OCS header argument. An Axios adapter must perform status settlement; +this harness simulates it rather than claiming to test a real network adapter. +HTTP 200 containing an OCS-level error is not automatically interpreted as an +error by this test. The PDF return is generated as `File`, while the explicit +arraybuffer transport yields bytes at runtime; the caller must choose and +reconcile response handling. No automatic binary response type was observed. + +## Multipart limitations + +The harness checks the generated signatures and requests, and the controller +source supplies the expected upload names: + +| operationId | Runtime upload | Generated behavior | +| --- | --- | --- | +| `account-upload-pfx` | `file` in `AccountController::uploadPfx` | No typed file parameter or request body; generated call sends no body. | +| `file-save` | `file` or `files` in `FileController::prepareFilesForSaving` | Typed JSON body supports `NewFile` representations, but exposes no typed multipart upload. | +| `admin-signature-background-save` | `image` in `AdminController::signatureBackgroundSave` | No typed image parameter or request body; generated call sends no body. | + +Generic Axios options may allow a caller to handcraft a request, but that is not +verified typed multipart support. An official SDK or frontend migration would +need a reviewed contract/extractor correction and regenerated serialization, or +another explicitly designed solution. Changes to PHP or OpenAPI extraction are +outside this evaluation. + +## Handoff + +Investigate generator configuration, another generator, or a narrowly designed +adapter for `anyOf` fidelity and binary handling; separately correct the source +contract for uploads. Rerun this harness against the resulting approved +contract and version before deciding on SDK infrastructure. A dedicated issue +for contract/extractor multipart support may be warranted once maintainers +choose the remediation; none is created by this evaluation. + +## Local Nextcloud check (2026-11-10) + +The optional `test:live` was run against the existing development instance +using this checkout: Nextcloud 36.0.0 dev, LibreSign 16.0.0-dev.3, HTTPS on +the local NCDD proxy. No application data was created or modified intentionally. +The generated client with real HTTP and basic authentication returned: + +- `policy-get-system` for `signature_flow`: HTTP 200 and an OCS envelope using + an administrator account. This is not a negative authorization test. +- `account-me`: HTTP 500. The Nextcloud log identified a missing stored + signature PFX referenced by the account, followed by `GenericFileException`. + This is an instance data problem observed on the server; the positive account + response remains unverified. No account certificate was modified. +- The same account call with deliberately invalid credentials was rejected + with an HTTP authentication error. +- `certificate-policy`: HTTP 404; no PDF was available, so real binary download + remains unverified. The response was handled as an Axios HTTP error. + +The local instance was hosted at the root, so a live subdirectory installation +was not tested. `request_signature-request-signature` was not run against this +instance because it changes application state. Its serialization remains covered +by the synthetic adapter. These observations do not change the No-Go decision. + +## Independent review observations + +Independent Claude Fable and Grok reviews reproduced the `anyOf` failure and +noted that its impact extends to policy write models and object unions such as +`FileListResponseDataInner` and `FileRuntimeMetadata`. The original minimal +negative test proves acceptance of an invalid array; it does not measure the +full extent of these other failures. The reviews also identified further upload +contract omissions: `file-validate-binary` (`file`), +`file-add-file-to-envelope` (`files`), and +`admin-save-certificate-policy` (`pdf`). They require separate verification +and correction at the source contract, outside this evaluation. + +The reviews disagreed on the decision threshold: Grok supported No-Go for the +tested version and configuration; Fable suggested Go conditional on a future +normalization of `anyOf` to `oneOf`, based on an isolated experiment. That +transformation is not part of this harness, can change schema semantics, and +has not been approved as a contract change. Consequently it is a candidate +for future investigation, not evidence that this unmodified input works. + +The simulated transport uses both basic and bearer credentials together and +does not establish which Authorization header a real Axios network adapter +will send when both are configured. Its supplied Axios `baseURL` and +configuration `basePath` also have the same value: the precedence described +above follows from inspection of generated `common.ts`, not that test alone. +No claim of complete parameter-signature coverage follows from the inventory. diff --git a/tests/sdk-generation/anyof-negative.ts b/tests/sdk-generation/anyof-negative.ts new file mode 100644 index 0000000000..63950cd0bf --- /dev/null +++ b/tests/sdk-generation/anyof-negative.ts @@ -0,0 +1,10 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import type { EffectivePolicyValue } from '../../build/sdk-generation/typescript/api' +// Arrays are not one of the allowed anyOf alternatives. An unused directive +// means the generated type incorrectly accepts the invalid value. +// @ts-expect-error arrays are not policy values +const invalid: EffectivePolicyValue = ['not a policy value'] +void invalid diff --git a/tests/sdk-generation/generate.sh b/tests/sdk-generation/generate.sh new file mode 100755 index 0000000000..8ee6c5905b --- /dev/null +++ b/tests/sdk-generation/generate.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +set -eu +root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) +image='openapitools/openapi-generator-cli@sha256:509f01c3c7eee9d1ad286506a7b6aa4624a95b410be9a238a306d209e900621f' +output=${1:-build/sdk-generation/typescript} +case "$output" in *..*) echo "Output must not contain .." >&2; exit 1;; esac +case "$output" in build/sdk-generation/*) ;; *) echo 'Output must be under build/sdk-generation/' >&2; exit 1;; esac +cd "$root" +mkdir -p "$output" +docker run --rm --user "$(id -u):$(id -g)" -v "$root:/local" "$image" validate -i /local/openapi-full.json +docker run --rm --user "$(id -u):$(id -g)" -v "$root:/local" "$image" generate -i /local/openapi-full.json -g typescript-axios -o "/local/$output" --additional-properties=useSingleRequestParameter=true diff --git a/tests/sdk-generation/inventory.cjs b/tests/sdk-generation/inventory.cjs new file mode 100644 index 0000000000..a2d4acfc4c --- /dev/null +++ b/tests/sdk-generation/inventory.cjs @@ -0,0 +1,46 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +const fs = require('node:fs') +const path = require('node:path') +const ts = require('typescript') +const root = path.resolve(__dirname, '../..') +const dir = path.join(root, 'build/sdk-generation/typescript') +const spec = JSON.parse(fs.readFileSync(path.join(root, 'openapi-full.json'))) +const source = ts.createSourceFile('api.ts', fs.readFileSync(path.join(dir, 'api.ts'), 'utf8'), ts.ScriptTarget.Latest, true) +const classes = new Map() +for (const node of source.statements) { + if (!ts.isClassDeclaration(node) || !node.name) continue + classes.set(node.name.text, new Set(node.members.filter(ts.isMethodDeclaration).map(m => m.name.getText(source)))) +} +const generated = new Map() +for (const tag of ['policies', 'identity', 'documents', 'requests', 'signing', 'appearance', 'verification', 'certificates', 'notifications', 'system']) { + const name = tag[0].toUpperCase() + tag.slice(1) + 'Api' + const doc = fs.readFileSync(path.join(dir, 'docs', name + '.md'), 'utf8') + const rows = [...doc.matchAll(/^\|\[\*\*(\w+)\*\*\]\([^\n]*?\| \*\*(GET|POST|PUT|DELETE|PATCH)\*\* ([^ |]+)/gm)] + for (const [, method, verb, url] of rows) { + const key = `${verb} ${url}` + if (!generated.has(key)) generated.set(key, []) + generated.get(key).push({ name, method, exists: classes.get(name)?.has(method) === true }) + } +} +const rows = [] +const ids = new Set() +let errors = 0 +for (const [url, operations] of Object.entries(spec.paths)) for (const [verb, op] of Object.entries(operations)) { + if (!['get', 'post', 'put', 'delete', 'patch'].includes(verb)) continue + const key = `${verb.toUpperCase()} ${url}` + const found = generated.get(key) || [] + const expected = op.tags[0][0].toUpperCase() + op.tags[0].slice(1) + 'Api' + const ok = !ids.has(op.operationId) && found.length === 1 && found[0].name === expected && found[0].exists + ids.add(op.operationId) + if (!ok) errors++ + rows.push(`| ${op.operationId} | ${key} | ${found.map(x => `${x.name}.${x.method}${x.exists ? '' : ' (missing)'}`).join(', ') || 'MISSING'} | ${ok ? 'OK' : 'FAIL'} |`) + generated.delete(key) +} +errors += generated.size +const output = ['', '', '# Generated operation inventory', '', '| operationId | HTTP operation | Generated class.method | Result |', '| --- | --- | --- | --- |', ...rows, '', `${rows.length} input operations; ${errors} inventory errors. Presence does not establish serialization compatibility.`, ''].join('\n') +fs.writeFileSync(path.join(root, 'build/sdk-generation/inventory.md'), output) +console.log(`${rows.length} operations; ${errors} inventory errors; build/sdk-generation/inventory.md`) +if (errors) process.exitCode = 1 diff --git a/tests/sdk-generation/inventory.md b/tests/sdk-generation/inventory.md new file mode 100644 index 0000000000..4bcbecc7c2 --- /dev/null +++ b/tests/sdk-generation/inventory.md @@ -0,0 +1,101 @@ + + +# Generated operation inventory + +| operationId | HTTP operation | Generated class.method | Result | +| --- | --- | --- | --- | +| certificate_policy-get-certificate-policy | GET /index.php/apps/libresign/certificate-policy.pdf | CertificatesApi.certificatePolicyGetCertificatePolicy | OK | +| crl-get-revocation-list | GET /index.php/apps/libresign/crl/libresign_{instanceId}_{generation}_{engineType}.crl | CertificatesApi.crlGetRevocationList | OK | +| crl-check-certificate-status | GET /index.php/apps/libresign/crl/check/{serialNumber} | VerificationApi.crlCheckCertificateStatus | OK | +| account-create-to-sign | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/account/create/{uuid} | IdentityApi.accountCreateToSign | OK | +| account-signature-generate | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/account/signature | IdentityApi.accountSignatureGenerate | OK | +| account-me | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/account/me | IdentityApi.accountMe | OK | +| account-update-settings | PATCH /ocs/v2.php/apps/libresign/api/{apiVersion}/account/settings | IdentityApi.accountUpdateSettings | OK | +| account-delete-pfx | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/account/pfx | IdentityApi.accountDeletePfx | OK | +| account-upload-pfx | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/account/pfx | IdentityApi.accountUploadPfx | OK | +| account-update-pfx-password | PATCH /ocs/v2.php/apps/libresign/api/{apiVersion}/account/pfx | IdentityApi.accountUpdatePfxPassword | OK | +| account-read-pfx-data | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/account/pfx/read | IdentityApi.accountReadPfxData | OK | +| account-set-config | PUT /ocs/v2.php/apps/libresign/api/{apiVersion}/account/config/{key} | IdentityApi.accountSetConfig | OK | +| file-validate-uuid | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/file/validate/uuid/{uuid} | VerificationApi.fileValidateUuid | OK | +| file-validate-file-id | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/file/validate/file_id/{fileId} | VerificationApi.fileValidateFileId | OK | +| file-validate-binary | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/file/validate | VerificationApi.fileValidateBinary | OK | +| file-list | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/file/list | DocumentsApi.fileList | OK | +| file-get-thumbnail | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/file/thumbnail/{nodeId} | DocumentsApi.fileGetThumbnail | OK | +| file-get-thumbnail-by-file-id | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/file/thumbnail/file_id/{fileId} | DocumentsApi.fileGetThumbnailByFileId | OK | +| file-save | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/file | DocumentsApi.fileSave | OK | +| file-add-file-to-envelope | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/file/{uuid}/add-file | DocumentsApi.fileAddFileToEnvelope | OK | +| file-delete-file | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/file/file_id/{fileId} | DocumentsApi.fileDeleteFile | OK | +| file_element-create-visible-element | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/file-element/{uuid} | AppearanceApi.fileElementCreateVisibleElement | OK | +| file_element-update-visible-element | PATCH /ocs/v2.php/apps/libresign/api/{apiVersion}/file-element/{uuid}/{elementId} | AppearanceApi.fileElementUpdateVisibleElement | OK | +| file_element-delete-visible-element | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/file-element/{uuid}/{elementId} | AppearanceApi.fileElementDeleteVisibleElement | OK | +| file_progress-check-progress-by-uuid | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/file/progress/{uuid} | SigningApi.fileProgressCheckProgressByUuid | OK | +| footer_template-get-footer-template | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/footer-template | AppearanceApi.footerTemplateGetFooterTemplate | OK | +| footer_template-save-footer-template | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/footer-template | AppearanceApi.footerTemplateSaveFooterTemplate | OK | +| footer_template-preview-pdf | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/footer-template/preview-pdf | AppearanceApi.footerTemplatePreviewPdf | OK | +| id_docs-add-files | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/id-docs | IdentityApi.idDocsAddFiles | OK | +| id_docs-list-unauthenticated-signer-documents | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/id-docs | IdentityApi.idDocsListUnauthenticatedSignerDocuments | OK | +| id_docs-delete | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/id-docs/{nodeId} | IdentityApi.idDocsDelete | OK | +| id_docs-list-to-approval | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/id-docs/approval/list | IdentityApi.idDocsListToApproval | OK | +| identify-search | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/identify-account/search | IdentityApi.identifySearch | OK | +| notify-signers | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/notify/signers | NotificationsApi.notifySigners | OK | +| notify-signer | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/notify/signer | NotificationsApi.notifySigner | OK | +| notify-status | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/notify/status | NotificationsApi.notifyStatus | OK | +| notify-notification-dismiss | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/notify/notification | NotificationsApi.notifyNotificationDismiss | OK | +| policy-effective | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/effective | PoliciesApi.policyEffective | OK | +| policy-get-group | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/group/{groupId}/{policyKey} | PoliciesApi.policyGetGroup | OK | +| policy-set-group | PUT /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/group/{groupId}/{policyKey} | PoliciesApi.policySetGroup | OK | +| policy-clear-group | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/group/{groupId}/{policyKey} | PoliciesApi.policyClearGroup | OK | +| policy-list-group-policies | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/by-policy/group/{policyKey} | PoliciesApi.policyListGroupPolicies | OK | +| policy-get-user-policy-for-user | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/user/{userId}/{policyKey} | PoliciesApi.policyGetUserPolicyForUser | OK | +| policy-set-user-policy-for-user | PUT /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/user/{userId}/{policyKey} | PoliciesApi.policySetUserPolicyForUser | OK | +| policy-clear-user-policy-for-user | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/user/{userId}/{policyKey} | PoliciesApi.policyClearUserPolicyForUser | OK | +| policy-list-user-policies | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/by-policy/user/{policyKey} | PoliciesApi.policyListUserPolicies | OK | +| policy-set-group-compound | PUT /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/compound/group/{groupId}/{parentPolicyKey} | PoliciesApi.policySetGroupCompound | OK | +| policy-set-user-preference-compound | PUT /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/compound/user/{parentPolicyKey} | PoliciesApi.policySetUserPreferenceCompound | OK | +| policy-set-user-policy-for-user-compound | PUT /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/compound/user/{userId}/{parentPolicyKey} | PoliciesApi.policySetUserPolicyForUserCompound | OK | +| policy-set-user-preference | PUT /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/user/{policyKey} | PoliciesApi.policySetUserPreference | OK | +| policy-clear-user-preference | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/user/{policyKey} | PoliciesApi.policyClearUserPreference | OK | +| request_signature-request-signature | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/request-signature | RequestsApi.requestSignatureRequestSignature | OK | +| request_signature-update-signature-request | PATCH /ocs/v2.php/apps/libresign/api/{apiVersion}/request-signature | RequestsApi.requestSignatureUpdateSignatureRequest | OK | +| request_signature-remove-signer | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/file_id/{fileId}/{signRequestId} | RequestsApi.requestSignatureRemoveSigner | OK | +| request_signature-delete-signature-request | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/file_id/{fileId} | RequestsApi.requestSignatureDeleteSignatureRequest | OK | +| sign_file-sign-by-file-id | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/file_id/{fileId} | SigningApi.signFileSignByFileId | OK | +| sign_file-sign-by-signer-uuid | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/uuid/{uuid} | SigningApi.signFileSignBySignerUuid | OK | +| sign_file-reject-by-file-id | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/file_id/{fileId}/reject | SigningApi.signFileRejectByFileId | OK | +| sign_file-reject-by-signer-uuid | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/uuid/{uuid}/reject | SigningApi.signFileRejectBySignerUuid | OK | +| sign_file-sign-renew | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/uuid/{uuid}/renew/{method} | SigningApi.signFileSignRenew | OK | +| sign_file-request-code-by-signer-uuid | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/uuid/{uuid}/code | SigningApi.signFileRequestCodeBySignerUuid | OK | +| sign_file-request-code-by-file-id | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/sign/file_id/{fileId}/code | SigningApi.signFileRequestCodeByFileId | OK | +| signature_elements-create-signature-element | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/signature/elements | AppearanceApi.signatureElementsCreateSignatureElement | OK | +| signature_elements-get-signature-elements | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/signature/elements | AppearanceApi.signatureElementsGetSignatureElements | OK | +| signature_elements-use-saved-signature-elements | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/signature/elements/saved | AppearanceApi.signatureElementsUseSavedSignatureElements | OK | +| signature_elements-preview-signature-element | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/signature/elements/preview/{nodeId} | AppearanceApi.signatureElementsPreviewSignatureElement | OK | +| signature_elements-get-signature-element | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/signature/elements/{nodeId} | AppearanceApi.signatureElementsGetSignatureElement | OK | +| signature_elements-patch-signature-element | PATCH /ocs/v2.php/apps/libresign/api/{apiVersion}/signature/elements/{nodeId} | AppearanceApi.signatureElementsPatchSignatureElement | OK | +| signature_elements-delete-signature-element | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/signature/elements/{nodeId} | AppearanceApi.signatureElementsDeleteSignatureElement | OK | +| signature_stamp_preview-preview-pdf | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/signature-stamp/preview-pdf | AppearanceApi.signatureStampPreviewPreviewPdf | OK | +| admin-generate-certificate-cfssl | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/certificate/cfssl | CertificatesApi.adminGenerateCertificateCfssl | OK | +| admin-generate-certificate-open-ssl | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/certificate/openssl | CertificatesApi.adminGenerateCertificateOpenSsl | OK | +| admin-set-certificate-engine | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/certificate/engine | CertificatesApi.adminSetCertificateEngine | OK | +| admin-load-certificate | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/certificate | CertificatesApi.adminLoadCertificate | OK | +| admin-configure-check | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/configure-check | SystemApi.adminConfigureCheck | OK | +| admin-signature-background-save | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/signature-background | AppearanceApi.adminSignatureBackgroundSave | OK | +| admin-signature-background-get | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/signature-background | AppearanceApi.adminSignatureBackgroundGet | OK | +| admin-signature-background-delete | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/signature-background | AppearanceApi.adminSignatureBackgroundDelete | OK | +| admin-save-certificate-policy | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/certificate-policy | CertificatesApi.adminSaveCertificatePolicy | OK | +| admin-delete-certificate-policy | DELETE /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/certificate-policy | CertificatesApi.adminDeleteCertificatePolicy | OK | +| admin-update-oid | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/certificate-policy/oid | CertificatesApi.adminUpdateOid | OK | +| admin-get-active-signings | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/active-signings | RequestsApi.adminGetActiveSignings | OK | +| admin-get-geo-ip-config | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/geoip | SystemApi.adminGetGeoIpConfig | OK | +| admin-save-geo-ip-config | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/admin/geoip | SystemApi.adminSaveGeoIpConfig | OK | +| crl_api-list | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/crl/list | CertificatesApi.crlApiList | OK | +| crl_api-revoke | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/crl/revoke | CertificatesApi.crlApiRevoke | OK | +| policy-get-system | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/system/{policyKey} | PoliciesApi.policyGetSystem | OK | +| policy-set-system | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/system/{policyKey} | PoliciesApi.policySetSystem | OK | +| policy-set-system-compound | POST /ocs/v2.php/apps/libresign/api/{apiVersion}/policies/compound/system/{parentPolicyKey} | PoliciesApi.policySetSystemCompound | OK | +| setting-has-root-cert | GET /ocs/v2.php/apps/libresign/api/{apiVersion}/setting/has-root-cert | CertificatesApi.settingHasRootCert | OK | + +90 input operations; 0 inventory errors. Presence does not establish serialization compatibility. diff --git a/tests/sdk-generation/live.ts b/tests/sdk-generation/live.ts new file mode 100644 index 0000000000..812706de52 --- /dev/null +++ b/tests/sdk-generation/live.ts @@ -0,0 +1,62 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import * as assert from 'node:assert/strict' +import { Agent } from 'node:https' +import axios from 'axios' +import { CertificatesApi, IdentityApi, PoliciesApi } from '../../build/sdk-generation/typescript/api' +import { Configuration } from '../../build/sdk-generation/typescript/configuration' + +async function main() { + const basePath = process.env.SDK_TEST_URL + const username = process.env.SDK_TEST_USER + const password = process.env.SDK_TEST_PASSWORD + if (!basePath || !username || !password) throw new Error('Set SDK_TEST_URL, SDK_TEST_USER and SDK_TEST_PASSWORD') + const url = new URL(basePath) + if (url.protocol !== 'https:' || !(url.hostname === 'localhost' || url.hostname.endsWith('.localhost'))) throw new Error('Only local HTTPS Nextcloud instances are supported') + // NCDD uses a local self-signed certificate; never use this for remote hosts. + const instance = axios.create({ httpsAgent: new Agent({ rejectUnauthorized: false }), proxy: false, timeout: 15000 }) + const config = new Configuration({ basePath, username, password }) + const identity = new IdentityApi(config, undefined, instance) + let failed = false + try { + const account = await identity.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }) + assert.equal(account.status, 200) + assert.equal(account.data.ocs.meta.statuscode, 200) + assert.equal(typeof account.data.ocs.data.account.uid, 'string') + console.log('account-me: HTTP 200, OCS envelope and typed account fields verified') + } catch (error) { + failed = true + console.log('account-me failed: HTTP', axios.isAxiosError(error) ? error.response?.status : 'assertion failure') + } + try { + const policy = await new PoliciesApi(config, undefined, instance).policyGetSystem({ apiVersion: 'v1', policyKey: 'signature_flow', oCSAPIRequest: true }) + assert.equal(policy.status, 200) + assert.equal(typeof policy.data.ocs.meta.statuscode, 'number') + assert.ok(policy.data.ocs.data) + console.log('policy-get-system: HTTP 200, OCS envelope verified with administrator') + } catch (error) { + failed = true + console.log('policy-get-system failed: HTTP', axios.isAxiosError(error) ? error.response?.status : 'assertion failure') + } + try { + const pdf = await new CertificatesApi(config, undefined, instance).certificatePolicyGetCertificatePolicy({ responseType: 'arraybuffer' }) + assert.equal(pdf.status, 200) + assert.match(String(pdf.headers['content-type']), /application\/pdf/i) + assert.equal(Buffer.from(pdf.data as unknown as ArrayBuffer).subarray(0, 5).toString(), '%PDF-') + console.log('certificate-policy: HTTP 200, PDF content type and bytes verified') + } catch (error) { + if (!axios.isAxiosError(error) || error.response?.status !== 404) throw error + console.log('certificate-policy: HTTP 404 (no configured policy PDF); binary response not verified') + } + const invalid = new IdentityApi(new Configuration({ basePath, username, password: 'deliberately-invalid-test-password' }), undefined, instance) + await assert.rejects(() => invalid.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }), (error: unknown) => axios.isAxiosError(error) && (error.response?.status === 401 || error.response?.status === 403)) + console.log('account-me with invalid credentials: HTTP authentication error verified') + if (failed) process.exitCode = 1 +} +main().catch(error => { + if (axios.isAxiosError(error)) console.error('Live request failed with HTTP status', error.response?.status ?? 'unavailable', 'code', error.code ?? 'none') + else console.error(error instanceof Error ? error.message : 'Live test failed') + process.exitCode = 1 +}) diff --git a/tests/sdk-generation/package-lock.json b/tests/sdk-generation/package-lock.json new file mode 100644 index 0000000000..642af6956a --- /dev/null +++ b/tests/sdk-generation/package-lock.json @@ -0,0 +1,873 @@ +{ + "name": "libresign-sdk-generation-evaluation", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "libresign-sdk-generation-evaluation", + "version": "1.0.0", + "license": "AGPL-3.0-or-later", + "dependencies": { + "axios": "1.9.0" + }, + "devDependencies": { + "@types/node": "22.15.21", + "tsx": "4.19.4", + "typescript": "5.8.3" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@types/node": { + "version": "22.15.21", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.21.tgz", + "integrity": "sha512-EV/37Td6c+MgKAbkcLG6vqZ2zEYHD7bvSrzqqs2RIhbA6w3x+Dqz8MZM3sP6kGTeLrdoOgKZe+Xja7tUB2DNkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz", + "integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/follow-redirects": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.3.tgz", + "integrity": "sha512-toOSoqN6d51Wjf1aOFJYcoVv1aND9rj/CwjLU0Vz40oDuSpWDayCeKe4JpL5NL0WdFvoOOCI3BRo69HahjbR1A==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.6.tgz", + "integrity": "sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.4", + "mime-types": "^2.1.35" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-tsconfig": { + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.14.3.tgz", + "integrity": "sha512-++QEw4DIY7WGoukz+/+A/8dGYPT9l9yIadnmSgZ8Rjr3YVSVDipQSO9CdnJo9ePqFqUUqh+wk9uIaoiAwsiPkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/tsx": { + "version": "4.19.4", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.4.tgz", + "integrity": "sha512-gK5GVzDkJK1SI1zwHf32Mqxf2tSJkNx+eYcNly5+nHvWqXUJYUkWBQtKauoESz3ymezAI++ZwT855x5p5eop+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.25.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/typescript": { + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/tests/sdk-generation/package.json b/tests/sdk-generation/package.json new file mode 100644 index 0000000000..0fe6f75a9c --- /dev/null +++ b/tests/sdk-generation/package.json @@ -0,0 +1,20 @@ +{ + "name": "libresign-sdk-generation-evaluation", + "private": true, + "version": "1.0.0", + "license": "AGPL-3.0-or-later", + "scripts": { + "compile": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/typescript/*.ts types.ts transport.ts live.ts", + "test": "tsx transport.ts && node inventory.cjs", + "test:live": "tsx live.ts", + "test:anyof": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node anyof-negative.ts" + }, + "dependencies": { + "axios": "1.9.0" + }, + "devDependencies": { + "@types/node": "22.15.21", + "tsx": "4.19.4", + "typescript": "5.8.3" + } +} diff --git a/tests/sdk-generation/setup.sh b/tests/sdk-generation/setup.sh new file mode 100755 index 0000000000..ea7a862557 --- /dev/null +++ b/tests/sdk-generation/setup.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# SPDX-FileCopyrightText: 2026 LibreCode coop and contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +set -eu +root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) +npm ci --prefix "$root/tests/sdk-generation" --ignore-scripts --no-audit --no-fund +mkdir -p "$root/build/sdk-generation" +if [ ! -e "$root/build/sdk-generation/node_modules" ]; then + ln -s ../../tests/sdk-generation/node_modules "$root/build/sdk-generation/node_modules" +fi diff --git a/tests/sdk-generation/transport.ts b/tests/sdk-generation/transport.ts new file mode 100644 index 0000000000..98d0e43f03 --- /dev/null +++ b/tests/sdk-generation/transport.ts @@ -0,0 +1,68 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import * as assert from 'node:assert/strict' +import axios, { AxiosError, type AxiosAdapter, type InternalAxiosRequestConfig } from 'axios' +import { AppearanceApi, CertificatesApi, DocumentsApi, IdentityApi, PoliciesApi, RequestsApi } from '../../build/sdk-generation/typescript/api' +import { Configuration } from '../../build/sdk-generation/typescript/configuration' + +async function run() { + let last!: InternalAxiosRequestConfig + let status = 200 + let body: unknown = { ocs: { meta: { status: 'ok', statuscode: 200 }, data: { account: { uid: 'test', emailAddress: 'test@example.test', displayName: 'Test' }, settings: { canRequestSign: true, hasSignatureFile: false, phoneNumber: '' } } } } + const adapter: AxiosAdapter = async config => { + last = config + const response = { data: body, status, statusText: String(status), headers: {}, config } + if (config.validateStatus && !config.validateStatus(status)) throw new AxiosError('HTTP error', 'ERR_BAD_RESPONSE', config, undefined, response) + return response + } + const instance = axios.create({ adapter, headers: { 'X-Instance': 'injected' } }) + const configuration = new Configuration({ basePath: 'https://example.test/nextcloud', username: 'test', password: 'secret', accessToken: 'synthetic-token' }) + const identity = new IdentityApi(configuration, undefined, instance) + const account = await identity.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }) + assert.equal(last.url, 'https://example.test/nextcloud/ocs/v2.php/apps/libresign/api/v1/account/me') + assert.equal(last.method, 'get') + assert.equal(last.headers.get('OCS-APIRequest'), 'true') + assert.equal(last.headers.get('X-Instance'), 'injected') + assert.deepEqual(last.auth, { username: 'test', password: 'secret' }) + assert.equal(account.data.ocs.data.account.uid, 'test') + const policies = new PoliciesApi(configuration, undefined, instance) + await policies.policyGetSystem({ apiVersion: 'v1', policyKey: 'a/b ?', oCSAPIRequest: true }) + assert.equal(last.url, 'https://example.test/nextcloud/ocs/v2.php/apps/libresign/api/v1/policies/system/a%2Fb%20%3F') + assert.equal(last.headers.get('Authorization'), 'Bearer synthetic-token') + const requests = new RequestsApi(configuration, undefined, instance) + await requests.requestSignatureRequestSignature({ apiVersion: 'v1', oCSAPIRequest: true, requestSignatureRequestSignatureRequest: { name: 'Example', file: { nodeId: '123' } } }) + assert.equal(last.method, 'post') + assert.equal(last.url, 'https://example.test/nextcloud/ocs/v2.php/apps/libresign/api/v1/request-signature') + assert.match(String(last.headers.get('Content-Type')), /application\/json/) + assert.deepEqual(JSON.parse(String(last.data)), { name: 'Example', file: { nodeId: '123' } }) + const certificates = new CertificatesApi(configuration, undefined, instance) + body = new Uint8Array([37, 80, 68, 70]) + const pdf = await certificates.certificatePolicyGetCertificatePolicy({ responseType: 'arraybuffer' }) + assert.equal(last.url, 'https://example.test/nextcloud/index.php/apps/libresign/certificate-policy.pdf') + assert.equal(last.responseType, 'arraybuffer') + assert.deepEqual(pdf.data, body) + status = 403 + await assert.rejects(() => policies.policyGetSystem({ apiVersion: 'v1', policyKey: 'test', oCSAPIRequest: true }), (error: unknown) => axios.isAxiosError(error) && error.response?.status === 403) + const root = new IdentityApi(new Configuration({ basePath: 'https://example.test' }), undefined, instance) + status = 200 + await root.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }) + assert.equal(last.url, 'https://example.test/ocs/v2.php/apps/libresign/api/v1/account/me') + await identity.accountUploadPfx({ apiVersion: 'v1', oCSAPIRequest: true }) + assert.equal(last.data, undefined) + await new AppearanceApi(configuration, undefined, instance).adminSignatureBackgroundSave({ apiVersion: 'v1', oCSAPIRequest: true }) + assert.equal(last.data, undefined) + await new DocumentsApi(configuration, undefined, instance).fileSave({ apiVersion: 'v1', oCSAPIRequest: true, fileSaveRequest: { file: { nodeId: 123 } } }) + assert.match(String(last.headers.get('Content-Type')), /application\/json/) + assert.deepEqual(JSON.parse(String(last.data)), { file: { nodeId: 123 } }) + const supplied = axios.create({ adapter, baseURL: 'https://example.test/nextcloud' }) + const suppliedIdentity = new IdentityApi(configuration, undefined, supplied) + await suppliedIdentity.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }) + assert.equal(supplied.getUri(last), 'https://example.test/nextcloud/ocs/v2.php/apps/libresign/api/v1/account/me') + const suppliedCertificates = new CertificatesApi(configuration, undefined, supplied) + await suppliedCertificates.certificatePolicyGetCertificatePolicy({ responseType: 'arraybuffer' }) + assert.equal(supplied.getUri(last), 'https://example.test/nextcloud/index.php/apps/libresign/certificate-policy.pdf') + console.log('PASS: generated transport, root/subdirectory paths, auth, JSON, binary options and HTTP errors') +} +run().catch(error => { console.error(error); process.exitCode = 1 }) diff --git a/tests/sdk-generation/types.ts b/tests/sdk-generation/types.ts new file mode 100644 index 0000000000..c6904e3ad8 --- /dev/null +++ b/tests/sdk-generation/types.ts @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import type { NewFile, SignerDetail, RequestSignatureRequestSignatureRequest, AccountMe200Response, IdentityApiAccountUploadPfxRequest, AppearanceApiAdminSignatureBackgroundSaveRequest } from '../../build/sdk-generation/typescript/api' + +const file1: NewFile = { nodeId: 42 } +const file2: NewFile = { nodeId: '9007199254740993' } +// @ts-expect-error nodeId is not a boolean +const badFile: NewFile = { nodeId: true } +const signer: SignerDetail = { + signRequestId: 1, displayName: 'Example', signed: null, + displayStatus: 'signed', statusText: 'signed', description: null, + request_sign_date: '2026-01-01', me: true, visibleElements: [], +} +// @ts-expect-error allOf requires inherited fields +const badSigner: SignerDetail = { me: true, visibleElements: [] } +const request: RequestSignatureRequestSignatureRequest = { callback: null } +// @ts-expect-error callback must be a string or null +const badRequest: RequestSignatureRequestSignatureRequest = { callback: 2 } +// @ts-expect-error status is a finite numeric enum +const badStatus: SignerDetail['status'] = 99 +function account(response: AccountMe200Response): string { return response.ocs.data.account.uid } +void [file1, file2, badFile, signer, badSigner, request, badRequest, badStatus, account] + +// @ts-expect-error the generated request has no upload parameter +const pfx: IdentityApiAccountUploadPfxRequest = { apiVersion: 'v1', oCSAPIRequest: true, file: new Blob() } +// @ts-expect-error the generated request has no image parameter +const background: AppearanceApiAdminSignatureBackgroundSaveRequest = { apiVersion: 'v1', oCSAPIRequest: true, image: new Blob() } +void [pfx, background] From ce38559a1831d5016157752af15fc21d8d2fd4ab Mon Sep 17 00:00:00 2001 From: Luis Amorim Date: Wed, 11 Nov 2026 00:23:04 -0300 Subject: [PATCH 2/4] test(sdk): finalize axios generator compatibility evaluation Pin generator 7.27.0 and evaluate normalized input separately. Cover independent authentication and base URL precedence, and document the real Nextcloud Axios Node import limitation. Co-authored-by: Codex Signed-off-by: Luis Amorim --- tests/sdk-generation/README.md | 32 ++- tests/sdk-generation/REPORT.md | 245 ++++++++++------------ tests/sdk-generation/generate.sh | 15 +- tests/sdk-generation/nextcloud-import.mjs | 8 + tests/sdk-generation/normalize-input.cjs | 25 +++ tests/sdk-generation/normalized-types.ts | 22 ++ tests/sdk-generation/package-lock.json | 181 +++++++++++++++- tests/sdk-generation/package.json | 7 +- tests/sdk-generation/transport.ts | 15 +- 9 files changed, 390 insertions(+), 160 deletions(-) create mode 100644 tests/sdk-generation/nextcloud-import.mjs create mode 100644 tests/sdk-generation/normalize-input.cjs create mode 100644 tests/sdk-generation/normalized-types.ts diff --git a/tests/sdk-generation/README.md b/tests/sdk-generation/README.md index 4e79926aa0..8a50af2923 100644 --- a/tests/sdk-generation/README.md +++ b/tests/sdk-generation/README.md @@ -26,12 +26,42 @@ Compare that inventory with the checked-in evaluation snapshot when changing the specification. This does not prove every operation's runtime serialization. The generator validates the full specification first and never uses -`--skip-validate-spec`. Its Docker image digest pins OpenAPI Generator 7.15.0; +`--skip-validate-spec`. Its Docker image digest pins OpenAPI Generator 7.27.0; `useSingleRequestParameter=true` is enabled. npm dependencies are pinned by `package-lock.json`. Use fresh output directories: the generator does not remove stale files. Generated code stays under ignored `build/` and must not be edited. See [REPORT.md](REPORT.md) and [inventory.md](inventory.md) for results. +## Normalized-input experiment + +This separate experiment changes all 22 `anyOf` keywords to `oneOf` in a +**disposable generator input**, never in the committed specification: + +```sh +node tests/sdk-generation/normalize-input.cjs +tests/sdk-generation/generate.sh build/sdk-generation/normalized/typescript build/sdk-generation/normalized/openapi-full.oneof.json +npm run test:normalized --prefix tests/sdk-generation +``` + +The positive/negative type checks pass, including rejection of the invalid +policy array and invalid scalar object unions. They also explicitly record that +schema-valid `null` is still rejected. This is partial mitigation, not a Go. +`oneOf` and `anyOf` are not equivalent validation contracts: `integer` and +`number` overlap. The transformed file must never replace the source contract. + +## Real Nextcloud Axios import probe + +```sh +npm run test:nextcloud --prefix tests/sdk-generation +``` + +With the locked `@nextcloud/axios` 2.6.0 on Node 24.22.2 this **fails** with +`ReferenceError: window is not defined` in `@nextcloud/browser-storage`, imported +by `@nextcloud/auth`. This invokes the real ESM package without browser shims. +Real Nextcloud instance injection therefore remains unverified; the deterministic +transport tests use ordinary Axios. Browser integration and CSRF retry behavior +need a separate browser environment. + ## Optional live Nextcloud check After generation and setup, set `SDK_TEST_URL` to the local HTTPS Nextcloud diff --git a/tests/sdk-generation/REPORT.md b/tests/sdk-generation/REPORT.md index 19777c4da2..856e1318e1 100644 --- a/tests/sdk-generation/REPORT.md +++ b/tests/sdk-generation/REPORT.md @@ -5,87 +5,103 @@ # Compatibility evaluation -## Decision: No-Go - -OpenAPI Generator 7.15.0's `typescript-axios` output in the evaluated -configuration is not a sufficiently faithful SDK foundation: critical `anyOf` -models are incorrect. This does not prevent planning an SDK using a different -generator or a reviewed mitigation. Multipart omissions are separate gaps in -the input contract, not evidence that the generator mishandles declared uploads. -This decision does not assert that every operation is broken, nor does it -change backend authorization. - -## Input and reproducibility - -- Application revision: `b02d0b82e3abe346085c8bfe059e7ca4bf8f6bfd`. -- `openapi-full.json` SHA-256: `2501bc11fcee0545dfb703a28d93018a80e62f6e14ba81bae549d1b130de9243`. -- Generator: Docker image `openapitools/openapi-generator-cli` 7.15.0, - SHA-256 `509f01c3c7eee9d1ad286506a7b6aa4624a95b410be9a238a306d209e900621f`; - generator `typescript-axios`, `useSingleRequestParameter=true`. -- TypeScript 5.8.3, Axios 1.9.0, tsx 4.19.4, Node 24.22.2; exact npm - dependencies and transitives are in the lockfile. -- The commands in README were run, except that the first two output directories - were generated before the setup script was written with equivalent pinned - tooling. A third generation used the final script. Validation succeeded with - warnings for unused `Capabilities` and `PublicCapabilities` models. A full - recursive diff of the first and third output directories was empty, without - excluding metadata. Generated code was not edited. -- Warm local timings: validation and generation together 4.40 seconds; - compilation 1.20 seconds; transport and inventory 0.56 seconds. These are - wall-clock observations from one machine, excluding npm installation and image - download, not CI benchmarks. No recurring CI job is proposed without - measuring cold-start cost and benefit. - -## Inventory and models - -The input contains 90 operations, rather than the 88 in the issue. The -[inventory](inventory.md) matches HTTP method and path to the generator's -actual documentation and checks for a corresponding public class method in the -TypeScript AST: 90 matched, no duplicate input operation IDs, missing methods or -wrong functional class among the ten approved tags. This is a presence/grouping -check, not an exhaustive signature or runtime-serialization audit. In -particular, the generated Markdown examples use positional arguments despite -`useSingleRequestParameter=true`; use the actual class signatures instead. - -Generated code and positive/negative checks in `types.ts` compile under strict -TypeScript (with `skipLibCheck`); `NewFile.nodeId` accepts number/string and -rejects boolean; `SignerDetail` includes required inherited and local fields; -nullable/optional and enum examples reject invalid values. These tests sample -contracts and do not validate numerical minima or runtime JSON. - -`EffectivePolicyValue` is generated as an empty interface even though the -schema is a nullable `anyOf` of boolean, number, string and object. An invalid -array is accepted. `npm run test:anyof` fails with TS2578 (unused -`@ts-expect-error`), proving the negative test is not enforced. This is a -critical type-fidelity failure, not a passing acceptance test. No generated -code was patched to hide it. - -## Transport - -Tests invoke generated class methods through a synthetic Axios adapter, with -synthetic credentials and data. They check: - -- `IdentityApi.accountMe`: GET, versioned OCS URL, explicit - `OCS-APIRequest: true`, injected basic auth and typed `ocs.data` envelope. -- `PoliciesApi.policyGetSystem`: encoded path parameter, bearer configuration, - and a simulated HTTP 403 rejection. Authorization remains the server's job; - no server authorization was tested. The encoded sample exercises serialization - and is not claimed to satisfy the policy key's server-side pattern. -- `RequestsApi.requestSignatureRequestSignature`: JSON body and content type. -- `CertificatesApi.certificatePolicyGetCertificatePolicy`: non-OCS path and - explicit `responseType: arraybuffer`, with synthetic binary data. -- Root and `/nextcloud` URLs, including an injected Axios instance with its own - `baseURL`. A supplied instance's `baseURL` takes precedence over the generated - configuration's base path. An Axios-compatible injected instance is exercised; - the real `@nextcloud/axios` package and a live Nextcloud server were not tested. - -The generated client does not unwrap `ocs.data`, and the caller must supply the -required OCS header argument. An Axios adapter must perform status settlement; -this harness simulates it rather than claiming to test a real network adapter. -HTTP 200 containing an OCS-level error is not automatically interpreted as an -error by this test. The PDF return is generated as `File`, while the explicit -arraybuffer transport yields bytes at runtime; the caller must choose and -reconcile response handling. No automatic binary response type was observed. +## Decision: No-Go for unmodified input + +OpenAPI Generator 7.27.0's `typescript-axios` output is not a sufficiently +faithful SDK foundation: `EffectivePolicyValue` is an empty interface and +accepts invalid arrays. Version 7.15.0 has the same defect. The separate +normalized-input experiment partially improves unions; it does not change +this decision or approve any source contract change. Multipart is tracked +separately in #9435. + +## Input and toolchain + +- Application base: `9aebe13938369e70344a4fb1e16fc331387427ea` (upstream main). +- `openapi-full.json` SHA-256: + `2501bc11fcee0545dfb703a28d93018a80e62f6e14ba81bae549d1b130de9243`. +- Generator: `openapitools/openapi-generator-cli` 7.27.0 at + `sha256:949efd0d5cf3c093ef169887b2ebe0879ee2e8074b6476264232ce4fd8ef46d0`; + `typescript-axios`, `useSingleRequestParameter=true`. +- Previous comparison: 7.15.0 at + `sha256:509f01c3c7eee9d1ad286506a7b6aa4624a95b410be9a238a306d209e900621f`. +- TypeScript 5.8.3, Axios 1.20.0, `@nextcloud/axios` 2.6.0, tsx 4.19.4; + Node 24.22.2, npm 11.19.1. npm dependencies/transitives are locked. + Axios matches the application's locked version and satisfies Nextcloud Axios. +- All deterministic README commands ran with fresh generated directories. + Validation succeeded with unused `Capabilities` and `PublicCapabilities` + warnings. Two generations had an empty recursive diff including metadata. + No generated source was edited. +- Warm timings: setup 1.05 s; validation/generation 4.91 s (repeat 5.79 s); + strict compilation 2.09 s; transport/inventory 1.06 s; normalized + validation/generation 4.71 s and type checks 1.36 s. These are single-machine + observations with cached images, not cold CI benchmarks. No CI job is added. + +## Unmodified input results + +The [inventory](inventory.md) covers 90 operations (69 default, 21 +administration), rather than the issue's original 88: 90 matched, zero inventory +errors, ten functional classes. The checked-in snapshot matches the new output. +The check matches method/path, generated documentation and public TypeScript +class methods; it does not exhaustively validate signatures or serialization. +Generated Markdown examples still use positional arguments despite the chosen +single-request-parameter configuration; use actual class signatures. + +Strict compilation with `skipLibCheck` passes. `types.ts` tests number/string +`NewFile.nodeId` (rejecting boolean), inherited/local `SignerDetail` fields, +nullable/optional fields and enums. `test:anyof` exits 2 with TS2578, an unused +`@ts-expect-error`: the generated empty interface accepts an invalid policy +array. This is a failed acceptance criterion, not a passing test. + +The controlled Axios adapter tests generated calls for account GET and typed +OCS envelope, encoded policy path and simulated HTTP 403, signature-request +JSON POST, and non-OCS PDF with explicit `responseType: arraybuffer`. Basic-only +and bearer-only configurations are independent, with assertions that the other +credential mechanism is absent. Both root and subdirectory paths pass. +An instance at `https://instance.test/installed` overrides configuration +`https://example.test/nextcloud` for both OCS and PDF URLs, proving precedence +with different values. + +The real locked `@nextcloud/axios` ESM import probe exits 1 in Node with +`ReferenceError: window is not defined`: `@nextcloud/auth` imports +`@nextcloud/browser-storage`, whose `StorageBuilder.build` accesses browser +storage during initialization. No browser globals are mocked. Real Nextcloud +Axios injection and its CSRF/session interceptors remain unverified; the +successful transport tests use ordinary Axios. + +## Normalized-input experiment + +`normalize-input.cjs` writes only +`build/sdk-generation/normalized/openapi-full.oneof.json`, renaming all 22 +`anyOf` keywords to `oneOf`. Generation is separate from the main evaluation. +It produces: + +- `EffectivePolicyValue = boolean | number | string | { [key: string]: object }`; +- `FileListResponseDataInner = DetailedFile | FileSummary`; +- `FileRuntimeMetadata = ValidateMetadata | { [key: string]: object }`. + +`test:normalized` passes strict compilation and positive/negative checks: +policy primitives/object values and object union members compile; policy arrays, +undefined and scalar file/metadata values are rejected. It also records a +remaining defect: schema-valid `null` is rejected by `EffectivePolicyValue`. +Passing this diagnostic suite does not establish full contract fidelity. + +This transformation is **generator-input normalization only**, not an equivalent +validation contract. In particular, integers match both `integer` and `number` +alternatives: `anyOf` allows that overlap, while `oneOf` requires exactly one +match. Never replace committed OpenAPI with this experiment's output. + +## Remaining limits + +OCS envelopes are not automatically unwrapped, and callers must pass the OCS +header argument. Adapter status settlement is simulated; server authorization +and OCS-level errors inside HTTP 200 are not tested. Basic auth is inspected as +Axios config, not a real on-wire Authorization header. PDF types are generated +as `File` although explicit arraybuffer transport returns bytes; callers must +reconcile those types. No live Nextcloud checks were rerun for this version; +real account success, binary download, subdirectory deployment and state-changing +signature requests remain unverified. Tests sample models, not runtime JSON +validation or numerical limits. No production SDK or frontend migration is +included. ## Multipart limitations @@ -106,58 +122,15 @@ outside this evaluation. ## Handoff -Investigate generator configuration, another generator, or a narrowly designed -adapter for `anyOf` fidelity and binary handling; separately correct the source -contract for uploads. Rerun this harness against the resulting approved -contract and version before deciding on SDK infrastructure. A dedicated issue -for contract/extractor multipart support may be warranted once maintainers -choose the remediation; none is created by this evaluation. - -## Local Nextcloud check (2026-11-10) - -The optional `test:live` was run against the existing development instance -using this checkout: Nextcloud 36.0.0 dev, LibreSign 16.0.0-dev.3, HTTPS on -the local NCDD proxy. No application data was created or modified intentionally. -The generated client with real HTTP and basic authentication returned: - -- `policy-get-system` for `signature_flow`: HTTP 200 and an OCS envelope using - an administrator account. This is not a negative authorization test. -- `account-me`: HTTP 500. The Nextcloud log identified a missing stored - signature PFX referenced by the account, followed by `GenericFileException`. - This is an instance data problem observed on the server; the positive account - response remains unverified. No account certificate was modified. -- The same account call with deliberately invalid credentials was rejected - with an HTTP authentication error. -- `certificate-policy`: HTTP 404; no PDF was available, so real binary download - remains unverified. The response was handled as an Axios HTTP error. - -The local instance was hosted at the root, so a live subdirectory installation -was not tested. `request_signature-request-signature` was not run against this -instance because it changes application state. Its serialization remains covered -by the synthetic adapter. These observations do not change the No-Go decision. - -## Independent review observations - -Independent Claude Fable and Grok reviews reproduced the `anyOf` failure and -noted that its impact extends to policy write models and object unions such as -`FileListResponseDataInner` and `FileRuntimeMetadata`. The original minimal -negative test proves acceptance of an invalid array; it does not measure the -full extent of these other failures. The reviews also identified further upload -contract omissions: `file-validate-binary` (`file`), -`file-add-file-to-envelope` (`files`), and -`admin-save-certificate-policy` (`pdf`). They require separate verification -and correction at the source contract, outside this evaluation. - -The reviews disagreed on the decision threshold: Grok supported No-Go for the -tested version and configuration; Fable suggested Go conditional on a future -normalization of `anyOf` to `oneOf`, based on an isolated experiment. That -transformation is not part of this harness, can change schema semantics, and -has not been approved as a contract change. Consequently it is a candidate -for future investigation, not evidence that this unmodified input works. - -The simulated transport uses both basic and bearer credentials together and -does not establish which Authorization header a real Axios network adapter -will send when both are configured. Its supplied Axios `baseURL` and -configuration `basePath` also have the same value: the precedence described -above follows from inspection of generated `common.ts`, not that test alone. -No claim of complete parameter-signature coverage follows from the inventory. +Maintainers must choose among these options; this evaluation selects none: + +1. Conditional Go with reviewed generator-input normalization, addressing the + remaining nullable and transport limitations before SDK infrastructure. +2. Correct the source contract/extractor to emit `oneOf` where semantically + valid, explicitly resolving overlapping alternatives rather than blindly + renaming keywords. +3. Evaluate another generator against the same acceptance criteria. + +Rerun the harness against the approved contract and toolchain. Multipart source +contract work belongs to #9435. No PHP controller, extractor, committed OpenAPI, +generated frontend type, CI job or permanent SDK is changed here. diff --git a/tests/sdk-generation/generate.sh b/tests/sdk-generation/generate.sh index 8ee6c5905b..815864f1ad 100755 --- a/tests/sdk-generation/generate.sh +++ b/tests/sdk-generation/generate.sh @@ -1,13 +1,20 @@ #!/bin/sh # SPDX-FileCopyrightText: 2026 LibreCode coop and contributors # SPDX-License-Identifier: AGPL-3.0-or-later +# +# Usage: generate.sh [output [input]] +# The input defaults to the repository's openapi-full.json. Any other input +# must be a disposable copy under build/sdk-generation/. set -eu root=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) -image='openapitools/openapi-generator-cli@sha256:509f01c3c7eee9d1ad286506a7b6aa4624a95b410be9a238a306d209e900621f' +# OpenAPI Generator 7.27.0 +image='openapitools/openapi-generator-cli@sha256:949efd0d5cf3c093ef169887b2ebe0879ee2e8074b6476264232ce4fd8ef46d0' output=${1:-build/sdk-generation/typescript} -case "$output" in *..*) echo "Output must not contain .." >&2; exit 1;; esac +input=${2:-openapi-full.json} +case "$output$input" in *..*) echo 'Paths must not contain ..' >&2; exit 1;; esac case "$output" in build/sdk-generation/*) ;; *) echo 'Output must be under build/sdk-generation/' >&2; exit 1;; esac +case "$input" in openapi-full.json|build/sdk-generation/*) ;; *) echo 'Input must be openapi-full.json or a copy under build/sdk-generation/' >&2; exit 1;; esac cd "$root" mkdir -p "$output" -docker run --rm --user "$(id -u):$(id -g)" -v "$root:/local" "$image" validate -i /local/openapi-full.json -docker run --rm --user "$(id -u):$(id -g)" -v "$root:/local" "$image" generate -i /local/openapi-full.json -g typescript-axios -o "/local/$output" --additional-properties=useSingleRequestParameter=true +docker run --rm --user "$(id -u):$(id -g)" -v "$root:/local" "$image" validate -i "/local/$input" +docker run --rm --user "$(id -u):$(id -g)" -v "$root:/local" "$image" generate -i "/local/$input" -g typescript-axios -o "/local/$output" --additional-properties=useSingleRequestParameter=true diff --git a/tests/sdk-generation/nextcloud-import.mjs b/tests/sdk-generation/nextcloud-import.mjs new file mode 100644 index 0000000000..218d36ceff --- /dev/null +++ b/tests/sdk-generation/nextcloud-import.mjs @@ -0,0 +1,8 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +// Deliberately use the package's real ESM entry point, without browser shims. +// Failure under Node is recorded as a limitation, not converted into a pass. +import nextcloudAxios from '@nextcloud/axios' +console.log('Imported @nextcloud/axios:', typeof nextcloudAxios.request) diff --git a/tests/sdk-generation/normalize-input.cjs b/tests/sdk-generation/normalize-input.cjs new file mode 100644 index 0000000000..57a5a1acc2 --- /dev/null +++ b/tests/sdk-generation/normalize-input.cjs @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +// Normalized-input experiment: writes a disposable copy of openapi-full.json in +// which every `anyOf` schema keyword is renamed to `oneOf`. `oneOf` requires +// exactly one matching alternative, so the copy is not an equivalent validation +// contract. It is generator input only and must never replace the specification. +const fs = require('node:fs') +const path = require('node:path') +const root = path.resolve(__dirname, '../..') +const target = path.join(root, 'build/sdk-generation/normalized/openapi-full.oneof.json') +let rewritten = 0 +function normalize(value) { + if (Array.isArray(value)) return value.map(normalize) + if (value === null || typeof value !== 'object') return value + const isUnion = Array.isArray(value.anyOf) + if (isUnion && 'oneOf' in value) throw new Error('Schema declares both anyOf and oneOf') + if (isUnion) rewritten++ + return Object.fromEntries(Object.entries(value).map(([key, item]) => [isUnion && key === 'anyOf' ? 'oneOf' : key, normalize(item)])) +} +const output = normalize(JSON.parse(fs.readFileSync(path.join(root, 'openapi-full.json'), 'utf8'))) +fs.mkdirSync(path.dirname(target), { recursive: true }) +fs.writeFileSync(target, JSON.stringify(output, null, 4) + '\n') +console.log(`${rewritten} anyOf schemas rewritten to oneOf; ${path.relative(root, target)}`) diff --git a/tests/sdk-generation/normalized-types.ts b/tests/sdk-generation/normalized-types.ts new file mode 100644 index 0000000000..835fd8d3e8 --- /dev/null +++ b/tests/sdk-generation/normalized-types.ts @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import type { EffectivePolicyValue, FileListResponseDataInner, FileSummary, FileRuntimeMetadata, ValidateMetadata } from '../../build/sdk-generation/normalized/typescript/api' + +const values: EffectivePolicyValue[] = [true, 42, 1.5, 'value', { nested: {} }] +// @ts-expect-error arrays are not policy values +const invalidArray: EffectivePolicyValue = ['not a policy value'] +// @ts-expect-error undefined is not a policy value +const invalidUndefined: EffectivePolicyValue = undefined +// Known remaining limitation: nullable on this union is lost by the generator. +// @ts-expect-error the generated union still rejects schema-valid null +const nullable: EffectivePolicyValue = null +function file(value: FileSummary): FileListResponseDataInner { return value } +function metadata(value: ValidateMetadata): FileRuntimeMetadata { return value } +const objectMetadata: FileRuntimeMetadata = { custom: {} } +// @ts-expect-error scalar is not a file object +const invalidFile: FileListResponseDataInner = 42 +// @ts-expect-error scalar is not runtime metadata +const invalidMetadata: FileRuntimeMetadata = false +void [values, invalidArray, invalidUndefined, nullable, file, metadata, objectMetadata, invalidFile, invalidMetadata] diff --git a/tests/sdk-generation/package-lock.json b/tests/sdk-generation/package-lock.json index 642af6956a..b033d640d8 100644 --- a/tests/sdk-generation/package-lock.json +++ b/tests/sdk-generation/package-lock.json @@ -9,7 +9,8 @@ "version": "1.0.0", "license": "AGPL-3.0-or-later", "dependencies": { - "axios": "1.9.0" + "@nextcloud/axios": "2.6.0", + "axios": "1.20.0" }, "devDependencies": { "@types/node": "22.15.21", @@ -459,6 +460,88 @@ "node": ">=18" } }, + "node_modules/@nextcloud/auth": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@nextcloud/auth/-/auth-2.6.0.tgz", + "integrity": "sha512-VkT87+9UqpPi7O36bVEE4/MxWF8d90VQcuMlvKltsZyLSLkEGrPXgowtD75Y54k60/8SR6mXbeqBwapi8dDUbA==", + "license": "GPL-3.0-or-later", + "dependencies": { + "@nextcloud/browser-storage": "^0.5.0", + "@nextcloud/event-bus": "^3.3.3", + "@nextcloud/router": "^3.1.0" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || ^24.0.0" + } + }, + "node_modules/@nextcloud/axios": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@nextcloud/axios/-/axios-2.6.0.tgz", + "integrity": "sha512-ehcIgyora8DAJ+STG6iFI4e+ufPVFrIA6o0FgMKeKdfyaxRJ9UM7L+n7V+rc/qv8sDiWC/hWIKwFtLw2W5yE4Q==", + "license": "GPL-3.0-or-later", + "dependencies": { + "@nextcloud/auth": "^2.6.0", + "axios": "^1.15.0" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || ^24.0.0" + } + }, + "node_modules/@nextcloud/browser-storage": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@nextcloud/browser-storage/-/browser-storage-0.5.0.tgz", + "integrity": "sha512-usYr4GlJQlK3hgZURvklqWb9ivi7sgsSuFqXrs7s4hl1LTS4enzPrnkQumm6nRsQruf0ITS+OBsK+oELEbvYPA==", + "license": "GPL-3.0-or-later", + "engines": { + "node": "^24 || ^22 || ^20" + } + }, + "node_modules/@nextcloud/event-bus": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/@nextcloud/event-bus/-/event-bus-3.3.3.tgz", + "integrity": "sha512-zIfvKmUGkXpVzRKoXrcO9hkoiKDm65fqNxy/XIbIxrQhZByPq3gDkjBpnu3V5Gs8JdYwa73R8DjzV9oH8HYhIg==", + "license": "GPL-3.0-or-later", + "dependencies": { + "@types/semver": "^7.7.0", + "semver": "^7.7.2" + }, + "engines": { + "node": "^20 || ^22 || ^24" + } + }, + "node_modules/@nextcloud/router": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@nextcloud/router/-/router-3.2.0.tgz", + "integrity": "sha512-an4gJ7mlDZGtYq8zTxp4Sg+iLlKKGvQ9ZH3Dp6ga/IlDNAP7VeMVGphsY798ORjncAp9+sEf370L5zpsnuxgng==", + "license": "GPL-3.0-or-later", + "dependencies": { + "@nextcloud/typings": "^1.10.0" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || ^24.0.0" + } + }, + "node_modules/@nextcloud/typings": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@nextcloud/typings/-/typings-1.10.0.tgz", + "integrity": "sha512-SMC42rDjOH3SspPTLMZRv76ZliHpj2JJkF8pGLP8l1QrVTZxE47Qz5qeKmbj2VL+dRv2e/NgixlAFmzVnxkhqg==", + "license": "GPL-3.0-or-later", + "dependencies": { + "@types/jquery": "3.5.16" + }, + "engines": { + "node": "^20.0.0 || ^22.0.0 || ^24.0.0" + } + }, + "node_modules/@types/jquery": { + "version": "3.5.16", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.16.tgz", + "integrity": "sha512-bsI7y4ZgeMkmpG9OM710RRzDFp+w4P1RGiIt30C1mSBT+ExCleeh4HObwgArnDFELmRrOpXgSYN9VF1hj+f1lw==", + "license": "MIT", + "dependencies": { + "@types/sizzle": "*" + } + }, "node_modules/@types/node": { "version": "22.15.21", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.21.tgz", @@ -469,6 +552,30 @@ "undici-types": "~6.21.0" } }, + "node_modules/@types/semver": { + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.8.0.tgz", + "integrity": "sha512-1mAINjtQCXXeLkJ9ehXkwOcBpqtLxiVtKhpUf83DdRNdQKV0iXZpaHYqRr7nj+wvxuJzoAmAwXI+sCNMv1CzLQ==", + "license": "MIT" + }, + "node_modules/@types/sizzle": { + "version": "2.3.10", + "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.10.tgz", + "integrity": "sha512-TC0dmN0K8YcWEAEfiPi5gJP14eJe30TTGjkvek3iM/1NdHHsdCA/Td6GvNndMOo/iSnIsZ4HuuhrYPDAmbxzww==", + "license": "MIT" + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -476,14 +583,15 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz", - "integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.20.0.tgz", + "integrity": "sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==", "license": "MIT", "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" + "follow-redirects": "^1.16.0", + "form-data": "^4.0.6", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" } }, "node_modules/call-bind-apply-helpers": { @@ -511,6 +619,23 @@ "node": ">= 0.8" } }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -782,6 +907,19 @@ "node": ">= 0.4" } }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -812,12 +950,21 @@ "node": ">= 0.6" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "license": "MIT" }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/resolve-pkg-maps": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", @@ -828,6 +975,18 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, + "node_modules/semver": { + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/tsx": { "version": "4.19.4", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.19.4.tgz", diff --git a/tests/sdk-generation/package.json b/tests/sdk-generation/package.json index 0fe6f75a9c..5f6f0547d9 100644 --- a/tests/sdk-generation/package.json +++ b/tests/sdk-generation/package.json @@ -7,10 +7,13 @@ "compile": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/typescript/*.ts types.ts transport.ts live.ts", "test": "tsx transport.ts && node inventory.cjs", "test:live": "tsx live.ts", - "test:anyof": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node anyof-negative.ts" + "test:anyof": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node anyof-negative.ts", + "test:normalized": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/normalized/typescript/*.ts normalized-types.ts", + "test:nextcloud": "node nextcloud-import.mjs" }, "dependencies": { - "axios": "1.9.0" + "@nextcloud/axios": "2.6.0", + "axios": "1.20.0" }, "devDependencies": { "@types/node": "22.15.21", diff --git a/tests/sdk-generation/transport.ts b/tests/sdk-generation/transport.ts index 98d0e43f03..01ef2d587c 100644 --- a/tests/sdk-generation/transport.ts +++ b/tests/sdk-generation/transport.ts @@ -18,7 +18,7 @@ async function run() { return response } const instance = axios.create({ adapter, headers: { 'X-Instance': 'injected' } }) - const configuration = new Configuration({ basePath: 'https://example.test/nextcloud', username: 'test', password: 'secret', accessToken: 'synthetic-token' }) + const configuration = new Configuration({ basePath: 'https://example.test/nextcloud', username: 'test', password: 'secret' }) const identity = new IdentityApi(configuration, undefined, instance) const account = await identity.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }) assert.equal(last.url, 'https://example.test/nextcloud/ocs/v2.php/apps/libresign/api/v1/account/me') @@ -26,11 +26,14 @@ async function run() { assert.equal(last.headers.get('OCS-APIRequest'), 'true') assert.equal(last.headers.get('X-Instance'), 'injected') assert.deepEqual(last.auth, { username: 'test', password: 'secret' }) + assert.equal(last.headers.get('Authorization'), undefined) assert.equal(account.data.ocs.data.account.uid, 'test') - const policies = new PoliciesApi(configuration, undefined, instance) + const bearerConfiguration = new Configuration({ basePath: configuration.basePath, accessToken: 'synthetic-token' }) + const policies = new PoliciesApi(bearerConfiguration, undefined, instance) await policies.policyGetSystem({ apiVersion: 'v1', policyKey: 'a/b ?', oCSAPIRequest: true }) assert.equal(last.url, 'https://example.test/nextcloud/ocs/v2.php/apps/libresign/api/v1/policies/system/a%2Fb%20%3F') assert.equal(last.headers.get('Authorization'), 'Bearer synthetic-token') + assert.equal(last.auth, undefined) const requests = new RequestsApi(configuration, undefined, instance) await requests.requestSignatureRequestSignature({ apiVersion: 'v1', oCSAPIRequest: true, requestSignatureRequestSignatureRequest: { name: 'Example', file: { nodeId: '123' } } }) assert.equal(last.method, 'post') @@ -56,13 +59,13 @@ async function run() { await new DocumentsApi(configuration, undefined, instance).fileSave({ apiVersion: 'v1', oCSAPIRequest: true, fileSaveRequest: { file: { nodeId: 123 } } }) assert.match(String(last.headers.get('Content-Type')), /application\/json/) assert.deepEqual(JSON.parse(String(last.data)), { file: { nodeId: 123 } }) - const supplied = axios.create({ adapter, baseURL: 'https://example.test/nextcloud' }) + const supplied = axios.create({ adapter, baseURL: 'https://instance.test/installed' }) const suppliedIdentity = new IdentityApi(configuration, undefined, supplied) await suppliedIdentity.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }) - assert.equal(supplied.getUri(last), 'https://example.test/nextcloud/ocs/v2.php/apps/libresign/api/v1/account/me') + assert.equal(supplied.getUri(last), 'https://instance.test/installed/ocs/v2.php/apps/libresign/api/v1/account/me') const suppliedCertificates = new CertificatesApi(configuration, undefined, supplied) await suppliedCertificates.certificatePolicyGetCertificatePolicy({ responseType: 'arraybuffer' }) - assert.equal(supplied.getUri(last), 'https://example.test/nextcloud/index.php/apps/libresign/certificate-policy.pdf') - console.log('PASS: generated transport, root/subdirectory paths, auth, JSON, binary options and HTTP errors') + assert.equal(supplied.getUri(last), 'https://instance.test/installed/index.php/apps/libresign/certificate-policy.pdf') + console.log('PASS: generated transport, root/subdirectory paths, independent basic/bearer auth, baseURL precedence, JSON, binary options and HTTP errors') } run().catch(error => { console.error(error); process.exitCode = 1 }) From a2aa59f6c462045863cafac7d0435c3663b3ecaf Mon Sep 17 00:00:00 2001 From: Luis Amorim Date: Wed, 11 Nov 2026 01:02:15 -0300 Subject: [PATCH 3/4] fix(sdk): satisfy eslint curly and package-json sort Signed-off-by: Luis Amorim Co-authored-by: Cursor --- tests/sdk-generation/inventory.cjs | 38 ++++++++++++++++-------- tests/sdk-generation/live.ts | 23 ++++++++++---- tests/sdk-generation/normalize-input.cjs | 16 +++++++--- tests/sdk-generation/package.json | 8 ++--- tests/sdk-generation/transport.ts | 4 ++- 5 files changed, 61 insertions(+), 28 deletions(-) diff --git a/tests/sdk-generation/inventory.cjs b/tests/sdk-generation/inventory.cjs index a2d4acfc4c..4b5ea7e5f1 100644 --- a/tests/sdk-generation/inventory.cjs +++ b/tests/sdk-generation/inventory.cjs @@ -11,7 +11,9 @@ const spec = JSON.parse(fs.readFileSync(path.join(root, 'openapi-full.json'))) const source = ts.createSourceFile('api.ts', fs.readFileSync(path.join(dir, 'api.ts'), 'utf8'), ts.ScriptTarget.Latest, true) const classes = new Map() for (const node of source.statements) { - if (!ts.isClassDeclaration(node) || !node.name) continue + if (!ts.isClassDeclaration(node) || !node.name) { + continue + } classes.set(node.name.text, new Set(node.members.filter(ts.isMethodDeclaration).map(m => m.name.getText(source)))) } const generated = new Map() @@ -21,26 +23,36 @@ for (const tag of ['policies', 'identity', 'documents', 'requests', 'signing', ' const rows = [...doc.matchAll(/^\|\[\*\*(\w+)\*\*\]\([^\n]*?\| \*\*(GET|POST|PUT|DELETE|PATCH)\*\* ([^ |]+)/gm)] for (const [, method, verb, url] of rows) { const key = `${verb} ${url}` - if (!generated.has(key)) generated.set(key, []) + if (!generated.has(key)) { + generated.set(key, []) + } generated.get(key).push({ name, method, exists: classes.get(name)?.has(method) === true }) } } const rows = [] const ids = new Set() let errors = 0 -for (const [url, operations] of Object.entries(spec.paths)) for (const [verb, op] of Object.entries(operations)) { - if (!['get', 'post', 'put', 'delete', 'patch'].includes(verb)) continue - const key = `${verb.toUpperCase()} ${url}` - const found = generated.get(key) || [] - const expected = op.tags[0][0].toUpperCase() + op.tags[0].slice(1) + 'Api' - const ok = !ids.has(op.operationId) && found.length === 1 && found[0].name === expected && found[0].exists - ids.add(op.operationId) - if (!ok) errors++ - rows.push(`| ${op.operationId} | ${key} | ${found.map(x => `${x.name}.${x.method}${x.exists ? '' : ' (missing)'}`).join(', ') || 'MISSING'} | ${ok ? 'OK' : 'FAIL'} |`) - generated.delete(key) +for (const [url, operations] of Object.entries(spec.paths)) { + for (const [verb, op] of Object.entries(operations)) { + if (!['get', 'post', 'put', 'delete', 'patch'].includes(verb)) { + continue + } + const key = `${verb.toUpperCase()} ${url}` + const found = generated.get(key) || [] + const expected = op.tags[0][0].toUpperCase() + op.tags[0].slice(1) + 'Api' + const ok = !ids.has(op.operationId) && found.length === 1 && found[0].name === expected && found[0].exists + ids.add(op.operationId) + if (!ok) { + errors++ + } + rows.push(`| ${op.operationId} | ${key} | ${found.map(x => `${x.name}.${x.method}${x.exists ? '' : ' (missing)'}`).join(', ') || 'MISSING'} | ${ok ? 'OK' : 'FAIL'} |`) + generated.delete(key) + } } errors += generated.size const output = ['', '', '# Generated operation inventory', '', '| operationId | HTTP operation | Generated class.method | Result |', '| --- | --- | --- | --- |', ...rows, '', `${rows.length} input operations; ${errors} inventory errors. Presence does not establish serialization compatibility.`, ''].join('\n') fs.writeFileSync(path.join(root, 'build/sdk-generation/inventory.md'), output) console.log(`${rows.length} operations; ${errors} inventory errors; build/sdk-generation/inventory.md`) -if (errors) process.exitCode = 1 +if (errors) { + process.exitCode = 1 +} diff --git a/tests/sdk-generation/live.ts b/tests/sdk-generation/live.ts index 812706de52..4be9a74f09 100644 --- a/tests/sdk-generation/live.ts +++ b/tests/sdk-generation/live.ts @@ -12,9 +12,13 @@ async function main() { const basePath = process.env.SDK_TEST_URL const username = process.env.SDK_TEST_USER const password = process.env.SDK_TEST_PASSWORD - if (!basePath || !username || !password) throw new Error('Set SDK_TEST_URL, SDK_TEST_USER and SDK_TEST_PASSWORD') + if (!basePath || !username || !password) { + throw new Error('Set SDK_TEST_URL, SDK_TEST_USER and SDK_TEST_PASSWORD') + } const url = new URL(basePath) - if (url.protocol !== 'https:' || !(url.hostname === 'localhost' || url.hostname.endsWith('.localhost'))) throw new Error('Only local HTTPS Nextcloud instances are supported') + if (url.protocol !== 'https:' || !(url.hostname === 'localhost' || url.hostname.endsWith('.localhost'))) { + throw new Error('Only local HTTPS Nextcloud instances are supported') + } // NCDD uses a local self-signed certificate; never use this for remote hosts. const instance = axios.create({ httpsAgent: new Agent({ rejectUnauthorized: false }), proxy: false, timeout: 15000 }) const config = new Configuration({ basePath, username, password }) @@ -47,16 +51,23 @@ async function main() { assert.equal(Buffer.from(pdf.data as unknown as ArrayBuffer).subarray(0, 5).toString(), '%PDF-') console.log('certificate-policy: HTTP 200, PDF content type and bytes verified') } catch (error) { - if (!axios.isAxiosError(error) || error.response?.status !== 404) throw error + if (!axios.isAxiosError(error) || error.response?.status !== 404) { + throw error + } console.log('certificate-policy: HTTP 404 (no configured policy PDF); binary response not verified') } const invalid = new IdentityApi(new Configuration({ basePath, username, password: 'deliberately-invalid-test-password' }), undefined, instance) await assert.rejects(() => invalid.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }), (error: unknown) => axios.isAxiosError(error) && (error.response?.status === 401 || error.response?.status === 403)) console.log('account-me with invalid credentials: HTTP authentication error verified') - if (failed) process.exitCode = 1 + if (failed) { + process.exitCode = 1 + } } main().catch(error => { - if (axios.isAxiosError(error)) console.error('Live request failed with HTTP status', error.response?.status ?? 'unavailable', 'code', error.code ?? 'none') - else console.error(error instanceof Error ? error.message : 'Live test failed') + if (axios.isAxiosError(error)) { + console.error('Live request failed with HTTP status', error.response?.status ?? 'unavailable', 'code', error.code ?? 'none') + } else { + console.error(error instanceof Error ? error.message : 'Live test failed') + } process.exitCode = 1 }) diff --git a/tests/sdk-generation/normalize-input.cjs b/tests/sdk-generation/normalize-input.cjs index 57a5a1acc2..8c447eed27 100644 --- a/tests/sdk-generation/normalize-input.cjs +++ b/tests/sdk-generation/normalize-input.cjs @@ -12,11 +12,19 @@ const root = path.resolve(__dirname, '../..') const target = path.join(root, 'build/sdk-generation/normalized/openapi-full.oneof.json') let rewritten = 0 function normalize(value) { - if (Array.isArray(value)) return value.map(normalize) - if (value === null || typeof value !== 'object') return value + if (Array.isArray(value)) { + return value.map(normalize) + } + if (value === null || typeof value !== 'object') { + return value + } const isUnion = Array.isArray(value.anyOf) - if (isUnion && 'oneOf' in value) throw new Error('Schema declares both anyOf and oneOf') - if (isUnion) rewritten++ + if (isUnion && 'oneOf' in value) { + throw new Error('Schema declares both anyOf and oneOf') + } + if (isUnion) { + rewritten++ + } return Object.fromEntries(Object.entries(value).map(([key, item]) => [isUnion && key === 'anyOf' ? 'oneOf' : key, normalize(item)])) } const output = normalize(JSON.parse(fs.readFileSync(path.join(root, 'openapi-full.json'), 'utf8'))) diff --git a/tests/sdk-generation/package.json b/tests/sdk-generation/package.json index 5f6f0547d9..775d6aaa08 100644 --- a/tests/sdk-generation/package.json +++ b/tests/sdk-generation/package.json @@ -1,15 +1,15 @@ { "name": "libresign-sdk-generation-evaluation", - "private": true, "version": "1.0.0", + "private": true, "license": "AGPL-3.0-or-later", "scripts": { "compile": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/typescript/*.ts types.ts transport.ts live.ts", "test": "tsx transport.ts && node inventory.cjs", - "test:live": "tsx live.ts", "test:anyof": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node anyof-negative.ts", - "test:normalized": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/normalized/typescript/*.ts normalized-types.ts", - "test:nextcloud": "node nextcloud-import.mjs" + "test:live": "tsx live.ts", + "test:nextcloud": "node nextcloud-import.mjs", + "test:normalized": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/normalized/typescript/*.ts normalized-types.ts" }, "dependencies": { "@nextcloud/axios": "2.6.0", diff --git a/tests/sdk-generation/transport.ts b/tests/sdk-generation/transport.ts index 01ef2d587c..87014cc3d3 100644 --- a/tests/sdk-generation/transport.ts +++ b/tests/sdk-generation/transport.ts @@ -14,7 +14,9 @@ async function run() { const adapter: AxiosAdapter = async config => { last = config const response = { data: body, status, statusText: String(status), headers: {}, config } - if (config.validateStatus && !config.validateStatus(status)) throw new AxiosError('HTTP error', 'ERR_BAD_RESPONSE', config, undefined, response) + if (config.validateStatus && !config.validateStatus(status)) { + throw new AxiosError('HTTP error', 'ERR_BAD_RESPONSE', config, undefined, response) + } return response } const instance = axios.create({ adapter, headers: { 'X-Instance': 'injected' } }) From 04b791ba281ac817d2f4473e3e4f68c47603e4d8 Mon Sep 17 00:00:00 2001 From: Luis Amorim Date: Thu, 12 Nov 2026 11:35:11 -0300 Subject: [PATCH 4/4] test(sdk): address compatibility evaluation review Make anyOf defect reproduction fail for missing or corrected generated types. Clear validated generation output safely and cover stale files and path boundaries. Continue live checks after PDF failures and require HTTP 401 for invalid credentials. Co-authored-by: Codex Signed-off-by: Luis Amorim --- tests/sdk-generation/README.md | 19 ++++++--- tests/sdk-generation/REPORT.md | 8 ++-- tests/sdk-generation/anyof-defect.ts | 9 ++++ tests/sdk-generation/anyof-negative.ts | 10 ----- tests/sdk-generation/generate.sh | 18 +++++++- tests/sdk-generation/generate.test.cjs | 45 ++++++++++++++++++++ tests/sdk-generation/live.test.ts | 37 ++++++++++++++++ tests/sdk-generation/live.ts | 58 +++++++++++++++----------- tests/sdk-generation/package.json | 6 +-- 9 files changed, 161 insertions(+), 49 deletions(-) create mode 100644 tests/sdk-generation/anyof-defect.ts delete mode 100644 tests/sdk-generation/anyof-negative.ts create mode 100644 tests/sdk-generation/generate.test.cjs create mode 100644 tests/sdk-generation/live.test.ts diff --git a/tests/sdk-generation/README.md b/tests/sdk-generation/README.md index 8a50af2923..98b66ff0ef 100644 --- a/tests/sdk-generation/README.md +++ b/tests/sdk-generation/README.md @@ -18,9 +18,11 @@ npm test --prefix tests/sdk-generation npm run test:anyof --prefix tests/sdk-generation ``` -The last command currently **fails intentionally**: TS2578 demonstrates that -an invalid array is accepted by the generated `EffectivePolicyValue`. Any other -failure must be investigated separately. `npm test` checks transport and writes +The last command **passes while the known defect exists**: it assigns an invalid +array to the generated `EffectivePolicyValue` without suppressing diagnostics. +A missing client fails with TS2307; a corrected type that rejects arrays fails +with TS2322 and requires reevaluating the No-Go report. `npm test` checks +transport, generation cleanup and live-check error handling, and writes the generated operation inventory to `build/sdk-generation/inventory.md`. Compare that inventory with the checked-in evaluation snapshot when changing the specification. This does not prove every operation's runtime serialization. @@ -28,8 +30,10 @@ specification. This does not prove every operation's runtime serialization. The generator validates the full specification first and never uses `--skip-validate-spec`. Its Docker image digest pins OpenAPI Generator 7.27.0; `useSingleRequestParameter=true` is enabled. npm dependencies are pinned by -`package-lock.json`. Use fresh output directories: the generator does not remove -stale files. Generated code stays under ignored `build/` and must not be edited. +`package-lock.json`. After validating the input, the script clears only the +selected output subdirectory before generation. It rejects the build root, +symlinked output paths and inputs inside the output directory. Generated code +stays under ignored `build/` and must not be edited. See [REPORT.md](REPORT.md) and [inventory.md](inventory.md) for results. ## Normalized-input experiment @@ -72,4 +76,7 @@ requests plus one deliberately invalid authentication attempt. It requires a local instance and is not part of the deterministic harness. It accepts only localhost hostnames and disables TLS certificate verification for the local development proxy; do not use it with remote systems. The PDF check reports a -404 as unverified when no certificate policy PDF is configured. +404 as unverified when no certificate policy PDF is configured. Other PDF errors +mark the run as failed but still allow the invalid-credentials check to run. +That check requires HTTP 401; HTTP 403 and 429 do not count as authentication +success for this negative test. diff --git a/tests/sdk-generation/REPORT.md b/tests/sdk-generation/REPORT.md index 856e1318e1..5afd01fba7 100644 --- a/tests/sdk-generation/REPORT.md +++ b/tests/sdk-generation/REPORT.md @@ -48,9 +48,11 @@ single-request-parameter configuration; use actual class signatures. Strict compilation with `skipLibCheck` passes. `types.ts` tests number/string `NewFile.nodeId` (rejecting boolean), inherited/local `SignerDetail` fields, -nullable/optional fields and enums. `test:anyof` exits 2 with TS2578, an unused -`@ts-expect-error`: the generated empty interface accepts an invalid policy -array. This is a failed acceptance criterion, not a passing test. +nullable/optional fields and enums. `test:anyof` exits 0 because the generated +empty interface accepts an invalid policy array. This is a passing reproduction +of a failed SDK acceptance criterion, so the decision remains No-Go. The fixture +has no error suppression: missing generated output fails with TS2307; a type +that rejects arrays fails with TS2322, requiring the report to be reevaluated. The controlled Axios adapter tests generated calls for account GET and typed OCS envelope, encoded policy path and simulated HTTP 403, signature-request diff --git a/tests/sdk-generation/anyof-defect.ts b/tests/sdk-generation/anyof-defect.ts new file mode 100644 index 0000000000..e23577beb6 --- /dev/null +++ b/tests/sdk-generation/anyof-defect.ts @@ -0,0 +1,9 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import type { EffectivePolicyValue } from '../../build/sdk-generation/typescript/api' +// This defect-reproduction check passes only while invalid arrays are accepted. +// Missing generated output or a corrected union must fail compilation. +const accepted: EffectivePolicyValue = ['not a policy value'] +void accepted diff --git a/tests/sdk-generation/anyof-negative.ts b/tests/sdk-generation/anyof-negative.ts deleted file mode 100644 index 63950cd0bf..0000000000 --- a/tests/sdk-generation/anyof-negative.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -import type { EffectivePolicyValue } from '../../build/sdk-generation/typescript/api' -// Arrays are not one of the allowed anyOf alternatives. An unused directive -// means the generated type incorrectly accepts the invalid value. -// @ts-expect-error arrays are not policy values -const invalid: EffectivePolicyValue = ['not a policy value'] -void invalid diff --git a/tests/sdk-generation/generate.sh b/tests/sdk-generation/generate.sh index 815864f1ad..9695e66718 100755 --- a/tests/sdk-generation/generate.sh +++ b/tests/sdk-generation/generate.sh @@ -12,9 +12,23 @@ image='openapitools/openapi-generator-cli@sha256:949efd0d5cf3c093ef169887b2ebe08 output=${1:-build/sdk-generation/typescript} input=${2:-openapi-full.json} case "$output$input" in *..*) echo 'Paths must not contain ..' >&2; exit 1;; esac -case "$output" in build/sdk-generation/*) ;; *) echo 'Output must be under build/sdk-generation/' >&2; exit 1;; esac +case "$output" in build/sdk-generation/?*) ;; *) echo 'Output must be under build/sdk-generation/' >&2; exit 1;; esac case "$input" in openapi-full.json|build/sdk-generation/*) ;; *) echo 'Input must be openapi-full.json or a copy under build/sdk-generation/' >&2; exit 1;; esac cd "$root" -mkdir -p "$output" +# Keep cleanup inside build/ and prevent aliases from hiding input/output overlap. +for candidate in "$output" "$input"; do + case "$candidate" in */.|*/./*|*//*|*/) echo 'Paths must not contain dot or empty components' >&2; exit 1;; esac + ancestor=$candidate + while [ "$ancestor" != . ]; do + if [ -L "$ancestor" ]; then + echo 'Input/output paths and their ancestors must not be symlinks' >&2 + exit 1 + fi + ancestor=$(dirname -- "$ancestor") + done +done +case "$input" in "$output"|"$output"/*) echo 'Input must be outside the output directory' >&2; exit 1;; esac docker run --rm --user "$(id -u):$(id -g)" -v "$root:/local" "$image" validate -i "/local/$input" +rm -rf -- "$output" +mkdir -p "$output" docker run --rm --user "$(id -u):$(id -g)" -v "$root:/local" "$image" generate -i "/local/$input" -g typescript-axios -o "/local/$output" --additional-properties=useSingleRequestParameter=true diff --git a/tests/sdk-generation/generate.test.cjs b/tests/sdk-generation/generate.test.cjs new file mode 100644 index 0000000000..435df703c2 --- /dev/null +++ b/tests/sdk-generation/generate.test.cjs @@ -0,0 +1,45 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +const assert = require('node:assert/strict') +const fs = require('node:fs') +const os = require('node:os') +const path = require('node:path') +const { spawnSync } = require('node:child_process') +const { test } = require('node:test') + +test('generation clears only its output and protects inputs and build siblings', () => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), 'sdk-generation-')) + try { + fs.mkdirSync(path.join(root, 'tests/sdk-generation'), { recursive: true }) + fs.mkdirSync(path.join(root, 'build/sdk-generation/typescript'), { recursive: true }) + fs.mkdirSync(path.join(root, 'bin')) + const script = path.join(root, 'tests/sdk-generation/generate.sh') + fs.copyFileSync(path.join(__dirname, 'generate.sh'), script) + // Stub Docker: test filesystem behavior without generating or editing a client. + fs.writeFileSync(path.join(root, 'bin/docker'), '#!/bin/sh\nexit 0\n', { mode: 0o755 }) + fs.writeFileSync(path.join(root, 'build/sdk-generation/keep'), 'sibling') + const output = path.join(root, 'build/sdk-generation/typescript') + fs.writeFileSync(path.join(output, 'stale.ts'), 'stale') + const run = (...args) => spawnSync('sh', [script, ...args], { + encoding: 'utf8', env: { ...process.env, PATH: `${root}/bin:${process.env.PATH}` }, + }) + assert.equal(run().status, 0) + assert.equal(fs.existsSync(path.join(output, 'stale.ts')), false) + assert.equal(fs.readFileSync(path.join(root, 'build/sdk-generation/keep'), 'utf8'), 'sibling') + for (const invalid of ['build/sdk-generation/', 'build/sdk-generation/.', 'build/sdk-generation//', 'build/sdk-generation/./', 'build/sdk-generation/../', 'src']) { + assert.notEqual(run(invalid).status, 0, invalid) + } + fs.writeFileSync(path.join(output, 'input.json'), '{}') + assert.notEqual(run('build/sdk-generation/typescript', 'build/sdk-generation/typescript/input.json').status, 0) + assert.equal(fs.existsSync(path.join(output, 'input.json')), true) + assert.notEqual(run('build/sdk-generation/typescript', 'build/sdk-generation/./typescript/input.json').status, 0) + fs.symlinkSync(output, path.join(root, 'build/sdk-generation/link')) + assert.notEqual(run('build/sdk-generation/link/child').status, 0) + assert.notEqual(run('build/sdk-generation/typescript', 'build/sdk-generation/link/input.json').status, 0) + assert.equal(fs.existsSync(path.join(output, 'input.json')), true) + } finally { + fs.rmSync(root, { recursive: true, force: true }) + } +}) diff --git a/tests/sdk-generation/live.test.ts b/tests/sdk-generation/live.test.ts new file mode 100644 index 0000000000..2637665958 --- /dev/null +++ b/tests/sdk-generation/live.test.ts @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import * as assert from 'node:assert/strict' +import { test } from 'node:test' +import axios, { AxiosError } from 'axios' +import { runLiveChecks } from './live' + +for (const pdfStatus of [200, 404, 500]) { + for (const authStatus of [200, 401, 403, 429]) { + test(`PDF ${pdfStatus}, invalid credentials ${authStatus}`, async () => { + let invalidAuthChecked = false + const instance = axios.create({ adapter: async config => { + const invalidAuth = config.auth?.password === 'deliberately-invalid-test-password' + const pdf = config.url?.endsWith('.pdf') + invalidAuthChecked ||= invalidAuth + const status = invalidAuth ? authStatus : pdf ? pdfStatus : 200 + const response = { + config, status, statusText: String(status), headers: { 'content-type': 'application/pdf' }, + data: pdf ? Buffer.from('%PDF-test') : { ocs: { meta: { statuscode: 200 }, data: { account: { uid: 'test' } } } }, + } + if (status >= 400) { + throw new AxiosError('Synthetic HTTP error', 'ERR_BAD_RESPONSE', config, undefined, response) + } + return response + } }) + const run = () => runLiveChecks('https://localhost', 'test', 'synthetic-password', instance) + if (authStatus === 401) { + assert.equal(await run(), pdfStatus !== 500) + } else { + await assert.rejects(run) + } + assert.equal(invalidAuthChecked, true, 'Authentication must be checked even after PDF failure') + }) + } +} diff --git a/tests/sdk-generation/live.ts b/tests/sdk-generation/live.ts index 4be9a74f09..ee3a28dbe5 100644 --- a/tests/sdk-generation/live.ts +++ b/tests/sdk-generation/live.ts @@ -4,7 +4,7 @@ */ import * as assert from 'node:assert/strict' import { Agent } from 'node:https' -import axios from 'axios' +import axios, { type AxiosInstance } from 'axios' import { CertificatesApi, IdentityApi, PoliciesApi } from '../../build/sdk-generation/typescript/api' import { Configuration } from '../../build/sdk-generation/typescript/configuration' @@ -21,25 +21,31 @@ async function main() { } // NCDD uses a local self-signed certificate; never use this for remote hosts. const instance = axios.create({ httpsAgent: new Agent({ rejectUnauthorized: false }), proxy: false, timeout: 15000 }) + if (!await runLiveChecks(basePath, username, password, instance)) { + process.exitCode = 1 + } +} + +export async function runLiveChecks(basePath: string, username: string, password: string, instance: AxiosInstance): Promise { const config = new Configuration({ basePath, username, password }) const identity = new IdentityApi(config, undefined, instance) let failed = false try { - const account = await identity.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }) - assert.equal(account.status, 200) - assert.equal(account.data.ocs.meta.statuscode, 200) - assert.equal(typeof account.data.ocs.data.account.uid, 'string') - console.log('account-me: HTTP 200, OCS envelope and typed account fields verified') + const account = await identity.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }) + assert.equal(account.status, 200) + assert.equal(account.data.ocs.meta.statuscode, 200) + assert.equal(typeof account.data.ocs.data.account.uid, 'string') + console.log('account-me: HTTP 200, OCS envelope and typed account fields verified') } catch (error) { failed = true console.log('account-me failed: HTTP', axios.isAxiosError(error) ? error.response?.status : 'assertion failure') } try { - const policy = await new PoliciesApi(config, undefined, instance).policyGetSystem({ apiVersion: 'v1', policyKey: 'signature_flow', oCSAPIRequest: true }) - assert.equal(policy.status, 200) - assert.equal(typeof policy.data.ocs.meta.statuscode, 'number') - assert.ok(policy.data.ocs.data) - console.log('policy-get-system: HTTP 200, OCS envelope verified with administrator') + const policy = await new PoliciesApi(config, undefined, instance).policyGetSystem({ apiVersion: 'v1', policyKey: 'signature_flow', oCSAPIRequest: true }) + assert.equal(policy.status, 200) + assert.equal(typeof policy.data.ocs.meta.statuscode, 'number') + assert.ok(policy.data.ocs.data) + console.log('policy-get-system: HTTP 200, OCS envelope verified with administrator') } catch (error) { failed = true console.log('policy-get-system failed: HTTP', axios.isAxiosError(error) ? error.response?.status : 'assertion failure') @@ -52,22 +58,24 @@ async function main() { console.log('certificate-policy: HTTP 200, PDF content type and bytes verified') } catch (error) { if (!axios.isAxiosError(error) || error.response?.status !== 404) { - throw error + failed = true + console.log('certificate-policy failed: HTTP', axios.isAxiosError(error) ? error.response?.status : 'assertion failure') + } else { + console.log('certificate-policy: HTTP 404 (no configured policy PDF); binary response not verified') } - console.log('certificate-policy: HTTP 404 (no configured policy PDF); binary response not verified') } const invalid = new IdentityApi(new Configuration({ basePath, username, password: 'deliberately-invalid-test-password' }), undefined, instance) - await assert.rejects(() => invalid.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }), (error: unknown) => axios.isAxiosError(error) && (error.response?.status === 401 || error.response?.status === 403)) - console.log('account-me with invalid credentials: HTTP authentication error verified') - if (failed) { + await assert.rejects(() => invalid.accountMe({ apiVersion: 'v1', oCSAPIRequest: true }), (error: unknown) => axios.isAxiosError(error) && error.response?.status === 401) + console.log('account-me with invalid credentials: HTTP 401 verified') + return !failed +} +if (require.main === module) { + main().catch(error => { + if (axios.isAxiosError(error)) { + console.error('Live request failed with HTTP status', error.response?.status ?? 'unavailable', 'code', error.code ?? 'none') + } else { + console.error(error instanceof Error ? error.message : 'Live test failed') + } process.exitCode = 1 - } + }) } -main().catch(error => { - if (axios.isAxiosError(error)) { - console.error('Live request failed with HTTP status', error.response?.status ?? 'unavailable', 'code', error.code ?? 'none') - } else { - console.error(error instanceof Error ? error.message : 'Live test failed') - } - process.exitCode = 1 -}) diff --git a/tests/sdk-generation/package.json b/tests/sdk-generation/package.json index 775d6aaa08..63f580cc43 100644 --- a/tests/sdk-generation/package.json +++ b/tests/sdk-generation/package.json @@ -4,9 +4,9 @@ "private": true, "license": "AGPL-3.0-or-later", "scripts": { - "compile": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/typescript/*.ts types.ts transport.ts live.ts", - "test": "tsx transport.ts && node inventory.cjs", - "test:anyof": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node anyof-negative.ts", + "compile": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/typescript/*.ts types.ts transport.ts live.ts live.test.ts", + "test": "tsx transport.ts && node inventory.cjs && tsx --test live.test.ts && node --test generate.test.cjs", + "test:anyof": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node anyof-defect.ts", "test:live": "tsx live.ts", "test:nextcloud": "node nextcloud-import.mjs", "test:normalized": "tsc --noEmit --strict --skipLibCheck --target ES2020 --module commonjs --moduleResolution node ../../build/sdk-generation/normalized/typescript/*.ts normalized-types.ts"