Skip to content

chore: add e2e tests for security propagation during join#2827

Open
Daryna-del wants to merge 16 commits into
mainfrom
fix/resolve-root-security-in-join
Open

chore: add e2e tests for security propagation during join#2827
Daryna-del wants to merge 16 commits into
mainfrom
fix/resolve-root-security-in-join

Conversation

@Daryna-del
Copy link
Copy Markdown
Contributor

@Daryna-del Daryna-del commented May 20, 2026

What/Why/How?

Added e2e tests for security propagation during join

Reference

#1409

Testing

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

Note

Medium Risk
Join output affects how merged OpenAPI describes authentication; wrong propagation could misstate required security, though this PR is primarily tests and a changeset note.

Overview
Documents a patch for @redocly/cli where join copies each source API’s root security onto operations that omit their own security, instead of dropping that inheritance when merging specs.

Adds two e2e scenarios under tests/e2e/join/: root-security-in-both-specs (Foo oauth2 and Bar bearerAuth at the root; joined output expects per-operation security on getProducts and getPets) and root-security-without-paths (one input has root security but empty paths; snapshot locks join behavior for the other file’s operations). Both are wired into the existing snapshot-based join test matrix.

Reviewed by Cursor Bugbot for commit 4b8bca5. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 20, 2026

🦋 Changeset detected

Latest commit: 4b8bca5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/cli Patch
@redocly/openapi-core Patch
@redocly/respect-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 1.903s ± 0.028s ▓ 1.00x (Fastest)
cli-next 1.918s ± 0.039s ▓ 1.01x

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 81.05% (🎯 80%) 7301 / 9007
🔵 Statements 80.4% (🎯 80%) 7585 / 9433
🔵 Functions 84.08% (🎯 83%) 1463 / 1740
🔵 Branches 72.55% (🎯 72%) 4939 / 6807
File CoverageNo changed files found.
Generated in workflow #9997 for commit 4b8bca5 by the Vitest Coverage Report Action

@Daryna-del
Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread packages/cli/src/commands/join/utils/get-effective-components-prefix.ts Outdated
Comment thread packages/cli/src/commands/join/utils/get-effective-components-prefix.ts Outdated
@Daryna-del
Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread tests/e2e/join/merged-root-security-from-other-apis/snapshot.txt Outdated
Comment thread packages/cli/src/commands/join/index.ts Outdated
@Daryna-del
Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread packages/cli/src/commands/join/utils/get-effective-components-prefix.ts Outdated
@Daryna-del Daryna-del force-pushed the fix/resolve-root-security-in-join branch from 5bc9605 to ecc35f1 Compare May 20, 2026 11:29
@Daryna-del Daryna-del marked this pull request as ready for review May 20, 2026 11:40
@Daryna-del Daryna-del requested review from a team as code owners May 20, 2026 11:40
Comment thread .changeset/curvy-ghosts-listen.md Outdated
Comment thread packages/cli/src/commands/join/utils/resolve-operation-security.ts Outdated
Comment thread packages/cli/src/commands/join/utils/get-effective-components-prefix.ts Outdated
Comment thread packages/cli/src/commands/join/index.ts Outdated
Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also address the bugbot comments.

Comment thread packages/cli/src/commands/join/index.ts Outdated
} from '../../utils/miscellaneous.js';
import type { CommandArgs } from '../../wrapper.js';
import { COMPONENTS } from '../split/constants.js';
// import { COMPONENTS } from '../split/constants.js';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

},
});
}
if (!security && openapi.hasOwnProperty('security')) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the previous solution was not working? I see it refers to the root security already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point. Previous solution was working for each case, except when we have paths: {} and security on root level. Simplified the solution to cover this case, please, review one more time.

Comment thread packages/cli/src/commands/join/index.ts Outdated
Comment thread packages/cli/src/commands/join/utils/collect-paths.ts Outdated
Comment thread packages/cli/src/commands/join/utils/resolve-operation-security.ts Outdated
Comment thread packages/cli/src/commands/join/utils/collect-paths.ts Outdated
@Daryna-del Daryna-del force-pushed the fix/resolve-root-security-in-join branch from 11a4935 to 09e577e Compare May 25, 2026 11:51
200:
description: OK
400:
description: Bad request No newline at end of file
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: Bad request
description: Bad request

Let's add a newline on file endings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to each file

info:
title: "spec1"
version: 1.0.0
servers:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add only essential fields and remove others.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

servers:
- url: https://api.example.com
paths:
/post:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's bad practice to use verbs in paths (especially mixing post and get), so I'm against using it in our examples.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

description: Bad request
tags:
- bar_other
security:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm getting it correctly, this path comes from an API description that doesn't have security defined on it; so how it got the security requirement from another description?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right, updated tests

authorizationUrl: https://example.com/oauth/authorize
tokenUrl: https://example.com/oauth/token
scopes: {}
oauth1:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These names are hard to follow. Please use something more meaningful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@Daryna-del Daryna-del force-pushed the fix/resolve-root-security-in-join branch from b887c33 to 1ecab94 Compare May 27, 2026 08:20
@Daryna-del Daryna-del changed the title fix: resolve root security during join tests: add e2e tests for security propagation during join May 27, 2026
@Daryna-del Daryna-del changed the title tests: add e2e tests for security propagation during join chore: add e2e tests for security propagation during join May 27, 2026
Comment thread tests/e2e/join/root-security-without-paths/snapshot.txt Outdated
Comment thread tests/e2e/join/root-security-in-both-specs/snapshot.txt Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ab620eb. Configure here.

Comment thread tests/e2e/join/root-security-in-both-specs/joined.yaml Outdated
@Daryna-del Daryna-del force-pushed the fix/resolve-root-security-in-join branch from bb740f3 to 046d4d0 Compare May 27, 2026 09:15
@Daryna-del Daryna-del force-pushed the fix/resolve-root-security-in-join branch from c4ad9b7 to 4b8bca5 Compare May 29, 2026 07:22
@Daryna-del Daryna-del requested a review from tatomyr May 29, 2026 07:23
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.

3 participants