Skip to content

Commit

Permalink
e2e: Added auth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed Aug 1, 2024
1 parent fde7088 commit 2c3bcba
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 122 deletions.
126 changes: 88 additions & 38 deletions .github/workflows/openvidu-call-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,50 @@ jobs:
path: ${{ github.workspace }}/**.tgz
if-no-files-found: error

# authentication_e2e_test:
# needs: prepare_openvidu_angular
# name: Authentication E2E tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: '20'
# - uses: actions/download-artifact@v4
# with:
# name: artifacts
# # - name: Run Selenium Chromedriver
# # run: docker run -d --shm-size="4g" --network host selenium/standalone-chrome:106.0
# - name: Run Browserless Chrome
# run: docker run -d -p 3000:3000 --network host browserless/chrome:1.53-chrome-stable
# - name: Run openvidu-server-kms
# run: |
# docker run -p 4443:4443 --rm -d \
# -e OPENVIDU_SECRET=MY_SECRET \
# openvidu/openvidu-dev:latest
# - name: Install openvidu-angular and dependencies
# run: |
# ls -al && \
# npm install openvidu-angular-*.tgz --prefix openvidu-call-front && \
# npm install openvidu-browser*.tgz --prefix openvidu-call-front && \
# npm install openvidu-node-client-*.tgz --prefix openvidu-call-back
# - name: Build openvidu-call
# run: |
# npm run build --prefix openvidu-call-back && \
# npm run prod:build --prefix openvidu-call-front
# - name: Serve openvidu-call
# env:
# LAUNCH_MODE: CI
# CALL_OPENVIDU_CERTTYPE: selfsigned
# run: node openvidu-call-back/dist/app.js &
# - name: Run openvidu-call AUTH e2e
# run: npm run e2e:auth-ci --prefix openvidu-call-front
auth_e2e_test:
needs: prepare_openvidu_components_angular
name: Atuhentication tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/download-artifact@v4
with:
name: artifacts
# - name: Run Browserless Chrome
# run: docker run -d -p 3000:3000 --network host browserless/chrome:1.53-chrome-stable
- name: Run Chrome
run: docker run --network=host -d -p 4444:4444 selenium/standalone-chrome:127.0
- name: Run openvidu-local-deployment
run: |
git clone --depth 1 https://github.com/OpenVidu/openvidu-local-deployment
cd openvidu-local-deployment/community
./configure_lan_private_ip_linux.sh
docker compose up -d
- name: Install dependencies and build openvidu-call
run: |
npm install openvidu-components-angular-*.tgz --prefix openvidu-call-front && \
npm install --prefix openvidu-call-back && \
npm run build --prefix openvidu-call-back && \
npm run prod:build --prefix openvidu-call-front
- name: Wait for openvidu-local-deployment
run: |
until curl -s -f -o /dev/null http://localhost:7880; do
echo "Waiting for openvidu-local-deployment to be ready..."
sleep 5
done
- name: Serve openvidu-call
run: node openvidu-call-back/dist/server.js &
- name: Run tests
env:
LAUNCH_MODE: CI
CALL_PRIVATE_ACCESS: true

run: npm run e2e:auth --prefix openvidu-call-front

home_e2e_test:
needs: prepare_openvidu_components_angular
Expand Down Expand Up @@ -169,3 +175,47 @@ jobs:
LAUNCH_MODE: CI
CALL_PRIVATE_ACCESS: false
run: npm run e2e:room --prefix openvidu-call-front

recording_e2e_test:
needs: prepare_openvidu_components_angular
name: Recording tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/download-artifact@v4
with:
name: artifacts
# - name: Run Browserless Chrome
# run: docker run -d -p 3000:3000 --network host browserless/chrome:1.53-chrome-stable
- name: Run Chrome
run: docker run --network=host -d -p 4444:4444 selenium/standalone-chrome:127.0
- name: Run openvidu-local-deployment
run: |
git clone --depth 1 https://github.com/OpenVidu/openvidu-local-deployment
cd openvidu-local-deployment/community
./configure_lan_private_ip_linux.sh
docker compose up -d
- name: Install dependencies and build openvidu-call
run: |
npm install openvidu-components-angular-*.tgz --prefix openvidu-call-front && \
npm install --prefix openvidu-call-back && \
npm run build --prefix openvidu-call-back && \
npm run prod:build --prefix openvidu-call-front
- name: Wait for openvidu-local-deployment
run: |
until curl -s -f -o /dev/null http://localhost:7880; do
echo "Waiting for openvidu-local-deployment to be ready..."
sleep 5
done
- name: Serve openvidu-call
run: node openvidu-call-back/dist/server.js &
- name: Run tests
env:
LAUNCH_MODE: CI
CALL_PRIVATE_ACCESS: false
run: npm run e2e:recording --prefix openvidu-call-front
106 changes: 22 additions & 84 deletions openvidu-call-front/e2e/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,61 +28,39 @@ describe('Testing AUTHENTICATION', () => {
await browser.quit();
});

it('should show the LOGIN FORM with DISABELD button', async () => {
it('should show the login form with join button disabled', async () => {
await browser.get(url);

let element: WebElement = await utils.waitForElement('#slogan-text');
expect(await element.getText()).to.be.equal('Videoconference rooms in one click');

await utils.waitForElement('#form-login');

expect(await utils.isPresent('#form-session')).to.be.false;

await utils.waitForElement('#login-username');

await utils.waitForElement('#login-password');
await utils.checkLoginFormIsPresent();

element = await utils.waitForElement('#join-btn');
expect(await element.isEnabled()).to.be.false;
});

it('should show an error when LOGIN with WRONG CREDENTIALS', async () => {
it('should show an error when login with WRONG CREDENTIALS', async () => {
await browser.get(url);

let element: WebElement = await utils.waitForElement('#slogan-text');
expect(await element.getText()).to.be.equal('Videoconference rooms in one click');

await utils.waitForElement('#form-login');

element = await utils.waitForElement('#login-username input');
await element.sendKeys('user');

element = await utils.waitForElement('#login-password input');
await element.sendKeys('user');

await utils.clickOn('#join-btn');
await utils.login('user-fail', 'user-fail');

element = await utils.waitForElement('#login-error');
expect(await element.getText()).to.be.equal('Authentication failed. Try again.');
});

it('should show the SESSION NAME form when LOGIN with VALID CREDENTIALS', async () => {
it('should show be able to login', async () => {
await browser.get(url);

let element: WebElement = await utils.waitForElement('#slogan-text');
const element: WebElement = await utils.waitForElement('#slogan-text');
expect(await element.getText()).to.be.equal('Videoconference rooms in one click');

await utils.waitForElement('#form-login');
await utils.login('user', 'user');

element = await utils.waitForElement('#login-username input');
await element.sendKeys('admin');

element = await utils.waitForElement('#login-password input');
await element.sendKeys('MY_SECRET');

await utils.clickOn('#join-btn');

await utils.waitForElement('#form-session');
await utils.waitForElement('#form-room');

expect(await utils.isPresent('prejoin-container')).to.be.false;

Expand All @@ -94,33 +72,17 @@ describe('Testing AUTHENTICATION', () => {
await browser.get(url);

await utils.waitForElement('#slogan-text');
await utils.waitForElement('#form-login');

let element = await utils.waitForElement('#login-username input');
await element.sendKeys('admin');

element = await utils.waitForElement('#login-password input');
await element.sendKeys('MY_SECRET');
await utils.login('user', 'user');

await utils.clickOn('#join-btn');

await utils.waitForElement('#form-session');
await utils.waitForElement('#form-room');

element = await utils.waitForElement('#logout-content span');
expect(await element.getText()).equal('Hi admin, do you want to logout?');
const element = await utils.waitForElement('#logout-content span');
expect(await element.getText()).equal('Hi user, do you want to logout?');

await utils.clickOn('#logout-btn');

await utils.waitForElement('#form-login');

element = await utils.waitForElement('#login-username input');
expect(await element.getAttribute('value')).equal('admin');

element = await utils.waitForElement('#login-password input');
expect(await element.getAttribute('value')).equal('MY_SECRET');

element = await utils.waitForElement('#join-btn');
expect(await element.isEnabled()).to.be.true;
await utils.checkLoginFormIsPresent();

expect(await utils.isPresent('#logout-btn')).to.be.false;

Expand All @@ -131,21 +93,15 @@ describe('Testing AUTHENTICATION', () => {
expect(await utils.isPresent('#logout-btn')).to.be.false;
});

it('should be able to JOIN with a VALID CREDENTIALS AND SESSION', async () => {
it('should be able to do login and join room', async () => {
await browser.get(url);

await utils.waitForElement('#slogan-text');
await utils.waitForElement('#form-login');

let element = await utils.waitForElement('#login-username input');
await element.sendKeys('admin');

element = await utils.waitForElement('#login-password input');
await element.sendKeys('MY_SECRET');

await utils.clickOn('#join-btn');
await utils.login('user', 'user');

await utils.waitForElement('#form-session');
await utils.waitForElement('#form-room');

expect(await utils.isPresent('#prejoin-container')).to.be.false;

Expand All @@ -154,49 +110,31 @@ describe('Testing AUTHENTICATION', () => {
await utils.checkPrejoinIsPresent();
});

it('should REDIRECT to the ROOT PATH with SAME SESSION NAME', async () => {
it('should redirect to login page if try to force the url without be logged', async () => {
await browser.get(`${url}testSession`);

await utils.waitForElement('#slogan-text');

await utils.waitForElement('#form-login');

expect(await utils.isPresent('#form-session')).to.be.false;
expect(await utils.isPresent('#form-room')).to.be.false;

await utils.waitForElement('#login-username');

await utils.waitForElement('#login-password');

let element = await utils.waitForElement('#join-btn');
const element = await utils.waitForElement('#join-btn');
expect(await element.isEnabled()).to.be.false;

element = await utils.waitForElement('#login-username input');
await element.sendKeys('admin');

element = await utils.waitForElement('#login-password input');
await element.sendKeys('MY_SECRET');

await utils.clickOn('#join-btn');

element = await utils.waitForElement('#form-session input');
expect(await element.getAttribute('value')).equal('testSession');
});

it('should ENTER to the PREJOIN PAGE refreshing AFTER LOGIN', async () => {
it('should show the prejoin page when reloading the page', async () => {
await browser.get(`${url}`);

await utils.waitForElement('#slogan-text');
await utils.waitForElement('#form-login');

let element = await utils.waitForElement('#login-username input');
await element.sendKeys('admin');

element = await utils.waitForElement('#login-password input');
await element.sendKeys('MY_SECRET');

await utils.clickOn('#join-btn');

await utils.waitForElement('#form-session');
await utils.login('user', 'user');
await utils.waitForElement('#form-room');

expect(await utils.isPresent('#prejoin-container')).to.be.false;

Expand Down
22 changes: 22 additions & 0 deletions openvidu-call-front/e2e/utils.po.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,28 @@ export class OpenViduCallPO {
await this.browser.sleep(1000);
}

async checkLoginFormIsPresent(): Promise<void> {
await this.waitForElement('#form-login');

expect(await this.isPresent('#form-room')).to.be.false;

await this.waitForElement('#login-username');

await this.waitForElement('#login-password');
}

async login(username: string, password: string): Promise<void> {
await this.waitForElement('#form-login');

let element = await this.waitForElement('#login-username input');
await element.sendKeys(username);

element = await this.waitForElement('#login-password input');
await element.sendKeys(password);

await this.clickOn('#join-btn');
}

async joinSession(): Promise<void> {
await this.waitForElement('#join-button');
await this.clickOn('#join-button');
Expand Down

0 comments on commit 2c3bcba

Please sign in to comment.