Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3493 from alistairmc/feature/Improve_the_403_Unau…
Browse files Browse the repository at this point in the history
…thorized_page_layout

[RHDX-158] Add 403 page config
  • Loading branch information
jordanpagewhite committed Feb 6, 2020
2 parents 478472e + b57da95 commit ef73ce7
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ url:
source: path_prefix
prefixes:
en: ''
'': null
domains:
en: ''
selected_langcode: site_default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: 'Red Hat Developer'
mail: rhd-drupal-admin@redhat.com
slogan: ''
page:
403: ''
403: /node/214865
404: /node/32155
front: /node/204425
admin_compact_mode: false
Expand Down
12 changes: 6 additions & 6 deletions _tests/e2e/tests/config/wdio.conf.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ const testProfile = typeof commandlineArgs.profile === 'undefined' ? 'desktop' :
const testType = typeof commandlineArgs.testType === 'undefined' ? 'export' : commandlineArgs.testType;
const exclude = testType === 'export' ? 'drupal' : 'export';
const host = typeof commandlineArgs['base-url'] === 'undefined' ? 'https://localhost' : commandlineArgs['base-url'];
const keyCloakUser = process.env.RHD_KEYCLOAK_ADMIN_USERNAME
const keyCloakPassword = process.env.RHD_KEYCLOAK_ADMIN_PASSWORD
const drupalUser = process.env.RHD_DRUPAL_ADMIN_USERNAME
const drupalPassword = process.env.RHD_DRUPAL_ADMIN_PASSWORD
const keyCloakUser = process.env.RHD_KEYCLOAK_ADMIN_USERNAME;
const keyCloakPassword = process.env.RHD_KEYCLOAK_ADMIN_PASSWORD;
const drupalUser = process.env.RHD_DRUPAL_ADMIN_USERNAME;
const drupalPassword = process.env.RHD_DRUPAL_ADMIN_PASSWORD;

checkPropertySet(keyCloakUser, 'RHD_KEYCLOAK_ADMIN_USERNAME');
checkPropertySet(keyCloakPassword, 'RHD_KEYCLOAK_ADMIN_PASSWORD');
checkPropertySet(drupalUser, 'RHD_DRUPAL_ADMIN_USERNAME');
checkPropertySet(drupalPassword, 'RHD_DRUPAL_ADMIN_PASSWORD');

function checkPropertySet(property, propertyName) {
if(property === undefined || property === '') {
if (property === undefined || property === '') {
throw new Error("You must set the environment variable '" + propertyName + "' for the tests to run.");
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ exports.config = {
onComplete: function() {
try {
const {execSync} = require('child_process');
execSync(`allure generate ./report/${testProfile}-results -o ./report/${testProfile}-report`)
execSync(`allure generate ./report/${testProfile}-results -o ./report/${testProfile}-report`);
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
Expand Down
12 changes: 12 additions & 0 deletions _tests/e2e/tests/specs/export/rhd-403-error.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Error403Page from '../support/pages/website/403-error.page';
import Driver from '../support/utils/Driver.Extension';

describe('403 Error Page', function() {
// eslint-disable-next-line no-invalid-this
this.retries(2);

it("should contain an <h1> with '403: Access is denied' inside it", () => {
Error403Page.open('/403-error/');
expect(Driver.getPageSource()).to.include("<h1>403: Access is denied</h1>");
});
});
5 changes: 1 addition & 4 deletions _tests/e2e/tests/specs/export/rhd-downloads.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ tags('desktop').describe('Download Manager', function() {
});

it('@downloads: should allow users to log-in and download advanced-linux-commands', function() {

/*
Please see https://issues.jboss.org/browse/DEVELOPER-5938
Expand All @@ -33,16 +32,14 @@ tags('desktop').describe('Download Manager', function() {
Fundamentally DownloadManager should respect environment configuration.
*/
if(Utils.isProduction()) {

if (Utils.isProduction()) {
CheatSheets
.open('advanced-linux-commands')
.loginToDownload();
Login.with(process.env.RHD_KEYCLOAK_ADMIN_USERNAME, process.env.RHD_KEYCLOAK_ADMIN_PASSWORD);
CheatSheets.awaitDownloadThankYou();
const downloadName = DownloadDir.get();
expect(downloadName.toString(), 'rhel advanced linux cheatsheet download was not triggered').to.include('rheladvancedlinux_cheat_sheet');

}
});

Expand Down
4 changes: 2 additions & 2 deletions _tests/e2e/tests/specs/support/Browser.Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Browser {
"prompt_for_download": false,
},
profile: {
"default_content_setting_values": { "automatic_downloads": 1 },
"default_content_setting_values": {"automatic_downloads": 1},
},
},
},
Expand Down Expand Up @@ -74,7 +74,7 @@ class Browser {
browserName: 'chrome',
acceptInsecureCerts: true,
'goog:chromeOptions': {
mobileEmulation: { deviceName: 'iPhone X' },
mobileEmulation: {deviceName: 'iPhone X'},
args: chromeArgs,
},
};
Expand Down
4 changes: 2 additions & 2 deletions _tests/e2e/tests/specs/support/pages/drupal/Config.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import Driver from "../../utils/Driver.Extension";

export class Config extends Page {
open() {
super.open('/admin/config/development/configuration')
super.open('/admin/config/development/configuration');
}

source() {
return Driver.getPageSource()
return Driver.getPageSource();
}
}
export default new Config;
4 changes: 3 additions & 1 deletion _tests/e2e/tests/specs/support/pages/drupal/Home.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import Page from "../Page";
import Driver from "../../utils/Driver.Extension";

class Home extends Page {
get toolbarItemUser() {return $('#toolbar-item-user');}
get toolbarItemUser() {
return $('#toolbar-item-user');
}

loggedInUser() {
return Driver.textOf(this.toolbarItemUser);
Expand Down
20 changes: 15 additions & 5 deletions _tests/e2e/tests/specs/support/pages/drupal/Login.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ import Page from "../Page";
import Driver from "../../utils/Driver.Extension";

class Login extends Page {
get loginPage() {return $('.kc-loginpage');}
get usernameField() {return $('#edit-name');}
get passwordField() {return $('#edit-pass');}
get loginButton() {return $('#edit-submit');}
get legacyLoginButton() {return $('#drupalUserLoginToggleVisibility');}
get loginPage() {
return $('.kc-loginpage');
}
get usernameField() {
return $('#edit-name');
}
get passwordField() {
return $('#edit-pass');
}
get loginButton() {
return $('#edit-submit');
}
get legacyLoginButton() {
return $('#drupalUserLoginToggleVisibility');
}

open() {
super.open('/user/login');
Expand Down
24 changes: 18 additions & 6 deletions _tests/e2e/tests/specs/support/pages/keycloak/Login.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ import Page from '../Page';
import Driver from '../../utils/Driver.Extension';

class Login extends Page {
get loginPage() {return $('.kc-loginpage');}
get usernameField() {return $('#username');}
get nextBtn() {return $('#login-show-step2');}
get passwordField() {return $('#password');}
get loginButton() {return $('#kc-login');}
get step2() {return $('#step2');}
get loginPage() {
return $('.kc-loginpage');
}
get usernameField() {
return $('#username');
}
get nextBtn() {
return $('#login-show-step2');
}
get passwordField() {
return $('#password');
}
get loginButton() {
return $('#kc-login');
}
get step2() {
return $('#step2');
}

open() {
super.open('/login');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import {Page} from "../Page";
import Driver from "../../utils/Driver.Extension";

class Register extends Page {
get registerForm() {return $('#kc-register-form');}
get registerForm() {
return $('#kc-register-form');
}

open() {
super.open('/register');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Page from '../Page';

class Error403Page extends Page {
open() {
super.open('/403-error/');
}
}

export default new Error403Page;
12 changes: 9 additions & 3 deletions _tests/e2e/tests/specs/support/pages/website/CheatSheets.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import Page from '../Page';
import Driver from '../../utils/Driver.Extension';

export class CheatSheets extends Page {
get cheatSheetPage() {return $('#rhd-cheat-sheet');}
get loginToDownloadBtn() {return $("//*[contains(text(),'Log in to download')]");}
get thankYou() {return $('.thankyou');}
get cheatSheetPage() {
return $('#rhd-cheat-sheet');
}
get loginToDownloadBtn() {
return $("//*[contains(text(),'Log in to download')]");
}
get thankYou() {
return $('.thankyou');
}

open(cheatSheet) {
super.open(`/cheat-sheets/${cheatSheet}/`.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,26 @@ import Page from '../Page';
import Driver from '../../utils/Driver.Extension';

class NavigationBar extends Page {
get mobileMenuOpen() {return $('.rhd-c-nav-dropdown');}
get loginLink() {return $$("li.login a");}
get mobileNavToggle() {return $('.hamburger');}
get searchToggle() {return $('a[data-rhd-nav-search-toggle]');}
get searchBar() {return $$('input[data-rhd-nav-search-input]');}
get mobileMenuOpen() {
return $('.rhd-c-nav-dropdown');
}
get loginLink() {
return $$("li.login a");
}
get mobileNavToggle() {
return $('.hamburger');
}
get searchToggle() {
return $('a[data-rhd-nav-search-toggle]');
}
get searchBar() {
return $$('input[data-rhd-nav-search-input]');
}

toggle() {
const mobileNavToggle = Driver.isVisible(this.mobileNavToggle);
if (mobileNavToggle) {
this.openMobileMenuWithRetry()
this.openMobileMenuWithRetry();
return true;
}
return false;
Expand All @@ -26,10 +36,10 @@ class NavigationBar extends Page {

openMobileMenuWithRetry() {
try {
this.openMobileMenu()
this.openMobileMenu();
} catch (err) {
console.log("Failed to open mobile menu, retrying...")
this.openMobileMenu()
console.log("Failed to open mobile menu, retrying...");
this.openMobileMenu();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import Page from '../Page';
import Driver from '../../utils/Driver.Extension';

class ProductOverview extends Page {
get downloadBtn() {return $('//rhdp-os-download/div/a');}
get downloadThankYou() {return $('#downloadthankyou');}
get downloadBtn() {
return $('//rhdp-os-download/div/a');
}
get downloadThankYou() {
return $('#downloadthankyou');
}

open(productCode, tab) {
super.open(`/products/${productCode}/${tab}`.toString());
Expand Down
6 changes: 4 additions & 2 deletions _tests/e2e/tests/specs/support/pages/website/Search.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import Page from '../Page';
import Driver from '../../utils/Driver.Extension';

class Search extends Page {
get searchPage() {return $('.searchpage-middle');}

get searchPage() {
return $('.searchpage-middle');
}

open() {
super.open('/search/');
return Driver.awaitIsDisplayed(this.searchPage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import Page from '../../../Page';
import Driver from '../../../../utils/Driver.Extension';

class SearchBox extends Page {
get searchField() {return $('#query');}
get searchField() {
return $('#query');
}

enterSearch(searchTerm) {
return Driver.type(searchTerm, this.searchField);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ import Page from '../../../Page';
import Driver from '../../../../utils/Driver.Extension';

class SearchFilter extends Page {
get showBtn() {return $('.showBtn');}
get cover() {return $('.cover');}
get applyFilters() {return $('.applyFilters');}
get activeFilters() {return $('.activeFilters');}
get clearFilters() {return $('.clearFilters');}
get showBtn() {
return $('.showBtn');
}
get cover() {
return $('.cover');
}
get applyFilters() {
return $('.applyFilters');
}
get activeFilters() {
return $('.activeFilters');
}
get clearFilters() {
return $('.clearFilters');
}

active() {
return this.activeFilters;
Expand Down Expand Up @@ -62,7 +72,7 @@ class SearchFilter extends Page {
Seems we need to wait for the menu to be fully displayed because we're at times getting partial menu displays in the test.
This solution is horrible. I've raised https://issues.jboss.org/browse/DEVELOPER-5896 for us to implement a better fix.
*/
Driver.pause(3000)
Driver.pause(3000);
return true;
}
return false;
Expand All @@ -75,4 +85,4 @@ class SearchFilter extends Page {
}
}

export default new SearchFilter;
export default new SearchFilter;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import Page from '../../../Page';
import Driver from '../../../../utils/Driver.Extension';

class SearchOneBox extends Page {
get oneBoxTitle() {return $('//rhdp-search-onebox//h4/a');}
get oneBoxTitle() {
return $('//rhdp-search-onebox//h4/a');
}

title() {
return Driver.textOf(this.oneBoxTitle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import SearchResults from './SearchResults';
import Driver from '../../../../utils/Driver.Extension';

class SearchResultSort extends Page {
get resultSort() {return $('//rhdp-search-sort-page/p/select');}
get resultSort() {
return $('//rhdp-search-sort-page/p/select');
}

get() {
return Driver.getValue(this.resultSort);
Expand Down
Loading

0 comments on commit ef73ce7

Please sign in to comment.