Skip to content

Commit a129591

Browse files
authored
E2e/feature/ri 5707 add sso support for linux (#4075)
* RI-5707_add-sso-support-for-linux * add installing xdotool * fixes for linux * test run * add installing chrome to config.yml * run only desktop tests * update for .sh * add desktop file utils * fix * add install xvfb * fixes * change getOpenedChromeTab * fix * delete logs file after test run * e2e/bugfix/fix-tsconfig * change method to get chrome tab url * fix for deps * add more logs * make chrome as default browser * change port for cdp * change port for CDP * fix for local deeplink and new log * add configs for chrome * modifications * add chrome arguments * return back opening tab * check if chrome is visible * change config * add timeout * add logs * add timeout before pgrep chrome * change ordering * check * increase timeout * remove duplicated method to open chrome * change exec * change for execSync * change rte * return back rte * add timeout * increase timeout * increase open chrome tab url timeout * add runExecutionTimeout * add testExecutionTimeout * add attempts++ after new tab found * change sync methods to async * change getOpenedChromeTab * change chrome tags * remove waiters * fix * fix for writefile * add log * add waiter * add screenshot for selenium * change path * change screenshots path * add condition to click google btn * try playwright for google auth * dep fix * deps fix 2 * add playwright install * change command * add puppeteer stealth * add puppeteer * improvements for stealth plugin * check puppeteer real browser * add screenshots for pass * add waiter before password * remove csp * check with proxy * change turnstile * add scrapeops proxy * add args for chrome * check without args * add chrome data dir * fix for tar export * fix for path * fix path * update user data dir path * update data dir * fix path for userDataDir * save chrome data dir to artifacts * save data after tests * comment download chrome profile * fix active save google data step * return back using user data dir * add timeout * add userdatadir to chrome * sign in with github * check saml * fixes for sso saml flow * fix for user name * updates for structure * add submitGithubForm() * remove playwright * return back long string * check with reopening chrome * add timeout for waiter * add wait to test * fixes * move get platform() * change waiters * add more attempts * run chrome in background * change timeout * change retries * check with closed chrome * check with closing chrome * increase timeout * add small timeout * updates for syntax * check without user data dir * unskip test * remote some waiters * return back all tests * add changes for github actions * remove display:99
1 parent 6f72a42 commit a129591

25 files changed

+1018
-226
lines changed

.circleci/config.yml.backup

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,15 +396,36 @@ jobs:
396396
- attach_workspace:
397397
at: .
398398
- run: sudo apt-get install net-tools
399+
- run: sudo apt-get install xdotool
400+
- run: sudo apt-get install -y desktop-file-utils
401+
- run:
402+
name: Install Google Chrome
403+
command: |
404+
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
405+
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
406+
sudo apt-get update
407+
sudo apt-get install -y google-chrome-stable
408+
sudo apt-get install -y \
409+
libnss3 \
410+
libgconf-2-4 \
411+
libxss1 \
412+
libasound2
413+
xdg-settings set default-web-browser google-chrome.desktop
399414
- run:
400415
name: Install WM
401416
command: sudo apt install fluxbox
402417
- run:
403-
name: Run X11
418+
name: Install Xvfb
419+
command: sudo apt-get install -y xvfb
420+
- run:
421+
name: Start Xvfb
404422
command: |
405-
Xvfb :99 -screen 0 1920x1080x24 &
423+
if [ -f /tmp/.X99-lock ]; then rm /tmp/.X99-lock; fi
424+
Xvfb :99 -ac -screen 0 1920x1080x24 &
406425
sleep 3
407426
fluxbox &
427+
export DISPLAY=:99
428+
echo $DISPLAY
408429
# - run:
409430
# name: Clone mocked RDI server
410431
# command: |

.circleci/e2e/test.app-image.sh

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,52 @@ set -e
33

44
yarn --cwd tests/e2e install
55

6-
# mount app resources
7-
./release/*.AppImage --appimage-mount >> apppath &
6+
# Create the ri-test directory if it doesn't exist
7+
mkdir -p ri-test
8+
9+
# Extract the AppImage
10+
chmod +x ./release/*.AppImage
11+
./release/*.AppImage --appimage-extract
12+
13+
# Move contents of squashfs-root to ri-test and remove squashfs-root folder
14+
mv squashfs-root/* ri-test/
15+
rm -rf squashfs-root
16+
17+
# Export custom XDG_DATA_DIRS with ri-test
18+
export XDG_DATA_DIRS="$(pwd)/ri-test:$XDG_DATA_DIRS"
819

920
# create folder before tests run to prevent permissions issue
1021
mkdir -p tests/e2e/remote
1122
mkdir -p tests/e2e/rdi
1223

13-
# run rte
24+
# Create a custom .desktop file for RedisInsight
25+
cat > ri-test/redisinsight.desktop <<EOL
26+
[Desktop Entry]
27+
Version=1.0
28+
Name=RedisInsight
29+
Exec=$(pwd)/ri-test/redisinsight %u
30+
Icon=$(pwd)/ri-test/resources/app.asar/img/icon.png
31+
Type=Application
32+
Terminal=false
33+
MimeType=x-scheme-handler/redisinsight;
34+
EOL
35+
36+
# Copy the .desktop file to the local applications directory
37+
cp ri-test/redisinsight.desktop "$HOME/.local/share/applications"
38+
39+
# Update the desktop database with custom directory
40+
update-desktop-database "$(pwd)/ri-test/"
41+
42+
# Register the RedisInsight deeplink protocol
43+
xdg-mime default redisinsight.desktop x-scheme-handler/redisinsight
44+
45+
# Run rte
1446
docker-compose -f tests/e2e/rte.docker-compose.yml build
1547
docker-compose -f tests/e2e/rte.docker-compose.yml up --force-recreate -d -V
1648
./tests/e2e/wait-for-redis.sh localhost 12000 && \
1749

18-
# run tests
19-
COMMON_URL=$(tail -n 1 apppath)/resources/app.asar/dist/renderer/index.html \
20-
ELECTRON_PATH=$(tail -n 1 apppath)/redisinsight \
50+
# Run tests
51+
COMMON_URL=$(pwd)/ri-test/resources/app.asar/dist/renderer/index.html \
52+
ELECTRON_PATH=$(pwd)/ri-test/redisinsight \
2153
RI_SOCKETS_CORS=true \
2254
yarn --cwd tests/e2e dotenv -e .desktop.env yarn --cwd tests/e2e test:desktop:ci

.github/e2e/test.app-image.sh

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,52 @@ set -e
33

44
yarn --cwd tests/e2e install
55

6-
# mount app resources
6+
# Create the ri-test directory if it doesn't exist
7+
mkdir -p ri-test
8+
9+
# Extract the AppImage
710
chmod +x ./release/*.AppImage
8-
./release/*.AppImage --appimage-mount >> apppath &
11+
./release/*.AppImage --appimage-extract
12+
13+
# Move contents of squashfs-root to ri-test and remove squashfs-root folder
14+
mv squashfs-root/* ri-test/
15+
rm -rf squashfs-root
16+
17+
# Export custom XDG_DATA_DIRS with ri-test
18+
export XDG_DATA_DIRS="$(pwd)/ri-test:$XDG_DATA_DIRS"
919

1020
# create folder before tests run to prevent permissions issue
1121
mkdir -p tests/e2e/remote
1222
mkdir -p tests/e2e/rdi
1323

14-
# run rte
15-
docker compose -f tests/e2e/rte.docker-compose.yml build
16-
docker compose -f tests/e2e/rte.docker-compose.yml up --force-recreate -d -V
24+
# Create a custom .desktop file for RedisInsight
25+
cat > ri-test/redisinsight.desktop <<EOL
26+
[Desktop Entry]
27+
Version=1.0
28+
Name=RedisInsight
29+
Exec=$(pwd)/ri-test/redisinsight %u
30+
Icon=$(pwd)/ri-test/resources/app.asar/img/icon.png
31+
Type=Application
32+
Terminal=false
33+
MimeType=x-scheme-handler/redisinsight;
34+
EOL
35+
36+
# Copy the .desktop file to the local applications directory
37+
cp ri-test/redisinsight.desktop "$HOME/.local/share/applications"
38+
39+
# Update the desktop database with custom directory
40+
update-desktop-database "$(pwd)/ri-test/"
41+
42+
# Register the RedisInsight deeplink protocol
43+
xdg-mime default redisinsight.desktop x-scheme-handler/redisinsight
44+
45+
# Run rte
46+
docker-compose -f tests/e2e/rte.docker-compose.yml build
47+
docker-compose -f tests/e2e/rte.docker-compose.yml up --force-recreate -d -V
1748
./tests/e2e/wait-for-redis.sh localhost 12000 && \
1849

19-
# run tests
20-
COMMON_URL=$(tail -n 1 apppath)/resources/app.asar/dist/renderer/index.html \
21-
ELECTRON_PATH=$(tail -n 1 apppath)/redisinsight \
50+
# Run tests
51+
COMMON_URL=$(pwd)/ri-test/resources/app.asar/dist/renderer/index.html \
52+
ELECTRON_PATH=$(pwd)/ri-test/redisinsight \
2253
RI_SOCKETS_CORS=true \
2354
yarn --cwd tests/e2e dotenv -e .desktop.env yarn --cwd tests/e2e test:desktop:ci

.github/workflows/tests-e2e-appimage.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,29 @@ jobs:
4949
with:
5050
detached: true
5151

52-
- name: Install WM
52+
- name: Install necessary packages
5353
run: |
5454
sudo apt-get update -y
55-
sudo apt-get install kmod libfuse2 xvfb net-tools fluxbox netcat -y
55+
sudo apt-get install kmod libfuse2 xvfb net-tools xdotool desktop-file-utils fluxbox netcat -y
56+
57+
- name: Install Google Chrome
58+
run: |
59+
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
60+
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
61+
sudo apt-get update
62+
sudo apt-get install -y google-chrome-stable libnss3 libgconf-2-4 libxss1 libasound2
63+
xdg-settings set default-web-browser google-chrome.desktop
5664
5765
- name: Download AppImage Artifacts
5866
uses: actions/download-artifact@v4
5967
with:
6068
name: linux-builds
6169
path: ./release
6270

63-
- name: Run X11
71+
- name: Start Xvfb
6472
run: |
65-
Xvfb :99 -screen 0 1920x1080x24 &
73+
if [ -f /tmp/.X99-lock ]; then rm /tmp/.X99-lock; fi
74+
Xvfb :99 -ac -screen 0 1920x1080x24 &
6675
sleep 3
6776
fluxbox &
6877

tests/e2e/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ remote
99
rihomedir
1010
rdi
1111
rte/rdi
12+
chrome_logs.txt

tests/e2e/desktop.runner.ci.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ import testcafe from 'testcafe';
3434
])
3535
.run({
3636
skipJsErrors: true,
37-
browserInitTimeout: 60000,
38-
selectorTimeout: 5000,
39-
assertionTimeout: 5000,
37+
browserInitTimeout: 120000,
38+
selectorTimeout: 10000,
39+
assertionTimeout: 10000,
4040
speed: 1,
4141
quarantineMode: { successThreshold: 1, attemptLimit: 3 },
42-
pageRequestTimeout: 8000,
43-
disableMultipleWindows: true
42+
pageRequestTimeout: 20000,
43+
disableMultipleWindows: true,
44+
runExecutionTimeout: 280000,
45+
testExecutionTimeout: 280000
4446
});
4547
})
4648
.then((failedCount) => {

tests/e2e/helpers/common.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const chance = new Chance();
99

1010
declare global {
1111
interface Window {
12-
windowId?: string
12+
windowId?: string
1313
}
14-
}
14+
}
1515

1616
const settingsApiUrl = `${apiUrl}/settings`;
1717
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // lgtm[js/disabling-certificate-validation]
@@ -180,17 +180,17 @@ export class Common {
180180
* @param expectedUrl Expected link that is compared with actual
181181
*/
182182
static async checkURL(expectedUrl: string): Promise<void> {
183-
const getPageUrl = ClientFunction(() => window.location.href);
184-
await t.expect(getPageUrl()).eql(expectedUrl, 'Opened URL is not correct');
183+
const getPageUrl = await this.getPageUrl();
184+
await t.expect(getPageUrl).eql(expectedUrl, 'Opened URL is not correct');
185185
}
186186

187187
/**
188188
* Check opened URL contains text
189189
* @param expectedText Expected link that is compared with actual
190190
*/
191191
static async checkURLContainsText(expectedText: string): Promise<void> {
192-
const getPageUrl = ClientFunction(() => window.location.href);
193-
await t.expect(getPageUrl()).contains(expectedText, `Opened URL not contains text ${expectedText}`);
192+
const getPageUrl = await this.getPageUrl();
193+
await t.expect(getPageUrl).contains(expectedText, `Opened URL not contains text ${expectedText}`);
194194
}
195195

196196
/**
@@ -207,7 +207,7 @@ export class Common {
207207
* Get current page url
208208
*/
209209
static async getPageUrl(): Promise<string> {
210-
return (await ClientFunction(() => window.location.href))();
210+
return (ClientFunction(() => window.location.href))();
211211
}
212212

213213
/**
@@ -247,19 +247,37 @@ export class Common {
247247

248248
/**
249249
* Delete file from folder
250-
* @param folderPath Path to file
250+
* @param filePath Path to file
251251
*/
252252
static async deleteFileFromFolder(filePath: string): Promise<void> {
253253
fs.unlinkSync(path.join(__dirname, filePath));
254254
}
255255

256256
/**
257257
* Delete file from folder if exists
258-
* @param folderPath Path to file
258+
* @param filePath Path to file
259259
*/
260260
static async deleteFileFromFolderIfExists(filePath: string): Promise<void> {
261261
if (fs.existsSync(filePath)) {
262262
fs.unlinkSync(filePath);
263263
}
264264
}
265+
266+
/**
267+
* Read file from folder
268+
* @param filePath Path to file
269+
*/
270+
static async readFileFromFolder(filePath: string): Promise<string> {
271+
return fs.readFileSync(filePath, 'utf8');
272+
}
273+
274+
/**
275+
* Get current machine platform
276+
*/
277+
static getPlatform(): { isMac: boolean, isLinux: boolean } {
278+
return {
279+
isMac: process.platform === 'darwin',
280+
isLinux: process.platform === 'linux'
281+
};
282+
}
265283
}

tests/e2e/helpers/conf.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const commonUrl = process.env.COMMON_URL || 'https://localhost:5540';
99
export const apiUrl = process.env.API_URL || 'https://localhost:5540/api';
1010
export const googleUser = process.env.GOOGLE_USER || '';
1111
export const googleUserPassword = process.env.GOOGLE_USER_PASSWORD || '';
12+
export const samlUser = process.env.E2E_SSO_EMAIL || '';
13+
export const samlUserPassword = process.env.E2E_SSO_PASSWORD || '';
1214

1315
export const workingDirectory = process.env.RI_APP_FOLDER_ABSOLUTE_PATH
1416
|| (joinPath(os.homedir(), process.env.RI_APP_FOLDER_NAME || '.redis-insight'));

tests/e2e/helpers/google-authorization.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

tests/e2e/helpers/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { DatabaseScripts, DbTableParameters } from './database-scripts';
22
import { Common } from './common';
33
import { DatabaseHelper } from './database';
4+
import { SsoAuthorization } from './sso-authorization';
45
import { Telemetry } from './telemetry';
56

67
export {
78
DatabaseScripts,
89
DbTableParameters,
910
Common,
1011
DatabaseHelper,
12+
SsoAuthorization,
1113
Telemetry
1214
};

0 commit comments

Comments
 (0)