Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/e2e/common-actions/databases-actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { t } from 'testcafe';
import * as fs from 'fs';
import { MyRedisDatabasePage } from '../pageObjects';

const myRedisDatabasePage = new MyRedisDatabasePage();
Expand Down Expand Up @@ -26,6 +27,14 @@ export class DatabasesActions {
.click(myRedisDatabasePage.submitImportBtn)
.expect(myRedisDatabasePage.importDialogTitle.textContent).eql('Import Results', `Databases from ${fileParameters.type} not imported`);
}

/**
* Parse json for importing databases
* @param path The path to json file
*/
parseDbJsonByPath(path: string): any[] {
return JSON.parse(fs.readFileSync(path, 'utf-8'));
}
}

/**
Expand All @@ -37,6 +46,7 @@ export class DatabasesActions {
* @param password The password of db
* @param connectionType The connection type of db
* @param fileName The file name
* @param parsedJson The parsed json content
*/
export type ImportDatabaseParameters = {
path: string,
Expand All @@ -45,5 +55,6 @@ export type ImportDatabaseParameters = {
userName?: string,
password?: string,
connectionType?: string,
fileName?: string
fileName?: string,
parsedJson?: any
};
8 changes: 4 additions & 4 deletions tests/e2e/helpers/api/api-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export async function addNewOSSClusterDatabaseApi(databaseParameters: OSSCluster
export async function discoverSentinelDatabaseApi(databaseParameters: SentinelParameters, primaryGroupsNumber?: number): Promise<void> {
let masters = databaseParameters.masters;
if (primaryGroupsNumber) {
masters = databaseParameters.masters.slice(0, primaryGroupsNumber);
masters = databaseParameters.masters!.slice(0, primaryGroupsNumber);
}
const response = await request(endpoint).post('/redis-sentinel/databases')
.send({
Expand Down Expand Up @@ -126,7 +126,7 @@ export async function getDatabaseByConnectionType(connectionType?: string): Prom
export async function deleteAllDatabasesApi(): Promise<void> {
const allDatabases = await getAllDatabases();
if (allDatabases.length > 0) {
const databaseIds = [];
const databaseIds: string[] = [];
for (let i = 0; i < allDatabases.length; i++) {
const dbData = JSON.parse(JSON.stringify(allDatabases[i]));
databaseIds.push(dbData.id);
Expand Down Expand Up @@ -183,8 +183,8 @@ export async function deleteOSSClusterDatabaseApi(databaseParameters: OSSCluster
* @param databaseParameters The database parameters
*/
export async function deleteAllSentinelDatabasesApi(databaseParameters: SentinelParameters): Promise<void> {
for (let i = 0; i < databaseParameters.name.length; i++) {
const databaseId = await getDatabaseByName(databaseParameters.name[i]);
for (let i = 0; i < databaseParameters.name!.length; i++) {
const databaseId = await getDatabaseByName(databaseParameters.name![i]);
const response = await request(endpoint).delete('/databases')
.send({ 'ids': [`${databaseId}`] }).set('Accept', 'application/json');
await t.expect(response.status).eql(200, 'Delete Sentinel database request failed');
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/helpers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export async function acceptLicenseTermsAndAddSentinelDatabaseApi(databaseParame
// Reload Page to see the database added through api
await common.reloadPage();
// Connect to DB
await myRedisDatabasePage.clickOnDBByName(databaseParameters.name[1] ?? '');
await myRedisDatabasePage.clickOnDBByName(databaseParameters.name![1] ?? '');
}

/**
Expand Down Expand Up @@ -273,7 +273,7 @@ export async function clickOnEditDatabaseByName(databaseName: string): Promise<v
* Delete database button by name
* @param databaseName The name of the database
*/
export async function deleteDatabaseByNameApi(databaseName: string): Promise<void> {
export async function deleteDatabaseByNameApi(databaseName: string): Promise<void> {
const databaseId = await getDatabaseByName(databaseName);
const databaseDeleteBtn = Selector(`[data-testid=delete-instance-${databaseId}-icon]`);

Expand Down
12 changes: 8 additions & 4 deletions tests/e2e/pageObjects/add-redis-database-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ export class AddRedisDatabasePage {
primaryGroupNameInput = Selector('[data-testid=primary-group]');
masterGroupPassword = Selector('[data-testid=sentinel-master-password]');
connectionType = Selector('[data-testid=connection-type]');
sentinelForm = Selector('[data-testid=form]');
//Links
buildFromSource = Selector('a').withExactText('Build from source');
buildFromDocker = Selector('a').withExactText('Docker');
buildFromHomebrew = Selector('a').withExactText('Homebrew');
// DROPDOWNS
caCertField = Selector('[data-testid=select-ca-cert]', {timeout: 500});
clientCertField = Selector('[data-testid=select-cert]', {timeout: 500});

/**
* Adding a new redis database
Expand All @@ -61,7 +65,7 @@ export class AddRedisDatabasePage {
await t
.typeText(this.hostInput, parameters.host, { replace: true, paste: true })
.typeText(this.portInput, parameters.port, { replace: true, paste: true })
.typeText(this.databaseAliasInput, parameters.databaseName, { replace: true, paste: true });
.typeText(this.databaseAliasInput, parameters.databaseName!, { replace: true, paste: true });
if (!!parameters.databaseUsername) {
await t.typeText(this.usernameInput, parameters.databaseUsername, { replace: true, paste: true });
}
Expand All @@ -82,7 +86,7 @@ export class AddRedisDatabasePage {
await t
.typeText(this.hostInput, parameters.host, { replace: true, paste: true })
.typeText(this.portInput, parameters.port, { replace: true, paste: true })
.typeText(this.databaseAliasInput, parameters.databaseName, { replace: true, paste: true });
.typeText(this.databaseAliasInput, parameters.databaseName!, { replace: true, paste: true });
if (!!parameters.databaseUsername) {
await t.typeText(this.usernameInput, parameters.databaseUsername, { replace: true, paste: true });
}
Expand Down Expand Up @@ -128,8 +132,8 @@ export class AddRedisDatabasePage {
await t
.typeText(this.hostInput, parameters.host, { replace: true, paste: true })
.typeText(this.portInput, parameters.port, { replace: true, paste: true })
.typeText(this.usernameInput, parameters.databaseUsername, { replace: true, paste: true })
.typeText(this.passwordInput, parameters.databasePassword, { replace: true, paste: true });
.typeText(this.usernameInput, parameters.databaseUsername!, { replace: true, paste: true })
.typeText(this.passwordInput, parameters.databasePassword!, { replace: true, paste: true });
}

/**
Expand Down
57 changes: 53 additions & 4 deletions tests/e2e/pageObjects/my-redis-databases-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,64 @@ export class MyRedisDatabasePage {
* Verify database status is visible
*/
async verifyDatabaseStatusIsVisible(): Promise<void> {
await t.expect(Selector("div").withAttribute("data-testid", /database-status-new-*/).visible)
.ok("Database status is not visible");
await t.expect(Selector('div').withAttribute('data-testid', /database-status-new-*/).visible)
.ok('Database status is not visible');
}

/**
* Verify database status is not visible
*/
async verifyDatabaseStatusIsNotVisible(): Promise<void> {
await t.expect(Selector("div").withAttribute("data-testid", /database-status-new-*/).visible)
.notOk("Database status is still visible");
await t.expect(Selector('div').withAttribute('data-testid', /database-status-new-*/).visible)
.notOk('Database status is still visible');
}

/**
* Filter array with database objects by result field and return names
* @param listOfDb Actual databases list
* @param result The expected import result
*/
getDatabaseNamesFromListByResult(listOfDb: DatabasesForImport, result: string): string[] {
return listOfDb.filter(element => element.result === result).map(item => item.name!);
}
}

/**
* Database for import parameters
* @param host Host of connection
* @param port Port of connection
* @param name The name of connection
* @param result The expected result of connection import
* @param username The username of connection
* @param auth Password of connection
* @param cluster Is the connection has cluster
* @param indName The name of coonection with index
* @param db The index of connection
* @param ssh_port The ssh port of connection
* @param timeout_connect The connect timeout of connection
* @param timeout_execute The execute timeout of connection
* @param other_field The test field
* @param ssl_ca_cert_path The CA certificate of connection by path
* @param ssl_local_cert_path The Client certificate of connection by path
* @param ssl_private_key_path The Client key of connection by path
* @param ssl Is the connection have ssl
*/
export type DatabasesForImport = {
host?: string,
port?: number | string,
name?: string,
result?: string,
username?: string,
auth?: string,
cluster?: boolean | string,
indName?: string,
db?: number,
ssh_port?: number,
timeout_connect?: number,
timeout_execute?: number,
other_field?: string,
ssl_ca_cert_path?: string,
ssl_local_cert_path?: string,
ssl_private_key_path?: string,
ssl?: boolean
}[];
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/certsByPath/caPath.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN CERTIFICATE-----
mockedCACertificatePath
-----END CERTIFICATE-----
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/certsByPath/caSameBody.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN CERTIFICATE-----
mockedCACertificatePath
-----END CERTIFICATE-----
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/certsByPath/clientPath.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN CERTIFICATE-----
mockedClientCrtPath
-----END CERTIFICATE-----
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/certsByPath/clientPath.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN PRIVATE KEY-----
mockedPrivateKeyPath
-----END PRIVATE KEY-----
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/certsByPath/clientSameBody.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN CERTIFICATE-----
mockedClientCrtPath
-----END CERTIFICATE-----
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/certsByPath/clientSameBody.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN PRIVATE KEY-----
mockedPrivateKeyPath
-----END PRIVATE KEY-----
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/sameNameCerts/caPath.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN CERTIFICATE-----
mockedCACertificatePath1
-----END CERTIFICATE-----
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/sameNameCerts/clientPath.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN CERTIFICATE-----
mockedClientCrtPath1
-----END CERTIFICATE-----
3 changes: 3 additions & 0 deletions tests/e2e/test-data/certs/sameNameCerts/clientPath.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-----BEGIN PRIVATE KEY-----
mockedPrivateKeyPath1
-----END PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -1 +1 @@
W3siaG9zdCI6ImxvY2FsaG9zdCIsInBvcnQiOiI2Mzc5IiwiYXV0aCI6InBhc3MiLCJ1c2VybmFtZSI6InVzZXJuYW1lVGVzdCIsIm5hbWUiOiJhcmRtV2l0aFBhc3NBbmRVc2VybmFtZSIsInNlcGFyYXRvciI6IjoiLCJjbHVzdGVyIjpmYWxzZSwia2V5IjoiMTY1MDM3MzUyNTY1MV9naHFwciIsIm9yZGVyIjowfSx7Imhvc3QiOiJhcmRtTm9OYW1lIiwicG9ydCI6IjEyMDAxIiwiYXV0aCI6IiIsInVzZXJuYW1lIjoiIiwic2VwYXJhdG9yIjoiOiIsImNsdXN0ZXIiOmZhbHNlLCJrZXkiOiIxNjUwODk3NjIxNzU0X2I1bjB2Iiwib3JkZXIiOjF9XQ==
W3siaG9zdCI6ImxvY2FsaG9zdCIsInBvcnQiOiI2Mzc5IiwiYXV0aCI6InBhc3MiLCJ1c2VybmFtZSI6InVzZXJuYW1lVGVzdCIsIm5hbWUiOiJhcmRtV2l0aFBhc3NBbmRVc2VybmFtZSIsInNlcGFyYXRvciI6IjoiLCJjbHVzdGVyIjpmYWxzZSwia2V5IjoiMTY1MDM3MzUyNTY1MV9naHFwciIsIm9yZGVyIjowfSx7Imhvc3QiOiJhcmRtTm9OYW1lIiwicG9ydCI6IjEyMDAxIiwiYXV0aCI6IiIsInVzZXJuYW1lIjoiIiwic2VwYXJhdG9yIjoiOiIsImNsdXN0ZXIiOmZhbHNlLCJrZXkiOiIxNjUwODk3NjIxNzU0X2I1bjB2Iiwib3JkZXIiOjF9LHsiaG9zdCI6Im9zcy1zZW50aW5lbCIsInBvcnQiOiIyNjM3OSIsIm5hbWUiOiJhcmRtU2VudGluZWwiLCJhdXRoIjoicGFzc3dvcmQiLCJzZW50aW5lbE9wdGlvbnMiOnsibWFzdGVyTmFtZSI6InByaW1hcnktZ3JvdXAtMSIsIm5vZGVQYXNzd29yZCI6ImRlZmF1bHRwYXNzIn19XQ==
2 changes: 1 addition & 1 deletion tests/e2e/test-data/import-databases/racompass-valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"port": 1111,
"keyPrefix": null,
"id": "f99a5d6d-daf4-489c-885b-6f8e411adbc9",
"cluster": true,
"type": "cluster",
"name": "racompassCluster"
}
]
74 changes: 74 additions & 0 deletions tests/e2e/test-data/import-databases/rdm-certificates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[
{
"host": "localhost",
"port": 8102,
"name": "theSameBody1",
"caCert": {
"name": "testCaName",
"certificate": "-----BEGIN CERTIFICATE-----mockedCACertificate1-----END CERTIFICATE-----"
},
"clientCert": {
"name": "testClientCertName",
"certificate": "-----BEGIN CERTIFICATE-----mockedClientCertificate1-----END CERTIFICATE-----",
"key": "-----BEGIN PRIVATE KEY-----mockedClientKey1-----END PRIVATE KEY-----"
},
"result": "success"
},
{
"host": "localhost",
"port": 8101,
"name": "theSameBody2",
"caCert": {
"name": "testCaName2",
"certificate": "-----BEGIN CERTIFICATE-----mockedCACertificate1-----END CERTIFICATE-----"
},
"clientCert": {
"name": "testClientCertName2",
"certificate": "-----BEGIN CERTIFICATE-----mockedClientCertificate1-----END CERTIFICATE-----",
"key": "-----BEGIN PRIVATE KEY-----mockedClientKey1-----END PRIVATE KEY-----"
},
"result": "success"
},
{
"host": "localhost",
"port": 8103,
"name": "theSameName",
"caCert": {
"name": "testCaName",
"certificate": "-----BEGIN CERTIFICATE-----mockedCACertificate2-----END CERTIFICATE-----"
},
"clientCert": {
"name": "testClientCertName",
"certificate": "-----BEGIN CERTIFICATE-----mockedClientCertificate2-----END CERTIFICATE-----",
"key": "-----BEGIN PRIVATE KEY-----mockedClientKey2-----END PRIVATE KEY-----"
},
"result": "success"
},
{
"host": "localhost",
"port": 8102,
"name": "theSameBody1Path",
"ssl_ca_cert_path": "/root/certs/certsByPath/caPath.crt",
"ssl_local_cert_path": "/root/certs/certsByPath/clientPath.crt",
"ssl_private_key_path": "/root/certs/certsByPath/clientPath.key",
"result": "success"
},
{
"host": "localhost",
"port": 8101,
"name": "theSameBody2Path",
"ssl_ca_cert_path": "/root/certs/certsByPath/caSameBody.crt",
"ssl_local_cert_path": "/root/certs/certsByPath/clientSameBody.crt",
"ssl_private_key_path": "/root/certs/certsByPath/clientSameBody.key",
"result": "success"
},
{
"host": "localhost",
"port": 8103,
"name": "theSameNamePath",
"ssl_ca_cert_path": "/root/certs/sameNameCerts/caPath.crt",
"ssl_local_cert_path": "/root/certs/sameNameCerts/clientPath.crt",
"ssl_private_key_path": "/root/certs/sameNameCerts/clientPath.key",
"result": "success"
}
]
Loading