-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin E2E: Allow overriding grafanaAPICredentials #930
Conversation
3fd6964
to
799875f
Compare
await expect(annotationEditPage.getByGrafanaSelector('Select option')).toContainText(REDSHIFT_SCHEMAS); | ||
await expect(annotationEditPage.getByGrafanaSelector(selectors.components.Select.option)).toContainText( | ||
REDSHIFT_SCHEMAS | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change (and the next file) is unrelated, but needed to get others tests to pass as this selector was recently changed in the main branch of Grafana.
packages/plugin-e2e/src/types.ts
Outdated
/** | ||
* Set this to true if the user already exist in the database. If omitted or set to false, the user will be created. | ||
*/ | ||
skipCreateUser?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prop name is a bit weird - would have been better to reverse the condition and call this createUser
, but that would have been a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
Left a couple of nits. Could we add something to the docs about this?
@@ -25,6 +25,10 @@ export default defineConfig<PluginOptions>({ | |||
|
|||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | |||
trace: 'on-first-retry', | |||
grafanaAPIUser: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Besides a user account are there other ways to auth with the API? Maybe grafanaAPIAuth
or grafanaAPICredentials
would work rather than mentioning user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, 100% agree
@@ -1,7 +1,7 @@ | |||
import { test as setup } from '../'; | |||
|
|||
setup('authenticate', async ({ login, createUser, user }) => { | |||
if (user) { | |||
if (user && !user.skipCreateUser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I'm understanding the skipCreateUser. Doesn't createUser already handle cases where the user already exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No that's right, user is only created if it doesn't exist, so this is not entirely necessary. I guess I thought this would make this more clear from an end-user standpoint, but that's not the case so I'll remote this prop. Thanks for feedback.
🚀 PR was released in |
What this PR does / why we need it:
In a few places in the code, plugin-e2e uses the Grafana API to administrate users, data sources etc. Before this PR, the Grafana API was always called on behalf of the admin:admin user (the default server admin account) as it has all the necessary permissions. This is working fine in most cases, but in the test environment for the SLO app, this account doesn't exist so they're getting 401 errors when setting up users (more details on how to create users here).
With this PR, the Grafana API is still called on behalf of the admin:admin user by default. However, consumers now have the option to override this user by providing a
grafanaAPIUser
in the playwright config.grafanaAPIUser
is a Playwright option, meaning it can be defined on a global level and on a project level. Also, when specifying the user to use when running the e2e test (not the same thing as thegrafanaAPIUser
), it's now possible to setskipCreateUser
prop. This gives the consumer the option to not create the user in the database.This is an example where one user is being used when calling the Grafana API and another one is being used when running the e2e tests.
Which issue(s) this PR fixes:
Fixes #934
Special notes for your reviewer:
📦 Published PR as canary version:
Canary Versions
✨ Test out this PR locally via: