Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Adds i18n config test to be used in widget PDV #893

Merged
merged 2 commits into from
Sep 3, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,7 @@

const constants = require('../util/constants');
const util = require('../util/util');

let cdnUrl='https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/3.0.0';

if(process.env.NPM_TARBALL_URL) {
// Extract the version of sign-in widget from the NPM_TARBALL_URL variable
// The variable is of the format https:<artifactory_url>/@okta/okta-signin-widget-3.0.6.tgz
const url = process.env.NPM_TARBALL_URL;
const i = url.lastIndexOf('-');
const version = url.substring(i + 1, url.length - 4);
cdnUrl=`https://global.oktacdn.com/okta-signin-widget/${version}`;
}
console.log(`Using CDN url - ${cdnUrl}`);
const cdnUrl = 'https://global.oktacdn.com/okta-signin-widget/4.4.1';

const serverOptions = {
issuer: constants.ISSUER,
Expand Down
12 changes: 11 additions & 1 deletion packages/oidc-middleware/test/e2e/harness/views/login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@
<div id="banner"><center>Custom Login Page</center></div>
<div id="app-container"></div>
<script type="text/javascript">
console.log('<%= baseUrl %>');
const signIn = new OktaSignIn({
baseUrl: '<%= baseUrl %>' // e.g. https://dev-1234.oktapreview.com
baseUrl: '<%= baseUrl %>', // e.g. https://dev-1234.oktapreview.com
language: '<%= language %>',
i18n: {
en: {
'primaryauth.title': 'Sign in to Acme',
},
fr: {
'primaryauth.title': 'Connectez-vous à Acme',
}
}
});

signIn.renderEl({ el: '#app-container' }, (res) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module.exports = class OktaSignInPage {
this.password = $('[name=password]');
this.submit = $('#okta-signin-submit');
this.banner = $('#banner');
this.pageTitle = $('[data-se=o-form-head]');
this.usernameLabel = $('[data-se=o-form-label] [for=okta-signin-username]');
this.passwordLabel = $('[data-se=o-form-label] [for=okta-signin-password]');
}

async load() {
Expand Down
26 changes: 22 additions & 4 deletions packages/oidc-middleware/test/e2e/specs/custom-login-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,26 @@ browser.waitForAngularEnabled(false);
describe('Custom login page', () => {
let server;
beforeEach(async () => {
let cdnUrl='https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/3.0.0';
let widgetVersion = '4.4.1';
const options = {};

// This is used as PDV for widget after artifact promotion to CDN
if(process.env.NPM_TARBALL_URL) {
// Extract the version of sign-in widget from the NPM_TARBALL_URL variable
// The variable is of the format https:<artifactory_url>/@okta/okta-signin-widget-3.0.6.tgz
const url = process.env.NPM_TARBALL_URL;
const i = url.lastIndexOf('-');
const version = url.substring(i + 1, url.length - 4);
cdnUrl=`https://global.oktacdn.com/okta-signin-widget/${version}`;
widgetVersion = url.substring(i + 1, url.length - 4);

// We also test i18n assets on CDN
options.language = 'fr';
options.i18n = {
fr: {
'primaryauth.title': 'Connectez-vous à Acme',
}
}
}
const cdnUrl = `https://global.oktacdn.com/okta-signin-widget/${widgetVersion}`;
console.log(`Using CDN url - ${cdnUrl}`);

const serverOptions = {
Expand All @@ -40,7 +50,8 @@ describe('Custom login page', () => {
testing: {
disableHttpsCheck: constants.OKTA_TESTING_DISABLEHTTPSCHECK
},
cdnUrl: cdnUrl
cdnUrl: cdnUrl,
options: options
}

server = util.createDemoServerWithCustomLoginPage(serverOptions);
Expand All @@ -57,6 +68,13 @@ describe('Custom login page', () => {
await browser.sleep(3000);
await signInPage.waitUntilVisible();

// If we're testing widget i18n options (widget PDV)
if(process.env.NPM_TARBALL_URL) {
expect(signInPage.pageTitle.getText()).toBe('Connectez-vous à Acme');
expect(signInPage.usernameLabel.getText()).toBe('Nom d\'utilisateur ');
expect(signInPage.passwordLabel.getText()).toBe('Mot de passe ');
}

await signInPage.signIn({
username: constants.USERNAME,
password: constants.PASSWORD
Expand Down
5 changes: 4 additions & 1 deletion packages/oidc-middleware/test/e2e/util/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ util.createDemoServerWithCustomLoginPage = (options) => {
login: {
viewHandler: (req, res/*, next */) => {
const baseUrl = url.parse(baseConfig.issuer).protocol + '//' + url.parse(baseConfig.issuer).host;

res.render('login', {
csrfToken: req.csrfToken(),
baseUrl: baseUrl,
cdnUrl: baseConfig.cdnUrl
cdnUrl: baseConfig.cdnUrl,
language: baseConfig.options.language,
i18n: baseConfig.options.i18n
});
}
}
Expand Down