|
| 1 | +import { rte } from '../../../../helpers/constants'; |
| 2 | +import { BrowserPage, MyRedisDatabasePage } from '../../../../pageObjects'; |
| 3 | +import { commonUrl, ossStandaloneForSSHConfig } from '../../../../helpers/conf'; |
| 4 | +import { DatabaseHelper } from '../../../../helpers/database'; |
| 5 | +import { DatabaseAPIRequests } from '../../../../helpers/api/api-database'; |
| 6 | +import { sshPrivateKey, sshPrivateKeyWithPasscode } from '../../../../test-data/sshPrivateKeys'; |
| 7 | +import { Common } from '../../../../helpers/common'; |
| 8 | +// import { BrowserActions } from '../../../common-actions/browser-actions'; |
| 9 | + |
| 10 | +const myRedisDatabasePage = new MyRedisDatabasePage(); |
| 11 | +const browserPage = new BrowserPage(); |
| 12 | +const databaseHelper = new DatabaseHelper(); |
| 13 | +const databaseAPIRequests = new DatabaseAPIRequests(); |
| 14 | +// const browserActions = new BrowserActions(); |
| 15 | + |
| 16 | +const sshParams = { |
| 17 | + sshHost: '172.31.100.245', |
| 18 | + sshPort: '2222', |
| 19 | + sshUsername: 'u' |
| 20 | +}; |
| 21 | +const newClonedDatabaseAlias = 'Cloned ssh database'; |
| 22 | +const sshDbPass = { |
| 23 | + ...ossStandaloneForSSHConfig, |
| 24 | + databaseName: `SSH_${Common.generateWord(5)}` |
| 25 | +}; |
| 26 | +const sshDbPrivateKey = { |
| 27 | + ...ossStandaloneForSSHConfig, |
| 28 | + databaseName: `SSH_${Common.generateWord(5)}` |
| 29 | +}; |
| 30 | +const sshDbPasscode = { |
| 31 | + ...ossStandaloneForSSHConfig, |
| 32 | + databaseName: `SSH_${Common.generateWord(5)}` |
| 33 | +}; |
| 34 | + |
| 35 | +fixture `Adding database with SSH` |
| 36 | + .meta({ type: 'critical_path', rte: rte.standalone }) |
| 37 | + .page(commonUrl) |
| 38 | + .beforeEach(async() => { |
| 39 | + await databaseHelper.acceptLicenseTerms(); |
| 40 | + }) |
| 41 | + .after(async() => { |
| 42 | + // Delete databases |
| 43 | + await databaseAPIRequests.deleteStandaloneDatabasesByNamesApi([sshDbPass.databaseName, sshDbPrivateKey.databaseName, sshDbPasscode.databaseName, newClonedDatabaseAlias]); |
| 44 | + }); |
| 45 | +test('Adding database with SSH', async t => { |
| 46 | + const sshWithPass = { |
| 47 | + ...sshParams, |
| 48 | + sshPassword: 'pass' |
| 49 | + }; |
| 50 | + const sshWithPrivateKey = { |
| 51 | + ...sshParams, |
| 52 | + sshPrivateKey: sshPrivateKey |
| 53 | + }; |
| 54 | + const sshWithPassphrase = { |
| 55 | + ...sshParams, |
| 56 | + sshPrivateKey: sshPrivateKeyWithPasscode, |
| 57 | + sshPassphrase: 'test' |
| 58 | + }; |
| 59 | + // update after resolving testcafe Native Automation mode limitations |
| 60 | + // // Verify that if user have not entered any required value he can see that this field should be specified when hover over the button to add a database |
| 61 | + // await t |
| 62 | + // .click(myRedisDatabasePage.AddRedisDatabase.addDatabaseButton) |
| 63 | + // .click(myRedisDatabasePage.AddRedisDatabase.addDatabaseManually) |
| 64 | + // .click(myRedisDatabasePage.AddRedisDatabase.useSSHCheckbox) |
| 65 | + // .click(myRedisDatabasePage.AddRedisDatabase.sshPrivateKeyRadioBtn) |
| 66 | + // .hover(myRedisDatabasePage.AddRedisDatabase.addRedisDatabaseButton); |
| 67 | + // for (const text of tooltipText) { |
| 68 | + // await browserActions.verifyTooltipContainsText(text, true); |
| 69 | + // } |
| 70 | + // // Verify that user can see the Test Connection button enabled/disabled with the same rules as the button to add/apply the changes |
| 71 | + // await t.hover(myRedisDatabasePage.AddRedisDatabase.testConnectionBtn); |
| 72 | + // for (const text of tooltipText) { |
| 73 | + // await browserActions.verifyTooltipContainsText(text, true); |
| 74 | + // } |
| 75 | + |
| 76 | + // Verify that user can add SSH tunnel with Password for Standalone database |
| 77 | + // await t.click(myRedisDatabasePage.AddRedisDatabase.cancelButton); |
| 78 | + await myRedisDatabasePage.AddRedisDatabase.addStandaloneSSHDatabase(sshDbPass, sshWithPass); |
| 79 | + await myRedisDatabasePage.clickOnDBByName(sshDbPass.databaseName); |
| 80 | + await Common.checkURLContainsText('browser'); |
| 81 | + |
| 82 | + // Verify that user can add SSH tunnel with Private Key |
| 83 | + await t.click(browserPage.OverviewPanel.myRedisDBLink); |
| 84 | + await myRedisDatabasePage.AddRedisDatabase.addStandaloneSSHDatabase(sshDbPrivateKey, sshWithPrivateKey); |
| 85 | + await myRedisDatabasePage.clickOnDBByName(sshDbPrivateKey.databaseName); |
| 86 | + await Common.checkURLContainsText('browser'); |
| 87 | + |
| 88 | + // Verify that user can edit SSH parameters for existing database connections |
| 89 | + await t.click(browserPage.OverviewPanel.myRedisDBLink); |
| 90 | + await myRedisDatabasePage.clickOnEditDBByName(sshDbPrivateKey.databaseName); |
| 91 | + await t |
| 92 | + .typeText(myRedisDatabasePage.AddRedisDatabase.sshPrivateKeyInput, sshWithPassphrase.sshPrivateKey, { replace: true, paste: true }) |
| 93 | + .typeText(myRedisDatabasePage.AddRedisDatabase.sshPassphraseInput, sshWithPassphrase.sshPassphrase, { replace: true, paste: true }); |
| 94 | + await t.click(myRedisDatabasePage.AddRedisDatabase.addRedisDatabaseButton); |
| 95 | + await t.expect(myRedisDatabasePage.AddRedisDatabase.addRedisDatabaseButton.exists).notOk('Edit database panel still displayed'); |
| 96 | + await databaseHelper.clickOnEditDatabaseByName(sshDbPrivateKey.databaseName); |
| 97 | + await t |
| 98 | + .expect(myRedisDatabasePage.AddRedisDatabase.sshPrivateKeyInput.value).eql(sshWithPassphrase.sshPrivateKey, 'Edited Private key not saved') |
| 99 | + .expect(myRedisDatabasePage.AddRedisDatabase.sshPassphraseInput.value).eql(sshWithPassphrase.sshPassphrase, 'Edited Passphrase not saved'); |
| 100 | + |
| 101 | + // Verify that user can clone database with SSH tunnel |
| 102 | + await databaseHelper.clickOnEditDatabaseByName(sshDbPrivateKey.databaseName); |
| 103 | + await t.click(myRedisDatabasePage.AddRedisDatabase.cloneDatabaseButton); |
| 104 | + // Edit Database alias before cloning |
| 105 | + await t.typeText(myRedisDatabasePage.AddRedisDatabase.databaseAliasInput, newClonedDatabaseAlias, { replace: true }); |
| 106 | + await t.click(myRedisDatabasePage.AddRedisDatabase.addRedisDatabaseButton); |
| 107 | + await t.expect(myRedisDatabasePage.dbNameList.withExactText(newClonedDatabaseAlias).exists).ok('DB with SSH was not cloned'); |
| 108 | + |
| 109 | + // Verify that user can add SSH tunnel with Passcode |
| 110 | + await myRedisDatabasePage.AddRedisDatabase.addStandaloneSSHDatabase(sshDbPasscode, sshWithPassphrase); |
| 111 | + await myRedisDatabasePage.clickOnDBByName(sshDbPasscode.databaseName); |
| 112 | + await Common.checkURLContainsText('browser'); |
| 113 | +}); |
0 commit comments