AAE-22865 - Fixing webdriver version used and installed (#9749)

* Fixing webdriver version used and installed

* Fixing webdriver selenium version

* Disabling Code flow for grant password auth

* Removing the install from the script as it's done in the postinstall now

* It's funny how this tests work

* Having codeflow disabled by default

* Checking if Core tests pass

* Refreshing as SSO button is broken after clicking apply
This commit is contained in:
Vito Albano
2024-05-30 16:36:48 +01:00
committed by GitHub
parent a1555074a7
commit 6bdfd83dac
10 changed files with 249 additions and 133 deletions

View File

@@ -1,9 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const semver = require("semver");
const config_1 = require("../config");
const http_utils_1 = require("../http_utils");
const config_source_1 = require("./config_source");
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const semver = require('semver');
const config_1 = require('../config');
const http_utils_1 = require('../http_utils');
const config_source_1 = require('./config_source');
class ChromeXml extends config_source_1.XmlConfigSource {
constructor() {
super('chrome', config_1.Config.cdnUrls()['chrome']);
@@ -12,8 +12,7 @@ class ChromeXml extends config_source_1.XmlConfigSource {
getUrl(version) {
if (version === 'latest') {
return this.getLatestChromeDriverVersion();
}
else {
} else {
return this.getSpecificChromeDriverVersion(version);
}
}
@@ -21,16 +20,17 @@ class ChromeXml extends config_source_1.XmlConfigSource {
* Get a list of chrome drivers paths available for the configuration OS type and architecture.
*/
getVersionList() {
return this.getXml().then(xml => {
return this.getXml().then((xml) => {
let versionPaths = [];
let osType = this.getOsTypeName();
for (let content of xml.ListBucketResult.Contents) {
let contentKey = content.Key[0];
if (
// Filter for 32-bit devices, make sure x64 is not an option
(this.osarch.includes('64') || !contentKey.includes('64')) &&
// Filter for 32-bit devices, make sure x64 is not an option
(this.osarch.includes('64') || !contentKey.includes('64')) &&
// Filter for x86 macs, make sure m1 is not an option
((this.ostype === 'Darwin' && this.osarch === 'arm64') || !contentKey.includes('m1'))) {
((this.ostype === 'Darwin' && this.osarch === 'arm64') || !contentKey.includes('m1'))
) {
// Filter for only the osType
if (contentKey.includes(osType)) {
versionPaths.push(contentKey);
@@ -46,97 +46,96 @@ class ChromeXml extends config_source_1.XmlConfigSource {
getOsTypeName() {
// Get the os type name.
if (this.ostype === 'Darwin') {
return 'mac';
}
else if (this.ostype === 'Windows_NT') {
return 'win';
}
else {
return 'linux';
return 'mac-x64';
} else if (this.ostype === 'Windows_NT') {
return 'win64';
} else {
return 'linux64';
}
}
/**
* Gets the latest item from the XML.
*/
getLatestChromeDriverVersion() {
const path = require('path')
const fs = require('fs')
const path = require('path');
const fs = require('fs');
const lastKnownGoodVersionsWithDownloads_Url = 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json';
return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then(body => {
const latestVersion_Body = JSON.parse(body)['channels']['Stable']
const lastKnownGoodVersionsWithDownloads_Url =
'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json';
return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then((body) => {
const latestVersion_Body = JSON.parse(body)['channels']['Stable'];
const latestVersion = latestVersion_Body['version']
const latestVersion_Url = latestVersion_Body['downloads']['chromedriver'].find(obj => obj['platform'] == 'mac-x64')['url']
const latestVersion = latestVersion_Body['version'];
const latestVersion_Url = latestVersion_Body['downloads']['chromedriver'].find((obj) => obj['platform'] == 'mac-x64')['url'];
const latestMajorVersion = latestVersion.split('.')[0]
const latestMajorVersion = latestVersion.split('.')[0];
const localVersion_FileName = fs.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
.find(f => f.startsWith(`chromedriver_${latestMajorVersion}`)) || ''
const localVersion_FileName =
fs
.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
.find((f) => f.startsWith(`chromedriver_${latestMajorVersion}`)) || '';
const localVersion = localVersion_FileName.slice(13, -4)
const localVersion_Url = latestVersion_Url.replace(latestVersion, localVersion)
const localVersion = localVersion_FileName.slice(13, -4);
const localVersion_Url = latestVersion_Url.replace(latestVersion, localVersion);
const localMajorVersion = localVersion.split('.')[0]
const localMajorVersion = localVersion.split('.')[0];
if (latestMajorVersion == localMajorVersion) {
return Promise.resolve({
url: localVersion_Url,
version: localVersion,
})
version: localVersion
});
} else {
return Promise.resolve({
url: latestVersion_Url,
version: latestVersion,
})
version: latestVersion
});
}
});
}
/**
* Gets a specific item from the XML.
*/
getSpecificChromeDriverVersion(inputVersion) {
return this.getVersionList().then(list => {
const specificVersion = getValidSemver(inputVersion);
if (specificVersion === '') {
throw new Error(`version ${inputVersion} ChromeDriver does not exist`);
}
let itemFound = '';
for (let item of list) {
// Get a semantic version.
let version = item.split('/')[0];
if (semver.valid(version) == null) {
const lookUpVersion = getValidSemver(version);
if (semver.valid(lookUpVersion)) {
// Check to see if the specified version matches.
if (lookUpVersion === specificVersion) {
// When item found is null, check the os arch
// 64-bit version works OR not 64-bit version and the path does not have '64'
if (itemFound == '') {
if (this.osarch === 'x64' ||
(this.osarch !== 'x64' && !item.includes(this.getOsTypeName() + '64'))) {
itemFound = item;
}
if (this.osarch === 'arm64' && this.ostype === 'Darwin' && item.includes('m1')) {
itemFound = item;
}
}
else if (this.osarch === 'x64') {
// No win64 version exists, so even on x64 we need to look for win32
const osTypeNameAndArch = this.getOsTypeName() + (this.getOsTypeName() === 'win' ? '32' : '64');
if (item.includes(osTypeNameAndArch)) {
itemFound = item;
}
}
}
}
}
}
if (itemFound == '') {
return { url: '', version: inputVersion };
}
else {
return { url: config_1.Config.cdnUrls().chrome + itemFound, version: inputVersion };
getSpecificChromeDriverVersion(versionRequired) {
const path = require('path');
const fs = require('fs');
let baseTagVersion = versionRequired.split('.');
baseTagVersion.splice(-1);
baseTagVersion = baseTagVersion.join('.');
const lastKnownGoodVersionsWithDownloads_Url =
'https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json';
return http_utils_1.requestBody(lastKnownGoodVersionsWithDownloads_Url).then((body) => {
const version_Body = JSON.parse(body)['builds'][baseTagVersion];
const opSys = this.getOsTypeName();
const currentVersion = version_Body['version'];
const currentVersion_Url = version_Body['downloads']['chromedriver'].find((obj) => obj['platform'] == opSys)['url'];
const latestMajorVersion = currentVersion.split('.')[0];
const localVersion_FileName =
fs
.readdirSync(path.resolve(__dirname, '..', '..', '..', 'selenium'))
.find((f) => f.startsWith(`chromedriver_${latestMajorVersion}`)) || '';
const localVersion = localVersion_FileName.slice(13, -4);
const localVersion_Url = currentVersion_Url.replace(currentVersion, localVersion);
const localMajorVersion = localVersion.split('.')[0];
if (latestMajorVersion == localMajorVersion) {
return Promise.resolve({
url: localVersion_Url,
version: localVersion
});
} else {
return Promise.resolve({
url: currentVersion_Url,
version: currentVersion
});
}
});
}
@@ -163,8 +162,7 @@ function getValidSemver(version) {
if (exec) {
lookUpVersion = exec[1] + '.0';
}
}
catch (_) {
} catch (_) {
// no-op: is this is not valid, do not throw here.
}
// This supports downloading 74.0.3729.6
@@ -174,8 +172,7 @@ function getValidSemver(version) {
if (exec) {
lookUpVersion = exec[1];
}
}
catch (_) {
} catch (_) {
// no-op: if this does not work, use the other regex pattern.
}
return lookUpVersion;