|
1 |
| -import { test, expect } from "@grafana/plugin-e2e"; |
| 1 | +import { test, expect } from '@grafana/plugin-e2e'; |
2 | 2 |
|
3 |
| -test("\"Save & test\" should be successful when mongo without auth config is valid", async ({ |
4 |
| - createDataSourceConfigPage, |
5 |
| - readProvisionedDataSource, |
6 |
| - page, |
| 3 | +test('"Save & test" should be successful when mongo without auth config is valid', async ({ |
| 4 | + createDataSourceConfigPage, |
| 5 | + readProvisionedDataSource, |
| 6 | + page, |
7 | 7 | }) => {
|
8 |
| - const ds = await readProvisionedDataSource({ fileName: "test/mongo-no-auth.yml" }); |
9 |
| - const configPage = await createDataSourceConfigPage({ type: ds.type }); |
10 |
| - await page.getByLabel("Host").fill(ds.jsonData.host || ""); |
11 |
| - await page.getByLabel("Port").fill(ds.jsonData.port?.toString() || ""); |
12 |
| - await page.getByLabel("Database").fill(ds.jsonData.database || ""); |
13 |
| - await page.getByRole("radio", { name: "None" }).check(); |
14 |
| - await expect(configPage.saveAndTest()).toBeOK(); |
| 8 | + const ds = await readProvisionedDataSource({ fileName: 'test/mongo-no-auth.yml' }); |
| 9 | + const configPage = await createDataSourceConfigPage({ type: ds.type }); |
| 10 | + await page.getByLabel('Host').fill(ds.jsonData.host ?? ''); |
| 11 | + await page.getByLabel('Port').fill(ds.jsonData.port?.toString() ?? ''); |
| 12 | + await page.getByLabel('Database').fill(ds.jsonData.database ?? ''); |
| 13 | + await page.getByRole('radio', { name: 'None' }).check(); |
| 14 | + await expect(configPage.saveAndTest()).toBeOK(); |
15 | 15 | });
|
16 | 16 |
|
17 |
| -test("\"Save & test\" should be successful when mongo username-password auth config is valid", async ({ |
18 |
| - createDataSourceConfigPage, |
19 |
| - readProvisionedDataSource, |
20 |
| - page, |
| 17 | +test('"Save & test" should be successful when mongo username-password auth config is valid', async ({ |
| 18 | + createDataSourceConfigPage, |
| 19 | + readProvisionedDataSource, |
| 20 | + page, |
21 | 21 | }) => {
|
22 |
| - const ds = await readProvisionedDataSource({ fileName: "test/mongo-username-password-auth.yml" }); |
23 |
| - const configPage = await createDataSourceConfigPage({ type: ds.type }); |
24 |
| - await page.getByLabel("Host").fill(ds.jsonData.host || ""); |
25 |
| - await page.getByLabel("Port").fill(ds.jsonData.port?.toString() || ""); |
26 |
| - await page.getByLabel("Database").fill(ds.jsonData.database || ""); |
27 |
| - await page.getByRole("radio", { name: "Username/Password", exact: true }).check(); |
28 |
| - await page.getByLabel("Username", { exact: true }).fill(ds.jsonData.username || ""); |
29 |
| - await page.getByLabel("Password", { exact: true }).fill(ds.secureJsonData?.password || ""); |
30 |
| - await expect(configPage.saveAndTest()).toBeOK(); |
| 22 | + const ds = await readProvisionedDataSource({ fileName: 'test/mongo-username-password-auth.yml' }); |
| 23 | + const configPage = await createDataSourceConfigPage({ type: ds.type }); |
| 24 | + await page.getByLabel('Host').fill(ds.jsonData.host ?? ''); |
| 25 | + await page.getByLabel('Port').fill(ds.jsonData.port?.toString() ?? ''); |
| 26 | + await page.getByLabel('Database').fill(ds.jsonData.database ?? ''); |
| 27 | + await page.getByRole('radio', { name: 'Username/Password', exact: true }).check(); |
| 28 | + await page.getByLabel('Username', { exact: true }).fill(ds.jsonData.username ?? ''); |
| 29 | + await page.getByLabel('Password', { exact: true }).fill(ds.secureJsonData?.password ?? ''); |
| 30 | + await expect(configPage.saveAndTest()).toBeOK(); |
| 31 | +}); |
| 32 | + |
| 33 | +test('"Save & test" should be successful when mongo tls auth config is valid', async ({ |
| 34 | + createDataSourceConfigPage, |
| 35 | + readProvisionedDataSource, |
| 36 | + page, |
| 37 | +}) => { |
| 38 | + const ds = await readProvisionedDataSource({ fileName: 'test/mongo-tls-auth.yml' }); |
| 39 | + const configPage = await createDataSourceConfigPage({ type: ds.type }); |
| 40 | + await page.getByLabel('Host').fill(ds.jsonData.host ?? ''); |
| 41 | + await page.getByLabel('Port').fill(ds.jsonData.port?.toString() ?? ''); |
| 42 | + await page.getByLabel('Database').fill(ds.jsonData.database ?? ''); |
| 43 | + await page.getByRole('radio', { name: 'TLS/SSL', exact: true }).check(); |
| 44 | + await page.getByLabel('Certificate Authority', { exact: true }).fill(ds.jsonData.caCertPath ?? ''); |
| 45 | + await page.getByLabel('Client Certificate', { exact: true }).fill(ds.jsonData.clientCertPath ?? ''); |
| 46 | + await page.getByLabel('Client Key', { exact: true }).fill(ds.jsonData.clientKeyPath ?? ''); |
| 47 | + await expect(configPage.saveAndTest()).toBeOK(); |
31 | 48 | });
|
0 commit comments