Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fine-grained selenium support also with user credentials #289

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions agora-gui/self_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@

---
- name: AgoraGui, Add Apt signing key for google-chrome
when: config.agora_gui.enable_self_testing
when: config.agora_gui.self_testing.enable
become: true
ansible.builtin.apt_key:
url: "https://dl.google.com/linux/linux_signing_key.pub"
state: present

- name: AgoraGui, Add google-chrome repository into sources list
when: config.agora_gui.enable_self_testing
when: config.agora_gui.self_testing.enable
become: true
ansible.builtin.apt_repository:
repo: deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
state: present
filename: google-chrome

- name: AgoraGui, Install google-chrome
when: config.agora_gui.self_testing.enable
become: true
ansible.builtin.apt:
name: google-chrome-stable
Expand All @@ -45,13 +46,20 @@
group: agoragui
mode: '0744'

- name: AgoraGui, set e2e tests baseUrl setting
- name: AgoraGui, set e2e tests settings
become: true
become_user: agoragui
replace:
dest: /home/agoragui/agora-gui-admin/test/e2e.conf.js
regexp: 'baseUrl:.*'
replace: 'baseUrl: "https://{{config.agora_gui.domain}}"'
regexp: '{{ item.regexp }}'
replace: '{{ item.replace }}'
with_items:
- regexp: 'defaultTimeoutInterval:.*'
replace: 'defaultTimeoutInterval: {{config.agora_gui.self_testing.defaultTimeoutInterval}},'
- regexp: 'getPageTimeout:.*'
replace: 'getPageTimeout: {{config.agora_gui.self_testing.getPageTimeout}},'
- regexp: 'allScriptsTimeout:.*'
replace: 'allScriptsTimeout: {{config.agora_gui.self_testing.allScriptsTimeout}},'

- name: AgoraGui, Creating selenium service
become: true
Expand All @@ -78,6 +86,7 @@
mode: '0700'

- name: AgoraGui, updating web-driver
when: config.agora_gui.self_testing.enable
become: true
become_user: agoragui
ansible.builtin.shell:
Expand Down
13 changes: 13 additions & 0 deletions agora-gui/templates/launch_selftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,17 @@
# along with agora-dev-box. If not, see <http://www.gnu.org/licenses/>.

cd /home/agoragui/agora-gui-admin
export PROTRACTOR_ARGS=$(cat <<-JSON_END
{
"baseUrl": "https://{{config.agora_gui.domain}}",
"params": {
"login": {{config.agora_gui.self_testing.admin_user_credentials}},
"timeout": {
"ECstandards": {{config.agora_gui.self_testing.allScriptsTimeout}},
"CreateElections": {{config.agora_gui.self_testing.createElectionsTimeout}}
}
}
}
JSON_END
)
grunt protractor
2 changes: 1 addition & 1 deletion agora-gui/templates/selenium.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[program:selenium]
command=/home/agoragui/selenium.sh
directory=/home/agoragui/
autostart={% if config.agora_gui.enable_self_testing %}true
autostart={% if config.agora_gui.self_testing.enable %}true
{% else %}false
{% endif %}
autorestart=true
Expand Down
2 changes: 1 addition & 1 deletion agora-gui/templates/selenium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

export DRIVER_PATH=/home/agoragui/agora-gui-admin/node_modules/webdriver-manager

${DRIVER_PATH}/bin/webdriver-manager update
${DRIVER_PATH}/bin/webdriver-manager update --ignore_ssl

${DRIVER_PATH}/bin/webdriver-manager \
start \
Expand Down
19 changes: 19 additions & 0 deletions authapi/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,25 @@
virtualenv: /home/authapi/env
settings: authapi.deploy

- name: Authapi, create e2e_test_user file
become: true
template:
src: authapi/templates/e2e_test_user.json
dest: /home/authapi/e2e_test_user.json
owner: authapi
group: authapi
mode: '0600'

- name: AuthApi, upsert e2e_test_user
become: true
become_user: authapi
django_manage:
command: upsert_users /home/authapi/e2e_test_user.json
args:
app_path: /home/authapi/authapi/authapi
virtualenv: /home/authapi/env
settings: authapi.deploy

- name: Authapi, allow authapi user to create databases (for example the test db)
become: true
become_user: postgres
Expand Down
3 changes: 3 additions & 0 deletions authapi/templates/e2e_test_user.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{{config.agora_gui.self_testing.admin_user_credentials}}
]
2 changes: 2 additions & 0 deletions authapi/templates/sudo-run-selftests
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{% if config.agora_gui.self_testing.enable %}
authapi ALL = (agoragui) NOPASSWD: /home/agoragui/launch_selftest.sh
authapi ALL = (root) NOPASSWD: /home/agoragui/kill_selftest.sh
{% endif %}
1 change: 0 additions & 1 deletion authapi/user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

- name: AuthApi, add sudoers file to be able to launch self-tests
become: true
when: config.agora_gui.enable_self_testing
template:
src: authapi/templates/sudo-run-selftests
dest: /etc/sudoers.d/sudo-run-selftests
Expand Down
55 changes: 49 additions & 6 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,55 @@ config:
booth_port: 10091
elections_port: 10092

# Boolean (default: true) that, if set to true, allows admins to launch
# a suite of automated end-to-end tests that follow the whole process of
# an election, including registering, creating the election keys, starting
# the election, voting, stopping, tallying, calculating and publishing the
# election results.
enable_self_testing: true
self_testing:
# Boolean (default: true) that, if set to true, allows admins to launch
# a suite of automated end-to-end tests that follow the whole process of
# an election, including registering, creating the election keys, starting
# the election, voting, stopping, tallying, calculating and publishing the
# election results.
enable: true

# credentials used for the admin user in the self tests. This user will be
# automatically created and managed by the ansible script. The format of
# this data is the same as the elements accepted by authapi's admin
# command `upsert_users`.
# More Info: https://github.com/agoravoting/authapi/blob/master/authapi/api/management/commands/upsert_users.py#L21
admin_user_credentials: |
{
"username": "e2e_test_admin",
"email": "[email protected]",
"password": "<PASSWORD>",
"is_active": true,
"is_admin": true,
"election_permissions": []
}

# Number (Miliseconds, default: 120,000) Default time to wait before a test
# fails.
# More Info: https://github.com/angular/protractor/blob/master/lib/config.ts#L629
defaultTimeoutInterval: 120000

# Number (Miliseconds, default: 15,000) How long to wait for a page to
# load.
# More Info: https://github.com/angular/protractor/blob/master/lib/config.ts#L446
getPageTimeout: 15000

# Number (Miliseconds, default: 10,000) The timeout in milliseconds for
# each script run on the browser. This should be longer than the maximum
# time your application needs to stabilize between tasks.
#
# Also used as the default timeout in protractor browser.wait calls.
#
# More Info:
# 1. https://github.com/angular/protractor/blob/master/lib/config.ts#L441
# 2. http://www.protractortest.org/#/api?view=webdriver.WebDriver.prototype.wait
allScriptsTimeout: 10000

# Timeout (Miliseconds, default: 120,000) for creating elections during
# the tests. Each election takes ~30 seconds/question to create with 2
# authorities. Sometimes test might include the creation of multiple
# elections with multiple questions, so change this accordingly.
createElectionsTimeout: 120000

# Main version shown in the user interface. set to 'false' if you don't
# want it to be shown.
Expand Down
50 changes: 50 additions & 0 deletions doc/devel/agora.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,56 @@ config:
booth_port: 10091
elections_port: 10092

self_testing:
# Boolean (default: true) that, if set to true, allows admins to launch
# a suite of automated end-to-end tests that follow the whole process of
# an election, including registering, creating the election keys, starting
# the election, voting, stopping, tallying, calculating and publishing the
# election results.
enable: true

# credentials used for the admin user in the self tests. This user will be
# automatically created and managed by the ansible script. The format of
# this data is the same as the elements accepted by authapi's admin
# command `upsert_users`.
# More Info: https://github.com/agoravoting/authapi/blob/master/authapi/api/management/commands/upsert_users.py#L21
admin_user_credentials: |
{
"username": "e2e_test_admin",
"email": "[email protected]",
"password": "<PASSWORD>",
"is_active": true,
"is_admin": true,
"election_permissions": []
}

# Number (Miliseconds, default: 120,000) Default time to wait before a test
# fails.
# More Info: https://github.com/angular/protractor/blob/master/lib/config.ts#L629
defaultTimeoutInterval: 120000

# Number (Miliseconds, default: 15,000) How long to wait for a page to
# load.
# More Info: https://github.com/angular/protractor/blob/master/lib/config.ts#L446
getPageTimeout: 15000

# Number (Miliseconds, default: 10,000) The timeout in milliseconds for
# each script run on the browser. This should be longer than the maximum
# time your application needs to stabilize between tasks.
#
# Also used as the default timeout in protractor browser.wait calls.
#
# More Info:
# 1. https://github.com/angular/protractor/blob/master/lib/config.ts#L441
# 2. http://www.protractortest.org/#/api?view=webdriver.WebDriver.prototype.wait
allScriptsTimeout: 10000

# Timeout (Miliseconds, default: 120,000) for creating elections during
# the tests. Each election takes ~30 seconds/question to create with 2
# authorities. Sometimes test might include the creation of multiple
# elections with multiple questions, so change this accordingly.
createElectionsTimeout: 120000

# Main version shown in the user interface. set to 'false' if you don't
# want it to be shown.
mainVersion: 'master'
Expand Down
50 changes: 50 additions & 0 deletions doc/devel/auth1.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,56 @@ config:
booth_port: 10091
elections_port: 10092

self_testing:
# Boolean (default: true) that, if set to true, allows admins to launch
# a suite of automated end-to-end tests that follow the whole process of
# an election, including registering, creating the election keys, starting
# the election, voting, stopping, tallying, calculating and publishing the
# election results.
enable: true

# credentials used for the admin user in the self tests. This user will be
# automatically created and managed by the ansible script. The format of
# this data is the same as the elements accepted by authapi's admin
# command `upsert_users`.
# More Info: https://github.com/agoravoting/authapi/blob/master/authapi/api/management/commands/upsert_users.py#L21
admin_user_credentials: |
{
"username": "e2e_test_admin",
"email": "[email protected]",
"password": "<PASSWORD>",
"is_active": true,
"is_admin": true,
"election_permissions": []
}

# Number (Miliseconds, default: 120,000) Default time to wait before a test
# fails.
# More Info: https://github.com/angular/protractor/blob/master/lib/config.ts#L629
defaultTimeoutInterval: 120000

# Number (Miliseconds, default: 15,000) How long to wait for a page to
# load.
# More Info: https://github.com/angular/protractor/blob/master/lib/config.ts#L446
getPageTimeout: 15000

# Number (Miliseconds, default: 10,000) The timeout in milliseconds for
# each script run on the browser. This should be longer than the maximum
# time your application needs to stabilize between tasks.
#
# Also used as the default timeout in protractor browser.wait calls.
#
# More Info:
# 1. https://github.com/angular/protractor/blob/master/lib/config.ts#L441
# 2. http://www.protractortest.org/#/api?view=webdriver.WebDriver.prototype.wait
allScriptsTimeout: 10000

# Timeout (Miliseconds, default: 120,000) for creating elections during
# the tests. Each election takes ~30 seconds/question to create with 2
# authorities. Sometimes test might include the creation of multiple
# elections with multiple questions, so change this accordingly.
createElectionsTimeout: 120000

# Main version shown in the user interface. set to 'false' if you don't
# want it to be shown.
mainVersion: 'master'
Expand Down
55 changes: 49 additions & 6 deletions doc/devel/auth2.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -496,12 +496,55 @@ config:
booth_port: 10091
elections_port: 10092

# Boolean (default: true) that, if set to true, allows admins to launch
# a suite of automated end-to-end tests that follow the whole process of
# an election, including registering, creating the election keys, starting
# the election, voting, stopping, tallying, calculating and publishing the
# election results.
enable_self_testing: true
self_testing:
# Boolean (default: true) that, if set to true, allows admins to launch
# a suite of automated end-to-end tests that follow the whole process of
# an election, including registering, creating the election keys, starting
# the election, voting, stopping, tallying, calculating and publishing the
# election results.
enable: true

# credentials used for the admin user in the self tests. This user will be
# automatically created and managed by the ansible script. The format of
# this data is the same as the elements accepted by authapi's admin
# command `upsert_users`.
# More Info: https://github.com/agoravoting/authapi/blob/master/authapi/api/management/commands/upsert_users.py#L21
admin_user_credentials: |
{
"username": "e2e_test_admin",
"email": "[email protected]",
"password": "<PASSWORD>",
"is_active": true,
"is_admin": true,
"election_permissions": []
}

# Number (Miliseconds, default: 120,000) Default time to wait before a test
# fails.
# More Info: https://github.com/angular/protractor/blob/master/lib/config.ts#L629
defaultTimeoutInterval: 120000

# Number (Miliseconds, default: 15,000) How long to wait for a page to
# load.
# More Info: https://github.com/angular/protractor/blob/master/lib/config.ts#L446
getPageTimeout: 15000

# Number (Miliseconds, default: 10,000) The timeout in milliseconds for
# each script run on the browser. This should be longer than the maximum
# time your application needs to stabilize between tasks.
#
# Also used as the default timeout in protractor browser.wait calls.
#
# More Info:
# 1. https://github.com/angular/protractor/blob/master/lib/config.ts#L441
# 2. http://www.protractortest.org/#/api?view=webdriver.WebDriver.prototype.wait
allScriptsTimeout: 10000

# Timeout (Miliseconds, default: 120,000) for creating elections during
# the tests. Each election takes ~30 seconds/question to create with 2
# authorities. Sometimes test might include the creation of multiple
# elections with multiple questions, so change this accordingly.
createElectionsTimeout: 120000

# Main version shown in the user interface. set to 'false' if you don't
# want it to be shown.
Expand Down
Loading