Skip to content

Commit

Permalink
Don't call updateAuthState during handleAuthentication
Browse files Browse the repository at this point in the history
OKTA-415108
<<<Jenkins Check-In of Tested SHA: ef487bb for eng_productivity_ci_bot_okta@okta.com>>>
Artifact: okta-react
Files changed count: 12
PR Link:
  • Loading branch information
denys.oblohin authored and eng-prod-CI-bot-okta committed Jul 26, 2021
1 parent 87106f5 commit 97fb325
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 178 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
/dist
/scripts
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 3.0.11

### Bug Fixes

- [#150](https://github.com/okta/okta-react/pull/150) fixes issue with displaying error in `LoginCallback`

# 3.0.10

### Bug Fixes
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@okta/okta-react",
"version": "3.0.10",
"version": "3.0.11",
"description": "React support for Okta",
"private": true,
"scripts": {
Expand All @@ -12,6 +12,7 @@
"lint:report": "eslint -f checkstyle -o ./test-reports/lint/eslint-checkstyle-result.xml .",
"prepare": "yarn build",
"start": "yarn --cwd test/e2e/harness start",
"pretest:e2e": "node ./scripts/update-se-drivers.js",
"test": "yarn lint && yarn test:unit && yarn test:e2e",
"test:e2e": "yarn --cwd test/e2e/harness test",
"test:unit": "jest"
Expand Down Expand Up @@ -52,6 +53,7 @@
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"@babel/preset-react": "^7.10.4",
"axios": "^0.21.0",
"babel-jest": "^26.3.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"chalk": "^4.1.0",
Expand Down
1 change: 1 addition & 0 deletions scripts/travis.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set -e
# if this build was triggered via a cron job, run tests on sauce labs
if [ "${TRAVIS_EVENT_TYPE}" = "cron" ] ; then
yarn pretest
yarn test:e2e
else
# run the lint, unit and e2e tests (on chrome headless)
Expand Down
41 changes: 41 additions & 0 deletions scripts/update-se-drivers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const axios = require('axios');
const { execSync } = require('child_process');

function getOS() {
let os = process.platform;
if (os === 'darwin') {
os = 'MacOS';
} else if (os === 'win32' || os === 'win64') {
os = 'Windows';
} else if (os === 'linux') {
os = 'Linux';
}
return os;
}

const os = getOS();
console.log(`Operating System - ${os}`);

let chromeVersion;
if (os === 'MacOS') {
const chromeVersionString = execSync('/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --version').toString();
// Get the major and minor version of the chrome version using regex (1 or more digits followed by a dot followed by 1 or more digits)
const matchIndex = 0;
chromeVersion = chromeVersionString.match(/(\d+(\.\d+)?)/)[matchIndex];
} else {
chromeVersion = execSync('google-chrome --product-version').toString();
}

const chromeMajorVersion = chromeVersion.split('.')[0];
console.log(`Chrome Major Version - ${chromeMajorVersion}`);

const chromeDriverUrl = `https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${chromeMajorVersion}`;

axios.get(chromeDriverUrl).then((response) => {
const chromeDriverVersion = response.data;
console.log(`Chrome Driver Version - ${chromeDriverVersion}`);

execSync(`${__dirname}/../node_modules/protractor/bin/webdriver-manager update --versions.chrome ${chromeDriverVersion} --gecko false --versions.standalone latest`);
}).catch((err) => {
console.log(err);
});
174 changes: 0 additions & 174 deletions scripts/update_se_drivers.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/Security.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Security = (props) => {
setAuthState(authService.getAuthState());
});

if (!authService._oktaAuth.token.isLoginRedirect()) {
if (!authService._oktaAuth.token.isLoginRedirect() && !authService._pending.handleAuthentication) {
// Trigger an initial change event to make sure authState is latest when not in loginRedirect state
authService.updateAuthState();
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/harness/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"start": "PORT=8080 react-app-rewired start",
"build": "react-app-rewired build",
"kill:port": "kill -s TERM $(lsof -t -i:8080 -sTCP:LISTEN) || true",
"pretest": "../../../scripts/update_se_drivers.sh 0",
"pretest": "node ../../../scripts/update-se-drivers.js",
"wait:server": "BROWSER=none yarn start & ./node_modules/.bin/wait-on http://localhost:8080",
"test": "yarn wait:server && yarn protractor",
"posttest": "yarn kill:port",
Expand Down
1 change: 1 addition & 0 deletions test/jest/loginCallback.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('<LoginCallback />', () => {
updateAuthState: jest.fn(),
getAuthState: jest.fn().mockImplementation(() => authState),
handleAuthentication: jest.fn(),
_pending: {},
_oktaAuth: {
token: {
isLoginRedirect: jest.fn().mockImplementation(() => false)
Expand Down
1 change: 1 addition & 0 deletions test/jest/secureRoute.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('<SecureRoute />', () => {
updateAuthState: jest.fn(),
getAuthState: jest.fn().mockImplementation(() => authState),
login: jest.fn(),
_pending: {},
_oktaAuth: {
token: {
isLoginRedirect: jest.fn().mockImplementation(() => false)
Expand Down
1 change: 1 addition & 0 deletions test/jest/security.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('<Security />', () => {
on: jest.fn(),
updateAuthState: jest.fn(),
getAuthState: jest.fn().mockImplementation(() => initialAuthState),
_pending: {},
_oktaAuth: {
token: {
isLoginRedirect: jest.fn().mockImplementation(() => false)
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3775,6 +3775,13 @@ axe-core@^3.5.4:
resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-3.5.5.tgz#84315073b53fa3c0c51676c588d59da09a192227"
integrity sha512-5P0QZ6J5xGikH780pghEdbEKijCTrruK9KxtPZCFWUpef0f6GipO+xEZ5GKCb020mmqgbiNO6TcA55CriL784Q==

axios@^0.21.0:
version "0.21.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.0.tgz#26df088803a2350dff2c27f96fef99fe49442aca"
integrity sha512-fmkJBknJKoZwem3/IKSSLpkdNXZeBu5Q7GA/aRsr2btgrptmSCxi2oFjZHqGdK9DoTil9PIHlPIZw2EcRJXRvw==
dependencies:
follow-redirects "^1.10.0"

axobject-query@^2.0.2, axobject-query@^2.1.2:
version "2.2.0"
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.2.0.tgz#943d47e10c0b704aa42275e20edf3722648989be"
Expand Down Expand Up @@ -7903,7 +7910,7 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"

follow-redirects@^1.0.0:
follow-redirects@^1.0.0, follow-redirects@^1.10.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db"
integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==
Expand Down

0 comments on commit 97fb325

Please sign in to comment.