Skip to content

Commit

Permalink
Added test for JCERACFKS
Browse files Browse the repository at this point in the history
Signed-off-by: hpathak <[email protected]>
  • Loading branch information
hpathak committed Dec 20, 2024
1 parent 22e4dd9 commit a58c596
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 22 deletions.
88 changes: 74 additions & 14 deletions playwright_test/Pages/certificates.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,22 @@ class CertificatesPage{
pem_cert_key: locator;
pem_key: locator;
sanInput: locator;
keyringHeading: locator;
certificate_type: locator;
KeyringOwner: locator;
KeyringName: locator;
keyringLabel: locator;
keyringCaLabel: locator;
keyringConnect: locator;
keyringImport: locator;
keyringConnectUser: locator;
keyringDsName: locator;
keyringConnectLabel: locator;
keyringConnectPassword: locator;
KeyringZOSMF: locator;
keyringZOSMFUser: locator;
keyringZosmfCa: locator;
fillCerttificateType: locator;



Expand All @@ -64,7 +80,23 @@ class CertificatesPage{
this.click_CertificatePage = page.locator('//span[text()="Certificates"]')
this.option1 = page.locator('//span[text()="Option 1"]')
this.option2 = page.locator('//span[text()="Option 2"]')
this.keyringHeading = page.getByText('keyring').nth(2);
this.certificate_type = page.locator('//label[text()="Type"]')
this.KeyringOwner = page.locator('//label[text()="Owner"]')
this.KeyringName = page.locator('//label[text()="Name"]')
this.keyringLabel = page.locator('//label[text()="Label"]').nth(1)
this.keyringCaLabel = page.locator('//label[text()="Ca Label"]')
this.keyringConnect = page.locator('//span[text() = "Connect"]')
this.keyringImport = page.locator('//span[text() = "Import"]')
this.keyringConnectUser = page.locator('//span[text() = "User"]').nth(1)
this.keyringDsName = page.locator('//span[text() = "Ds Name"]')
this.keyringConnectLabel = page.locator('//span[text() = "Label"]').nth(2)
this.keyringConnectPassword = page.locator('//span[text() = "Password"]')
this.KeyringZOSMF = page.locator('//label[text()="Z OSMF"]')
this.keyringZOSMFUser= page.locator('//span[text() = "User"]').nth(2)
this.keyringZosmfCa= page.locator('//span[text() = "ca"]')
this.fillCerttificateType = page.getByLabel('Type')

this.click_dropdown = page.locator('//button[@title="Open"]')
this.keystore_directory = page.locator('//label[text()="Directory"]')
this.keystore_value = page.locator("//html/body/div[1]/div[2]/div/div[4]/div/form/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/div[1]/div/div[1]/div/div/input");
Expand Down Expand Up @@ -131,6 +163,23 @@ class CertificatesPage{
return await this.pageTitle.textContent({ timeout: 2000 });
}

async clickOption2() {
await this.option2.scrollIntoViewIfNeeded({ timeout: 2000 });
await this.option2.click({ timeout: 2000 });
}

async clickOption1() {
await this.option1.scrollIntoViewIfNeeded({ timeout: 2000 });
await this.option1.click({ timeout: 2000 });
}

async fillCertificateType(certificateType: string){
await this.page.waitForTimeout(500)
await this.fillCerttificateType.fill(certificateType);
await this.page.keyboard.press('Enter');
await this.page.waitForTimeout(5000)
}

async returnTitleOfCertiPage(){
const certificate_title = await this.CERTIFICATE_TITLE.textContent();
return certificate_title;
Expand Down Expand Up @@ -287,9 +336,14 @@ class CertificatesPage{

async Lock_checkbox_Ischecked(){
await this.click_lockCheckbox.click({ timeout: 5000 });

return await this.click_lockCheckbox.isChecked();
}



async isKeyringHeadingVisible() {
const element = this.page.getByText('keyring').nth(2);
const isPresent = await element.isVisible();

Check warning on line 346 in playwright_test/Pages/certificates.page.ts

View workflow job for this annotation

GitHub Actions / lint

'isPresent' is assigned a value but never used
}


Expand Down Expand Up @@ -347,23 +401,29 @@ class CertificatesPage{
}
}

async updateEditorYaml(keyPath: string, newValue: string): Promise<void> {
const editorLocator = this.page.locator('//*[@id="monaco-editor-container"]/div');

async updateEditorYaml(updates: { keyPath: string; newValue: string }[]): Promise<void> {
const editorLocator = this.page.locator('//*[@id="monaco-editor-container"]/div');
await editorLocator.click();
await this.page.keyboard.press('Control+F');
await this.page.waitForTimeout(500);
await this.page.keyboard.press('Control+F');
await this.page.waitForTimeout(500);
await this.page.keyboard.press('Alt+R');
for (const { keyPath, newValue } of updates) {
await this.page.keyboard.press('Control+F');
await this.page.keyboard.type(keyPath);
await this.page.waitForTimeout(500);

await this.page.keyboard.type(keyPath);
await this.page.waitForTimeout(500);
await this.page.keyboard.press('Control+H');
await this.page.waitForTimeout(500);
await this.page.keyboard.type(newValue);

await this.page.keyboard.press('Control+H');
await this.page.waitForTimeout(500);
await this.page.keyboard.type(newValue);
await this.page.keyboard.press('Control+Alt+Enter');
await this.page.waitForTimeout(500);
await this.page.keyboard.press('Escape');

await this.page.keyboard.press('Control+Alt+Enter');
await this.page.waitForTimeout(5000);
console.log(`Replaced all appearances of "${keyPath}" with "${newValue}"`);
}
}

console.log(`Replaced all appearances of "${keyPath}" with "${newValue}"`);
}
}
export default CertificatesPage;
66 changes: 58 additions & 8 deletions playwright_test/Tests/Certificates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ test.describe('CertificateTab', () => {
config.AUTH_LOAD_LIB,
config.AUTH_PLUGIN_LIB
)
await installationPage.clickInstallMvsDatasets();
await installationPage.clickInstallMvsDatasets();
await installationPage.clickContinueToNetworkSetup();
await certificatePage.movetoCertificatePage();

Expand All @@ -102,9 +102,24 @@ test.describe('CertificateTab', () => {
await electronApp.close()
})

test('test title of page & required fields', async ({ page }) => {
test('test title of page & required fields', async ({ page }) => {
const title = await certificatePage.returnTitleOfCertiPage();
expect(title).toBe(CERTIFICATE_TITLE);
await certificatePage.clickOption2()
await expect(certificatePage.keyringHeading).toBeTruthy()
await expect(certificatePage.KeyringOwner).toBeTruthy()
await expect(certificatePage.keyringLabel).toBeTruthy()
await expect(certificatePage.keyringCaLabel).toBeTruthy()
await expect(certificatePage.keyringConnect).toBeTruthy()
await expect(certificatePage.keyringImport).toBeTruthy()
await expect(certificatePage.keyringConnectUser).toBeTruthy()
await expect(certificatePage.keyringDsName).toBeTruthy()
await expect(certificatePage.keyringConnectLabel).toBeTruthy()
await expect(certificatePage.keyringConnectPassword).toBeTruthy()
await expect(certificatePage.KeyringZOSMF).toBeTruthy()
await expect(certificatePage.keyringZOSMFUser).toBeTruthy()
await expect(certificatePage.keyringZosmfCa).toBeTruthy()
await certificatePage.clickOption1()
await expect(certificatePage.option1).toBeTruthy()
await expect(certificatePage.option2).toBeTruthy()
await expect(certificatePage.keystore_directory).toBeTruthy()
Expand All @@ -128,9 +143,45 @@ test.describe('CertificateTab', () => {
await expect(certificatePage.import_certificate_authorities).toBeTruthy()
await expect(certificatePage.verify_certificates).toBeTruthy()
const verifyList = await certificatePage.verifyCertificatesList();
expect(verifyList).toEqual(VERIFY_CERTIFICATE_LIST);
await expect(verifyList).toEqual(VERIFY_CERTIFICATE_LIST);
})


test('Test init JCERACFKS certificates with NONSTRICT Mode', async ({ page }) => {
await script.runCommand(`chmod -R 777 ${process.env.ZOWE_ROOT_DIR}/keystore &&
rm -r ${process.env.ZOWE_ROOT_DIR}/keystore`);
await certificatePage.viewYaml();
await expect(certificatePage.editor_title_element).toBeTruthy();
const updates = [
{ keyPath: 'pem:\\s*\\n\\s*key:\\s[^\\n]*\\n\\s*certificate:\\s[^\\n]*\\n\\s*certificateAuthorities:\\s[^\\n]*', newValue: ''},
{ keyPath: '(?<=alias:\\s).*$', newValue: 'ZWEMVDJS' },
{ keyPath: '(?<=truststore:\\s+(?:.*\\n)*?\\s+type:\\s*)\\S.*', newValue: 'JCERACFKS' },
{ keyPath: '(?<=keystore:\\s+(?:.*\\n)*?\\s+type:\\s*)\\S.*', newValue: 'JCERACFKS' },
{ keyPath: '(?<=password:\\s).*$', newValue: 'password' },
{ keyPath: '(?<=file:\\s).*$', newValue: 'safkeyring://ZWESMVD/ZoweKeyring' }
];
await certificatePage.updateEditorYaml(updates);
await certificatePage.closeButton();
await certificatePage.viewYaml();
const valueExists = await certificatePage.read_yaml();
for (const { newValue } of updates) {
if (newValue !== '') {
await expect(valueExists).toContain(newValue);
}
}
await certificatePage.closeButton();
await certificatePage.fillKeystoreDir(`${config.ZOWE_ROOT_DIR}/keystore`);
await certificatePage.select_VerifyCert('DISABLED');
await certificatePage.initializeCert();
const isWriteConfigCheckVisible = await certificatePage.isWriteConfigGreenCheckVisible();
await expect(isWriteConfigCheckVisible).toBe(true);
const isUploadConfigCheckVisible = await certificatePage.isUploadConfigGreenCheckVisible();
await expect(isUploadConfigCheckVisible).toBe(true);
const isInitCertCheckVisible = await certificatePage.isInitCertGreenCheckVisible();
await expect(isInitCertCheckVisible).toBe(true);
const is_ContinueButtonDisable = await certificatePage.isContinueButtonDisable();
await expect(is_ContinueButtonDisable).toBe(false);
});

test('Test Skip certificate button is enable', async ({ page }) => {
const isLaunchConfigEnable = await certificatePage.is_skipCertificateButtonEnable();
expect(isLaunchConfigEnable).toBe(true);
Expand Down Expand Up @@ -186,7 +237,7 @@ test('Test init certificates with NONSTRICT Mode & verify keystore dir created s
rm -r ${process.env.ZOWE_ROOT_DIR}/keystore`);
await certificatePage.viewYaml();
await expect(certificatePage.editor_title_element).toBeTruthy();
await certificatePage.updateEditorYaml('/global/zowe', config.ZOWE_ROOT_DIR);
await certificatePage.updateEditorYaml([{ keyPath: '/global/zowe', newValue: config.ZOWE_ROOT_DIR }]);
await certificatePage.closeButton();
await certificatePage.viewYaml();
const valueExists = await certificatePage.read_yaml();
Expand Down Expand Up @@ -217,7 +268,7 @@ test('Test init certificates with Disabled Mode and verify certificates configur
rm -r ${process.env.ZOWE_ROOT_DIR}/keystore`);
await certificatePage.viewYaml();
await expect(certificatePage.editor_title_element).toBeTruthy();
await certificatePage.updateEditorYaml('/global/zowe', config.ZOWE_ROOT_DIR);
await certificatePage.updateEditorYaml([{ keyPath: '/global/zowe', newValue: config.ZOWE_ROOT_DIR }]);
await certificatePage.closeButton();
await certificatePage.viewYaml();
const valueExists = await certificatePage.read_yaml();
Expand Down Expand Up @@ -249,7 +300,7 @@ test('Test init certificates with Lock keystore dir', async ({ page }) => {
rm -r ${process.env.ZOWE_ROOT_DIR}/keystore`);
await certificatePage.viewYaml();
await expect(certificatePage.editor_title_element).toBeTruthy();
await certificatePage.updateEditorYaml('/global/zowe', config.ZOWE_ROOT_DIR);
await certificatePage.updateEditorYaml([{ keyPath: '/global/zowe', newValue: config.ZOWE_ROOT_DIR }]);
await certificatePage.closeButton();
await certificatePage.fillKeystoreDir(`${config.ZOWE_ROOT_DIR}/keystore`);
const isChecked = await certificatePage.Lock_checkbox_Ischecked();
Expand All @@ -263,4 +314,3 @@ test('Test init certificates with Lock keystore dir', async ({ page }) => {
});

});

0 comments on commit a58c596

Please sign in to comment.