@@ -2,47 +2,43 @@ import { test, expect } from '@grafana/plugin-e2e';
2
2
3
3
test ( '"Save & test" should be successful when mongo without auth config is valid' , async ( {
4
4
createDataSourceConfigPage,
5
- readProvisionedDataSource,
6
5
page,
7
6
} ) => {
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 ?? '' ) ;
7
+ const configPage = await createDataSourceConfigPage ( { type : 'haohanyang-mongodb-datasource' } ) ;
8
+ await page . getByLabel ( 'Host' ) . fill ( 'mongo-no-auth' ) ;
9
+ await page . getByLabel ( 'Port' ) . fill ( '27017' ) ;
10
+ await page . getByLabel ( 'Database' ) . fill ( 'test' ) ;
13
11
await page . getByRole ( 'radio' , { name : 'None' } ) . check ( ) ;
14
12
await expect ( configPage . saveAndTest ( ) ) . toBeOK ( ) ;
15
13
} ) ;
16
14
17
15
test ( '"Save & test" should be successful when mongo username-password auth config is valid' , async ( {
18
16
createDataSourceConfigPage,
19
- readProvisionedDataSource,
20
17
page,
21
18
} ) => {
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 ?? '' ) ;
19
+ const configPage = await createDataSourceConfigPage ( { type : 'haohanyang-mongodb-datasource' } ) ;
20
+ await page . getByLabel ( 'Host' ) . fill ( 'mongo-username-password-auth' ) ;
21
+ await page . getByLabel ( 'Port' ) . fill ( '27017' ) ;
22
+ await page . getByLabel ( 'Database' ) . fill ( 'test' ) ;
27
23
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 ?? ' ') ;
24
+ await page . getByLabel ( 'Username' , { exact : true } ) . fill ( 'username ') ;
25
+ await page . getByLabel ( 'Password' , { exact : true } ) . fill ( 'password ') ;
30
26
await expect ( configPage . saveAndTest ( ) ) . toBeOK ( ) ;
31
27
} ) ;
32
28
33
29
test ( '"Save & test" should be successful when mongo tls auth config is valid' , async ( {
34
30
createDataSourceConfigPage,
35
- readProvisionedDataSource,
36
31
page,
37
32
} ) => {
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 ?? '' ) ;
33
+ const configPage = await createDataSourceConfigPage ( { type : 'haohanyang-mongodb-datasource' } ) ;
34
+ await page . getByLabel ( 'Host' ) . fill ( 'mongo-tls-auth' ) ;
35
+ await page . getByLabel ( 'Port' ) . fill ( '27017' ) ;
36
+ await page . getByLabel ( 'Database' ) . fill ( 'test' ) ;
43
37
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 ?? '' ) ;
38
+ await page . screenshot ( { path : 'mongo-tls-auth1.png' } ) ;
39
+
40
+ await page . getByLabel ( 'Certificate Authority' ) . fill ( '/certs/ca.pem' ) ;
41
+ await page . getByLabel ( 'Client Certificate' ) . fill ( '/certs/mongodb.crt' ) ;
42
+ await page . getByPlaceholder ( '/path/to/mongodb.pem' ) . fill ( '/certs/mongodb.pem' ) ;
47
43
await expect ( configPage . saveAndTest ( ) ) . toBeOK ( ) ;
48
44
} ) ;
0 commit comments