@@ -17,9 +17,9 @@ const racompassInvalidJson = 'racompass-invalid.json';
17
17
const rdmFullJson = 'rdm-full.json' ;
18
18
const ardmValidAno = 'ardm-valid.ano' ;
19
19
const listOfDB = JSON . parse ( fs . readFileSync ( path . join ( 'test-data' , 'import-databases' , 'rdm-full.json' ) , 'utf-8' ) ) ;
20
- const dbSuccessNames = listOfDB . filter ( element => element . result === 'success' ) . map ( item => item . name ) ;
21
- const dbPartialNames = listOfDB . filter ( element => element . result === 'partial' ) . map ( item => item . name ) ;
22
- const dbFailedNames = listOfDB . filter ( element => element . result === 'failed' ) . map ( item => item . name ) ;
20
+ const dbSuccessNames = myRedisDatabasePage . filterDatabaseListByResult ( listOfDB , 'success' ) ;
21
+ const dbPartialNames = myRedisDatabasePage . filterDatabaseListByResult ( listOfDB , 'partial' ) ;
22
+ const dbFailedNames = myRedisDatabasePage . filterDatabaseListByResult ( listOfDB , 'failed' ) ;
23
23
const dbImportedNames = [ ...dbSuccessNames , ...dbPartialNames ] ;
24
24
const rdmData = {
25
25
type : 'rdm' ,
@@ -50,18 +50,19 @@ const databases = [
50
50
dbData [ 1 ] . dbNames [ 1 ]
51
51
] ;
52
52
const databasesToDelete = [ ...dbImportedNames , ...databases ] ;
53
+ const findImportedDbNameInList = async ( dbName : string ) => dbImportedNames . find ( item => item === dbName ) ! ;
53
54
54
55
fixture `Import databases`
55
- . meta ( { type : 'critical_path' , rte : rte . standalone } )
56
+ . meta ( { type : 'critical_path' , rte : rte . none } )
56
57
. page ( commonUrl )
57
- . beforeEach ( async ( ) => {
58
+ . beforeEach ( async ( ) => {
58
59
await acceptLicenseTerms ( ) ;
59
60
} )
60
- . afterEach ( async ( ) => {
61
+ . afterEach ( async ( ) => {
61
62
// Delete databases
62
63
deleteStandaloneDatabasesByNamesApi ( databasesToDelete ) ;
63
- } ) ;
64
- test ( 'Connection import from JSON ' , async t => {
64
+ } )
65
+ test ( 'Connection import modal window ' , async t => {
65
66
const tooltipText = 'Import Database Connections' ;
66
67
const defaultText = 'Select or drag and drop a file' ;
67
68
const parseFailedMsg = 'Failed to add database connections' ;
@@ -95,8 +96,9 @@ test('Connection import from JSON', async t => {
95
96
await t . click ( myRedisDatabasePage . removeImportedFileBtn ) ;
96
97
await t . expect ( myRedisDatabasePage . importDbDialog . textContent ) . contains ( defaultText , 'File not removed from import input' ) ;
97
98
99
+ } ) ;
100
+ test ( 'Connection import from JSON' , async t => {
98
101
// Verify that user can import database with mandatory/optional fields
99
- await t . click ( myRedisDatabasePage . closeDialogBtn ) ;
100
102
await databasesActions . importDatabase ( rdmData ) ;
101
103
102
104
// Fully imported table
@@ -115,14 +117,37 @@ test('Connection import from JSON', async t => {
115
117
116
118
await clickOnEditDatabaseByName ( dbImportedNames [ 1 ] ) ;
117
119
// Verify username imported
118
- await t . expect ( addRedisDatabasePage . usernameInput . value ) . eql ( listOfDB [ 1 ] . username ) ;
120
+ await t . expect ( addRedisDatabasePage . usernameInput . value ) . eql ( listOfDB [ 1 ] . username , 'Username import incorrect' ) ;
119
121
// Verify password imported
120
122
await t . click ( addRedisDatabasePage . showPasswordBtn ) ;
121
- await t . expect ( addRedisDatabasePage . passwordInput . value ) . eql ( listOfDB [ 1 ] . auth ) ;
123
+ await t . expect ( addRedisDatabasePage . passwordInput . value ) . eql ( listOfDB [ 1 ] . auth , 'Password import incorrect' ) ;
122
124
123
125
// Verify cluster connection type imported
124
126
await clickOnEditDatabaseByName ( dbImportedNames [ 2 ] ) ;
125
- await t . expect ( addRedisDatabasePage . connectionType . textContent ) . eql ( rdmData . connectionType ) ;
127
+ await t . expect ( addRedisDatabasePage . connectionType . textContent ) . eql ( rdmData . connectionType , 'Connection type import incorrect' ) ;
128
+
129
+ // Verify that user can import database with CA certificate
130
+ await clickOnEditDatabaseByName ( await findImportedDbNameInList ( 'rdmHost+Port+Name+CaCert' ) ) ;
131
+ await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( 'ca' , 'CA certificate import incorrect' ) ;
132
+ await t . expect ( addRedisDatabasePage . clientCertField . exists ) . notOk ( 'Client certificate was imported' ) ;
133
+
134
+ // Verify that user can import database with Client certificate, Client private key
135
+ await clickOnEditDatabaseByName ( await findImportedDbNameInList ( 'rdmHost+Port+Name+clientCert+privateKey' ) ) ;
136
+ await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( 'No CA Certificate' , 'CA certificate was imported' ) ;
137
+ await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( 'client' , 'Client certificate import incorrect' ) ;
138
+
139
+ // Verify that user can import database with all certificates
140
+ await clickOnEditDatabaseByName ( await findImportedDbNameInList ( 'rdmHost+Port+Name+CaCert+clientCert+privateKey' ) ) ;
141
+ await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( 'ca' , 'CA certificate import incorrect' ) ;
142
+ await t . expect ( addRedisDatabasePage . clientCertField . textContent ) . eql ( 'client' , 'Client certificate import incorrect' ) ;
143
+
144
+ // Verify that certificate not imported when any certificate field has not been parsed
145
+ await clickOnEditDatabaseByName ( await findImportedDbNameInList ( 'rdmCaCertInvalidBody' ) ) ;
146
+ await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( 'No CA Certificate' , 'CA certificate was imported' ) ;
147
+ await t . expect ( addRedisDatabasePage . clientCertField . exists ) . notOk ( 'Client certificate was imported' ) ;
148
+ await clickOnEditDatabaseByName ( await findImportedDbNameInList ( 'rdmInvalidClientCert' ) ) ;
149
+ await t . expect ( addRedisDatabasePage . caCertField . textContent ) . eql ( 'No CA Certificate' , 'CA certificate was imported' ) ;
150
+ await t . expect ( addRedisDatabasePage . clientCertField . exists ) . notOk ( 'Client certificate was imported' ) ;
126
151
127
152
// Verify that user can import files from Racompass, ARDM, RDM
128
153
for ( const db of dbData ) {
0 commit comments