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

Commit

Permalink
Adds i18n config test to be used in widget PDV
Browse files Browse the repository at this point in the history
  • Loading branch information
vijetmahabaleshwar-okta committed Sep 3, 2020
1 parent aed57b3 commit a30771d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@

const constants = require('../util/constants');
const util = require('../util/util');
let options = {};
let cdnUrl = 'https://global.oktacdn.com/okta-signin-widget/4.4.1';

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

// 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}`;

// We also test i18n assets on CDN
options.language = 'fr';
options.i18n = {
fr: {
'primaryauth.title': 'Connectez-vous à Acme',
}
}
}
console.log(`Using CDN url - ${cdnUrl}`);

Expand All @@ -33,7 +42,8 @@ const serverOptions = {
testing: {
disableHttpsCheck: constants.OKTA_TESTING_DISABLEHTTPSCHECK
},
cdnUrl: cdnUrl
cdnUrl: cdnUrl,
options: options
}

console.log('serverOptions', serverOptions);
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
22 changes: 19 additions & 3 deletions packages/oidc-middleware/test/e2e/specs/custom-login-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@ 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 cdnUrl = 'https://global.oktacdn.com/okta-signin-widget/4.4.1';
let 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}`;
// We also test i18n assets on CDN
options.language = 'fr';
options.i18n = {
fr: {
'primaryauth.title': 'Connectez-vous à Acme',
}
}
}
console.log(`Using CDN url - ${cdnUrl}`);

Expand All @@ -40,7 +48,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 +66,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

0 comments on commit a30771d

Please sign in to comment.