Skip to content

Test(cloud-suite): Carry the M3d GraphQL gateway scenarios over to the cloud suite - #4501

Open
randilt wants to merge 35 commits into
wso2:mainfrom
randilt:test/cloud-m3d-graphql
Open

randilt wants to merge 35 commits into
wso2:mainfrom
randilt:test/cloud-m3d-graphql

Conversation

@randilt

@randilt randilt commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Purpose

Part of carrying the on-premises integration scenarios that apply to the APIP cloud over to the cloud suite, one pull request per milestone. This is milestone M3d: GraphQL routing, policies and jwt-auth on the managed gateway.

Stacked on #4484 (M3c), #4483 (M3b), #4482 (M3a), #4472 (M2) and #4444 (M1). Only the last commit belongs to this pull request: Check GraphQL routing, policies and jwt-auth on the managed gateway.

Goals

Cloud scenarios for the remaining on-premises GraphQL gateway scenarios, added to apip_graphql.feature (run by apip-basic) and scenarios/cloud/GRAPHQL.yaml.

Cloud ID On-premises State
ID_APIP_GRAPHQL_011 "A GraphQL API exposes exactly one POST route - other methods to the same context are not routed" Automated: verified on development
ID_APIP_GRAPHQL_012 "A GraphQL API with set-headers correctly mutates the proxied response" Automated: verified on development
ID_APIP_GRAPHQL_013 "A GraphQL API with cors answers a preflight request" Automated: verified on development
ID_APIP_GRAPHQL_014 "A GraphQL API with basic-ratelimit enforces its configured limit" Automated: verified on development
ID_APIP_GRAPHQL_015 "A GraphQL API with jwt-auth rejects requests without a token and accepts a valid one" Automated: verified on development

Where a clone differs from the on-premises scenario, a comment in the feature file says why:

  • 013 asserts the gateway's 204 for the preflight, where on-premises accepts any successful status.
  • 014 counts the request that finds the route ready as the first of the three the limit allows.
  • 015: the issuer jwt-auth trusts is a key manager in the gateway's own configuration. The scenario sets it on a synthetic managed gateway its runner owns, never on the shared gateway, and deploys the API there. The token comes from the testbench JWKS mock (/apip-testbench-mocks/jwks), whose iss the key manager is set to.

Approach

New steps, in graphql.go, runtime.go and a new tokenissuer.go:

  • send one GraphQL request, so a limit can be counted;
  • send a data-plane request with a table of headers;
  • make a synthetic managed gateway of the runner the active one;
  • trust the testbench token issuer on the selected gateway as a named key manager, refusing to fall back to the shared active gateway;
  • obtain a token from that issuer, kept in scenario state only and never published or reported;
  • send a GraphQL request with one header until a status.

User stories

N/A

Documentation

N/A: test-only change.

Automation tests

  • Unit tests

    Added to lifecycle_test.go for each new step, including the refusal to write the shared gateway's configuration and the issuer claim parsing.

  • Integration tests

    Run against development (organisation cloud-healthcheck-dev) on 2026-11-27: each scenario passed three consecutive runs with no cleanup failure, and failed on its own line when its assertion was broken.

Security checks

Database changes

  • I have applied the same table, column, and index changes to the API Platform SaaS (Bijira Cloud) databases in all relevant environments (dev, staging, production) and regions (US, EU).

N/A: no schema change.

…metadata address

Add the cloud counterparts of the on-premises network access control
scenarios that apply to the APIP cloud:

- ID_APIP_BASIC_021 (NETAC-PA-011): a REST API upstream at the metadata
  address is refused on create and on update, and a permitted upstream
  is kept.
- ID_APIP_DEPLOY_019 (NETAC-PA-014): a deployment whose production
  endpoint is the metadata address is refused, and a permitted endpoint
  deploys. The cloud deployment route answers with the platform's code
  and message only, so the refused field is not asserted.
- ID_APIP_GRAPHQL_009 (NETAC-PA-016): a GraphQL API whose SDL URL is the
  metadata address is refused, and one with an inline SDL is created.
- ID_APIP_GRAPHQL_010 (NETAC-PA-020): schema validation from a refused
  SDL URL or introspection endpoint is refused. The cloud publishes no
  mock that serves a schema file, so the permitted URL is the echo
  backend, which is fetched and reported unresolved.

The entries are planned until the scenarios pass against a cloud
environment.

New steps: an update the platform may refuse, a check of the API's main
upstream, a check of the field an error names, and schema validation
from a source given in a table. REST API tables accept upstreamUrl.
…tials do not allow

Add the cloud counterparts of the on-premises service-account exchange
refusals:

- ID_APIP_AUTH_009: a wrong secret, an unknown client, a missing or
  ungranted scope and another grant type are refused, and no token is
  issued.
- ID_APIP_AUTH_010: a client that authenticates twice, and a wrong
  HTTP Basic secret, are refused.
- ID_APIP_AUTH_011: a request that leaves out the scope is refused.

Each scenario ends by exchanging the same account's own credentials, so
a refusal cannot pass because the exchange is broken. The entries are
planned until the scenarios pass against a cloud environment, which
needs service accounts on there (APIP_PAPI_SA_ENABLED).

New steps create a synthetic service account and exchange its
credentials. The account's secret is never published, and an issued
access token is redacted before an answer is published or reported.
The account is registered for cleanup, and the finalizer sweeps a run's
leftover service accounts.
… free

Add a subscription plan list (PLAN) and its feature, run by apip-basic:

- ID_APIP_PLAN_001: a plan keeps its limits through list, update and
  duplicate attempts. The on-premises scenario's creator "admin" becomes
  the console user: the platform shows the token's name claim, or its
  sub when there is none.
- ID_APIP_PLAN_002: a free plan has no price to read, and a price can't
  be added later. The cloud refuses a priced plan create while
  monetization is off, but not an update, so the platform's pricing lock
  answers it. An update without a price is the positive control.

A scenario's plans carry one generated word in their display names, so
the list search finds them and nothing else of the shared organisation.
Each plan is registered for cleanup before it is created and keeps the
syn-plan- prefix the finalizer and the portal sweep look for.

The entries are planned until the scenarios pass against a cloud
environment.
…form puts it

POST /service-accounts answers ServiceAccountCredentials: the account, with its id, under serviceAccount, next to clientId and clientSecret. The step read a top-level id, so every service-account scenario stopped at the create against a real platform. The unit test's platform now answers the spec's shape, and an id beside the credentials is refused.
…ta plane is on

testbenchURL accepted only https, so a run against a cloud on the developer's machine, whose testbench is served over http on a .localhost host, could not set CLOUD_IT_BACKEND_URL and its kin. With CLOUD_IT_LOCAL_DATA_PLANE on, it now accepts the URLs that setting already approves for gateways: http or https on a named .localhost host, with no credentials. Nothing changes with it off.
BASIC_021, DEPLOY_019, GRAPHQL_009, GRAPHQL_010, PLAN_001 and PLAN_002 passed three
consecutive runs against development (organisation cloud-healthcheck-dev) and each failed
on its own line when its assertion was broken, so they are automated.

AUTH_009 to AUTH_011 cannot pass there: development turns service accounts off, and
POST /service-accounts answers 404. They are tagged @known-issue, and the apip-auth runner
now excludes known issues.
…ision

AUTH_009 to AUTH_011 stay @known-issue: service accounts are off on every cloud
environment by decision (wso2-enterprise/wso2cloud-deployment#6686), not by a defect.
…arden two steps

From the review of wso2#4444:

- ID_APIP_BASIC_021: a permitted upstream update to the echo backend succeeds and is stored
  before the refused update, which then leaves it unchanged.
- ID_APIP_GRAPHQL_010: a permitted introspection endpoint is fetched and reported
  unresolved, next to the refused one. The unresolved check accepts the platform's message
  as the diagnostic, which is where it reports an endpoint it could not introspect.
- ID_APIP_AUTH_010: the account's own credentials are exchanged through HTTP Basic, as the
  positive control for the HTTP Basic refusals (verified on a local cloud with service
  accounts on; development turns them off).
- ID_APIP_PLAN_001: a listed plan must hold exactly the one REQUEST_COUNT limit submitted.
- A created service account's returned id is registered before its credentials are
  checked, so an incomplete answer cannot leave the account without a cleanup.
- Access-token redaction decodes the answer first, so an escaped spelling of the
  access_token key is redacted too.
- apip_subscription_plan.feature works in project one, as the setup README says.
- The testbench URL test sets the local data plane flag itself.
…tched schema as resolved, and check no token after each Basic refusal

Addresses CodeRabbit review on wso2#4444 and wso2#4472.
@randilt
randilt force-pushed the test/cloud-m3d-graphql branch from db14237 to a88d810 Compare November 30, 2026 05:50
… a service-account create answer that is not an error, and drop any token answer that is not a JSON object

Addresses CodeRabbit review on wso2#4472 and wso2#4482.
…ip a self-hosted gateway's values and tokens

Carries three on-premises control-plane scenarios over to the cloud suite, all planned until they pass against a cloud environment:
- ID_APIP_BASIC_022 (APIDEF-011): validating the testbench backend's URL, which serves JSON, lists errors and returns no content; a valid definition validates.
- ID_APIP_SELF_HOSTED_GATEWAY_004: a self-hosted gateway registered with endpoints and properties reads them back, with the environment the cloud adds, starts inactive, and is listed.
- ID_APIP_SELF_HOSTED_GATEWAY_005: registration tokens are revoked one at a time; revoking one twice leaves the other active.

The creator half of the on-premises round-trip is ID_APIP_SELF_HOSTED_GATEWAY_006, known-issue: the cloud shows a self-hosted gateway's creator as deleted_user, because the plugin resolves the creator platform-api already resolved. The apip-self-hosted-gateway runner now excludes known issues. The console user's display name, which the subscription plan creator check worked out, is now shared by both checks.
…ts, send an upstream secret, and cap a request body

Clones the on-premises scenarios the cloud can run against a managed gateway:

- ID_APIP_DEPLOY_020 (SVR-020): the cloud refuses an invalid virtual host before
  anything is built and names vhostMain; the gateway-default placeholder deploys.
- ID_APIP_DEPLOY_021 (SVR-018): a deployment that names no host is reported on its
  gateway's public host, since the cloud does not report the placeholder, and one
  that names its own hosts reports them.
- ID_APIP_SECRETS_006: a secret named as a REST API's upstream credential reaches the
  upstream, asserted through the data plane.
- ID_APIP_BASIC_023 (CPLIM-001): a create over platform-api's 10 MiB default, which
  the cloud keeps, is refused and creates nothing; one under it is created.

The REST API values table takes a whole upstream and a padding size, and the active
gateway records the public host it lists.
…m secret a known issue

ID_APIP_DEPLOY_020 and ID_APIP_DEPLOY_021 passed three consecutive runs against
development (organisation cloud-healthcheck-dev) and failed when their assertions were
broken.

ID_APIP_SECRETS_006 fails on development: the echo backend receives no credential
header. A REST API's upstream.main.auth is stored but never deployed, since the
deployment's upstream (dto.UpstreamTarget) holds only url and ref and the gateway's
RestApi upstream has no auth field. The scenario is tagged @known-issue, and the
apip-secrets runner now excludes known issues.
BASIC_022, BASIC_023, SELF_HOSTED_GATEWAY_004 and SELF_HOSTED_GATEWAY_005 passed three
consecutive runs against development (organisation cloud-healthcheck-dev) and each failed
on its own line when its assertion was broken, so they are automated.
…, and check the token count after each revoke

Addresses CodeRabbit review on wso2#4472.
…er-cap one is absent

Addresses CodeRabbit review on wso2#4472.
… are revoked, and record what every create path sends

Addresses CodeRabbit review on wso2#4472.
…n token ids kept

The ids lived in runner state, so in a full run the first token SHG_005 revoked was one SHG_001
issued for a gateway already deleted, and the revoke answered 404.
@randilt
randilt force-pushed the test/cloud-m3d-graphql branch from a88d810 to fbe1785 Compare November 30, 2026 06:19
@randilt
randilt force-pushed the test/cloud-m3d-graphql branch from fbe1785 to dcc0280 Compare November 30, 2026 10:06
… and request IDs

Clones the on-premises runtime scenarios the managed gateway can be tested for, in a new
feature (apip_gateway_runtime.feature, run by apip-deploy) and scenario list
(GATEWAY-RUNTIME):

- Health (HEALTH-006, 007, 009, 033, 010): readiness and liveness report their checks, an
  unknown path under /_gateway-health is 404, other methods are 405 with Allow: GET, HEAD,
  and an API in the reserved namespace fails to deploy. The platform accepts it, since only
  the gateway knows the namespace.
- Request IDs: generated IDs on 200, 401, 404 and 503 answers, and a policy-set X-Request-ID
  replaced. The upstream half of the generated-ID case cannot be seen in the cloud, since
  the testbench sits behind another gateway that gives each request a new ID.
  ID_APIP_GATEWAY_RUNTIME_007 is @known-issue: the cloud's edge replaces a request ID the
  client sends, although the gateway keeps it (PreserveExternalRequestId).
- JWK Set: 304 for the current ETag, HEAD, 405 for POST, and the /.well-known context
  refused by the platform before the gateway sees it.
- A buffered body over the listener limit gets the gateway's 413; on-premises that is
  timing-dependent (wso2#4061).

The on-premises "on any virtual host" cases are not cloned: the managed gateway is reached
only through its own host, and the cloud's edge answers any other Host itself.

New steps send one data-plane request (with a header or a JSON body of a given size) and
check response headers, the request ID, an empty body, an absent JSON field and an echoed
header. All automated scenarios passed three consecutive runs on development and each
failed on its own line when its assertion was broken.
…controls, tag the feature with its list code, and link the edge issue

Addresses CodeRabbit review on wso2#4482 and wso2#4483.
…with permitted controls, and drop the unobservable upstream check from 007

The echoed-header step moves to the milestone that first uses it.

Addresses CodeRabbit review on wso2#4482.
… issue, as on-premises, for the gateway race in wso2#4061

Addresses CodeRabbit review on wso2#4482.
…input, and check an omission against a JSON object only
…ay, and prefer the default gateway

Clones the on-premises route scenarios in a new feature (apip_routes.feature, run by
apip-deploy) and scenario list (ROUTES):

- Path matching (route_path_matching, route_path_matching_prefix): wildcard, root, exact and
  sibling-context cases, with the path and method the backend receives.
- Case variants (PATHV-001 to 005): a variant answers 404 rather than reaching a wildcard
  operation, in one API and across an enclosing one.
- Normalization: dot-segments, duplicate slashes and literal dots. ID_APIP_ROUTES_015 (%2F
  kept unchanged) is @known-issue: the cloud's edge answers such a path with its own 307 to
  the unescaped path before the gateway sees it.
- A sandbox URL that is not http or https is refused by the cloud's destination guard.
- Default timeouts: a 2 s backend is waited for. ID_APIP_ROUTES_019 is @known-issue: an
  upstream that never accepts a connection gets the cloud edge's 504 after 15 s, not the
  gateway's 503 after its 5 s connect timeout.

upstream_url_validation.feature has no cloud counterpart: its query and fragment checks are
on upstreamDefinitions URLs, which the platform does not expose.

The active gateway is now an environment's default gateway when one is listed. The shared
organisation also holds short-lived gateways other clients create and delete; choosing one
left scenarios deploying to a gateway that was no longer active (409 gateway_not_active).

New steps wait until a gateway answer carries a header value, and until it answers with a
status only after a timeout. All automated scenarios here and in apip_gateway_runtime.feature
passed three consecutive runs on development after these changes, and each failed on its own
line when its assertion was broken.
… one, tag the routes feature with its list code, and link the edge issue

Addresses CodeRabbit review on wso2#4483.
…e managed gateway

Clones the on-premises policy scenarios in a new feature (apip_policies.feature, run by
apip-deploy) and scenario list (POLICIES):

- Policies (api_with_policies.feature): no policy, operation- and API-level CORS, a policy
  added or removed by an update and a redeploy, a policy without a version, and five methods
  on one path. The clones also check each policy's effect, where on-premises only the
  deployment is checked.
- CEL execution conditions (cel_conditions.feature): method, in, header presence, header
  value, path prefix and combined conditions, through the headers the backend receives.
- Templates: a secret in a set-headers value reaches the upstream rendered inside the value,
  while the API's create and read answers keep the template and never carry the value.
  ID_APIP_POLICIES_016 (default fallback for a missing env value) is @known-issue: the
  deployment fails with GATEWAY_PROCESSING_ERROR on development.
- ID_APIP_POLICIES_017 ($version in a context) is @known-issue: the platform refuses the
  context ("Invalid API context format"), although other platform code expects the
  placeholder.

The missing-secret case of template_functions.feature is already ID_APIP_SECRETS_005.
Every automated scenario passed three consecutive runs on development and failed on its own
line when one of its assertions was broken.
… header with the GET under the combined condition
…nswer only, and keep a test handler's decode failure off FailNow
…e managed gateway

Clones the remaining on-premises GraphQL gateway scenarios into apip_graphql.feature and
the GRAPHQL list:

- ID_APIP_GRAPHQL_011: a GraphQL API serves only POST on its context.
- ID_APIP_GRAPHQL_012 and 013: a set-headers response policy, and a CORS policy answering a
  preflight with 204 and the allowed origin.
- ID_APIP_GRAPHQL_014: a basic rate limit of three requests refuses the fourth with 429.
- ID_APIP_GRAPHQL_015: jwt-auth refuses a request without a token and serves one the
  testbench issuer signed. The issuer is a key manager in the gateway's own configuration,
  so the scenario trusts it on a synthetic managed gateway of its runner, never on the
  shared gateway, and deploys the API there.

New steps send one GraphQL request (so a limit can be counted), send a request with several
headers, make a synthetic managed gateway the active one, trust the testbench issuer on the
selected gateway (refusing to fall back to the shared active gateway), obtain a token from
that issuer, and send a GraphQL request with a header. Each scenario passed three
consecutive runs on development and failed on its own line when its assertion was broken.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant