Skip to content

Add the RBAC and Auth API helpers#50

Merged
subhashkhileri merged 6 commits intoredhat-developer:mainfrom
PatAKnight:more-api-helpers
Mar 11, 2026
Merged

Add the RBAC and Auth API helpers#50
subhashkhileri merged 6 commits intoredhat-developer:mainfrom
PatAKnight:more-api-helpers

Conversation

@PatAKnight
Copy link
Member

This PR adds two additional API helpers, RbacApiHelper and AuthApiHelper, meant to assist test authors with cleaning up permissions and roles during tests and accessing the auth token for a given logged in user.

My thought process was to expose the get and delete endpoints for the RBAC plugin so that a developer could clean up any permissions policies and roles that were created as part of their tests. This will help to ensure that prior permissions and roles do not interfere with future tests.

The AuthApiHelper is needed to ensure that we are able to access these endpoints as they require user credentials. Also, there might be other tests that rely on this and extracting it can help to prevent duplicate code within the overlays repo.

Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
@PatAKnight
Copy link
Member Author

Reminder for myself for when this gets merged to take care of some clean up

When this gets merged we should be able to remove the references to the RhdhRbacApi and RhdhAuthApiHack in this PR in favor of the RbacApiHelper and AuthApiHelper.

We can also remove the RhdhAuthApiHack from the backstage workspace tests in favor of AuthApiHelper

@subhashkhileri
Copy link
Member

Please bump the package version and update the changelog in docs.

export { LoginHelper, setupBrowser } from "./common.js";
export { UIhelper } from "./ui-helper.js";
export { RbacApiHelper } from "./rbac-api-helper.js";
export { AuthApiHelper } from "./auth-api-helper.js";
Copy link
Member

Choose a reason for hiding this comment

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

we might have to add these to exports in package.json
https://github.com/redhat-developer/rhdh-e2e-test-utils/pull/50/changes#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R14

In order to test package changes locally this is what I do :
cd /Users/..../rhdh-e2e-test-utils && yarn build && cd /Users/...../rhdh-plugin-export-overlays/workspaces/tech-radar/e2e-tests && yarn install && NODE_PRESERVE_SYMLINKS=1 yarn test:headed

Copy link
Member

Choose a reason for hiding this comment

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

and in overlay package.json replace the uitls package version to "file:/..localltion..to...rhdh-e2e-test-utils"

Copy link
Member

Choose a reason for hiding this comment

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

my bad, helper is already exported

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually worth the call out because I wasn't exporting the Policy and Response here. Has been updated but I haven't properly tested this yet since I don't have a cluster up at the moment.

The Api Helpers only slightly deviate from the versions within my PR and should be fine. But I can properly test them if you want me to.

Copy link
Member

Choose a reason for hiding this comment

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

it would be nice to test incase. otherwise for a small issue it would again require a fix with version bump.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to successfully test it locally thanks to your instructions.

Signed-off-by: Patrick Knight <pknight@redhat.com>
package.json Outdated
"@playwright/test": "^1.57.0"
},
"devDependencies": {
"@backstage-community/plugin-rbac-common": "1.23.0",
Copy link
Member

Choose a reason for hiding this comment

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

if this Dependencies is something that consumer requires. than we might have to move from devDependencies to Dependencies section.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved @backstage-community/plugin-rbac-common from devDependencies to dependencies.

Signed-off-by: Patrick Knight <pknight@redhat.com>
…endencies

Signed-off-by: Patrick Knight <pknight@redhat.com>
@subhashkhileri subhashkhileri merged commit e2c305f into redhat-developer:main Mar 11, 2026
1 check passed
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