-
Notifications
You must be signed in to change notification settings - Fork 33
Plugin E2E: Allow overriding grafanaAPICredentials #930
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
Changes from 5 commits
e51e215
799875f
bdc666d
c271d9e
a012001
661d0af
19315f9
a85b4bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { test as setup } from '../'; | ||
|
||
setup('authenticate', async ({ login, createUser, user }) => { | ||
if (user) { | ||
if (user && !user.skipCreateUser) { | ||
|
||
await createUser(); | ||
} | ||
await login(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import path = require('path'); | ||
import { Fixtures } from '@playwright/test'; | ||
import { PluginOptions } from './types'; | ||
import { PluginOptions, User } from './types'; | ||
|
||
export const DEFAULT_ADMIN_USER: User = { user: 'admin', password: 'admin' }; | ||
|
||
export const options: Fixtures<{}, PluginOptions> = { | ||
user: [undefined, { option: true, scope: 'worker' }], | ||
featureToggles: [{}, { option: true, scope: 'worker' }], | ||
provisioningRootDir: [path.join(process.cwd(), 'provisioning'), { option: true, scope: 'worker' }], | ||
user: [DEFAULT_ADMIN_USER, { option: true, scope: 'worker' }], | ||
grafanaAPIUser: [DEFAULT_ADMIN_USER, { option: true, scope: 'worker' }], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,18 @@ export type PluginOptions = { | |
* You can use different users for different projects. See the fixture createUser for more information on how to create a user, | ||
* and the fixture login for more information on how to authenticate. Also see https://grafana.com/developers/plugin-tools/e2e-test-a-plugin/use-authentication | ||
*/ | ||
user?: CreateUserArgs; | ||
user?: User & { | ||
/** | ||
* 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; | ||
|
||
}; | ||
|
||
/** | ||
* The user to use when making requests to the Grafana API. For example when creating users, fetching data sources etc. | ||
* If no user is provided, the server default admin/admin user will be used. | ||
*/ | ||
grafanaAPIUser: User; | ||
}; | ||
|
||
export type PluginFixture = { | ||
|
@@ -301,15 +312,17 @@ export interface Dashboard { | |
title?: string; | ||
} | ||
|
||
export type CreateUserArgs = { | ||
export type User = { | ||
/** | ||
* The username of the user to create. Needs to be unique | ||
* The username of the user | ||
*/ | ||
user: string; | ||
|
||
/** | ||
* The password of the user to create | ||
* The passwords | ||
*/ | ||
password: string; | ||
|
||
/** | ||
* The role of the user to create | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,16 @@ import { REDSHIFT_SCHEMAS } from '../mocks/resource'; | |
test('should load resources and display them as options when clicking on an input', async ({ | ||
annotationEditPage, | ||
page, | ||
selectors, | ||
readProvisionedDataSource, | ||
}) => { | ||
await annotationEditPage.mockResourceResponse('schemas', REDSHIFT_SCHEMAS); | ||
const ds = await readProvisionedDataSource({ fileName: 'redshift.yaml' }); | ||
await annotationEditPage.datasource.set(ds.name); | ||
await page.getByLabel('Schema').click(); | ||
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 commentThe 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. |
||
}); | ||
|
||
test('should be able to add a new annotation when annotations already exist', async ({ | ||
|
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
orgrafanaAPICredentials
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