This Selenium tests is to test authentication of a patron to the OPAC and intranet. It follows a similar workflow to the basic_workflow.t text by initially creating a patron category and patron user. Then the superlibrarian user used to create these logs out and the created patron logs into the staff intranet and OPAC
Created attachment 66502 [details] [review] Selenium test for logging into the Koha intranet and OPAC This selenium test goes through the process of creating a category and patron user (as is completed in the basic_workflow.t test) then the superlibrarian used to create them is logged out and the newly created patron user authenticates into the OPAC and staff intranet therefore testing the authenitcation of both. Test plan (this test plan includes how to install Selenium as well as how to run this test, for the benefit of people who have not got Selenium installed on their machines): 1. wget https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar 2. vim /etc/apt/sources.list.d/firefox.list 3. Paste into the file: deb http://packages.linuxmint.com debian import 4. sudo apt-get update 5. sudo apt-get install firefox 6. sudo apt-get install xvfb 7. Set the SELENIUM_PATH vartiable: SELENIUM_PATH=/home/vagrant/kohaclone/selenium-server-standalone-2.53.0.jar 8. Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null & 9. DISPLAY=:1 java -jar $SELENIUM_PATH Note: This will start up the selenium server. Everytime you want to shut down this terminal window and want to restart Selenium just run the step 9 command to restart the Selenium server 10. Open a new terminal window and write in: git clone https://github.com/gempesaw/Selenium-Remote-Driver --branch build/master --single-branch --depth 1 11. cd Selenium-Remote-Driver 12. perl Makefile.PL 13. make 14. make test 15. sudo make install 16. Now everything is installed and you can et up for running the selenium tests 17. Create a superlibrarian user with the username koha and password koha 18. If your usual port configuration for the intranet and OPAC is 8081 and 8080 respectively then set the staffClientBaseURL and OPACBaseURL system preferences to localhost:8080 and localhost:80 respectively 19. sudo koha-shell <instancename> 20. perl t/db_dependent/selenium/authenticate.t 21. The test should pass. Note: The time_diff comments in the test output showing what the test is doing Note: If you have issues with installing Selenium and Selenium::Remote::Driver please write a comment on the bug report and I will be more than happy to create a screencapture video showing all the steps Sponsored-By: Catalyst IT
This patch was originally attached to 18974 however I have placed it in its own bug report to make testing more straightforward
Created attachment 66505 [details] [review] Bug 19181 - Selenium test for logging into the Koha intranet and OPAC This selenium test goes through the process of creating a category and patron user (as is completed in the basic_workflow.t test) then the superlibrarian used to create them is logged out and the newly created patron user authenticates into the OPAC and staff intranet therefore testing the authenitcation of both. Test plan (this test plan includes how to install Selenium as well as how to run this test, for the benefit of people who have not got Selenium installed on their machines): 1. wget https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar 2. vim /etc/apt/sources.list.d/firefox.list 3. Paste into the file: deb http://packages.linuxmint.com debian import 4. sudo apt-get update 5. sudo apt-get install firefox 6. sudo apt-get install xvfb 7. Set the SELENIUM_PATH vartiable: SELENIUM_PATH=/home/vagrant/kohaclone/selenium-server-standalone-2.53.0.jar 8. Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null & 9. DISPLAY=:1 java -jar $SELENIUM_PATH Note: This will start up the selenium server. Everytime you want to shut down this terminal window and want to restart Selenium just run the step 9 command to restart the Selenium server 10. Open a new terminal window and write in: git clone https://github.com/gempesaw/Selenium-Remote-Driver --branch build/master --single-branch --depth 1 11. cd Selenium-Remote-Driver 12. perl Makefile.PL 13. make 14. make test 15. sudo make install 16. Now everything is installed and you can et up for running the selenium tests 17. Create a superlibrarian user with the username koha and password koha 18. If your usual port configuration for the intranet and OPAC is 8081 and 8080 respectively then set the staffClientBaseURL and OPACBaseURL system preferences to localhost:8080 and localhost:80 respectively 19. sudo koha-shell <instancename> 20. perl t/db_dependent/selenium/authenticate.t 21. The test should pass. Note: The time_diff comments in the test output showing what the test is doing Note: If you have issues with installing Selenium and Selenium::Remote::Driver please write a comment on the bug report and I will be more than happy to create a screencapture video showing all the steps Sponsored-By: Catalyst IT
This should be tweaked according to https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19337#c1
Comment on attachment 66505 [details] [review] Bug 19181 - Selenium test for logging into the Koha intranet and OPAC Review of attachment 66505 [details] [review]: ----------------------------------------------------------------- See the description of ENV variables to be used here: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19337#c1 ::: t/db_dependent/selenium/authenticate.t @@ +32,5 @@ > +use MARC::Field; > + > +my $dbh = C4::Context->dbh; > +my $login = 'koha'; > +my $password = 'koha'; This (user/password) does not use the possible ENV code that other tests use. @@ +33,5 @@ > + > +my $dbh = C4::Context->dbh; > +my $login = 'koha'; > +my $password = 'koha'; > +my $base_url= 'http://'.C4::Context->preference("staffClientBaseURL")."/cgi-bin/koha/"; protocol is now part of staff URL. @@ +34,5 @@ > +my $dbh = C4::Context->dbh; > +my $login = 'koha'; > +my $password = 'koha'; > +my $base_url= 'http://'.C4::Context->preference("staffClientBaseURL")."/cgi-bin/koha/"; > +my $opac_url= C4::Context->preference("OPACBaseURL"); KOHA_INTRANET_URL and KOHA_OPAC_URL env logic should be used here too.
t/db_dependent/selenium/authenticate.t .. 2/9 # Failed test at t/db_dependent/selenium/authenticate.t line 83. Wide character in print at /usr/local/share/perl/5.20.2/Test2/Formatter/TAP.pm line 113. # 'Koha › Log in to Koha' # doesn't match '(?^u:Patron categories)' 23:10:33.991 INFO - Executing: [find element: By.xpath: //a[@id="newcategory"]]) 23:10:34.114 WARN - Exception thrown org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector ":"//a[@id=\"newcategory\"]"} Command duration or timeout: 10 milliseconds Yes, this is a yucky mix of outputs. But sorry, I'm going to Failed QA this.
Created attachment 68824 [details] [review] Bug 19181 - Selenium test for logging into the Koha intranet and OPAC This selenium test goes through the process of creating a category and patron user (as is completed in the basic_workflow.t test) then the superlibrarian used to create them is logged out and the newly created patron user authenticates into the OPAC and staff intranet therefore testing the authenitcation of both. Test plan (this test plan includes how to install Selenium as well as how to run this test, for the benefit of people who have not got Selenium installed on their machines): 1. wget https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar 2. vim /etc/apt/sources.list.d/firefox.list 3. Paste into the file: deb http://packages.linuxmint.com debian import 4. sudo apt-get update 5. sudo apt-get install firefox 6. sudo apt-get install xvfb 7. Set the SELENIUM_PATH vartiable: SELENIUM_PATH=/home/vagrant/kohaclone/selenium-server-standalone-2.53.0.jar 8. Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null & 9. DISPLAY=:1 java -jar $SELENIUM_PATH Note: This will start up the selenium server. Everytime you want to shut down this terminal window and want to restart Selenium just run the step 9 command to restart the Selenium server 10. Open a new terminal window and write in: git clone https://github.com/gempesaw/Selenium-Remote-Driver --branch build/master --single-branch --depth 1 11. cd Selenium-Remote-Driver 12. perl Makefile.PL 13. make 14. make test 15. sudo make install 16. Now everything is installed and you can et up for running the selenium tests 17. Create a superlibrarian user with the username koha and password koha 18. If your usual port configuration for the intranet and OPAC is 8081 and 8080 respectively then set the staffClientBaseURL and OPACBaseURL system preferences to localhost:8080 and localhost:80 respectively 19. sudo koha-shell <instancename> 20. perl t/db_dependent/selenium/authenticate.t 21. The test should pass. Note: The time_diff comments in the test output showing what the test is doing Note: If you have issues with installing Selenium and Selenium::Remote::Driver please write a comment on the bug report and I will be more than happy to create a screencapture video showing all the steps Sponsored-By: Catalyst IT https://bugs.koha-community.org/show_bug.cgi?id=19181 Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Created attachment 68825 [details] [review] Bug 19181: Change to use ENV, fix login and passwords The kohadevbox has admin/admin set, so for testing when creating the initial superuser, if you wish to minimize effort, use admin/admin. Otherwise, make sure to: export KOHA_USER={whatever your user is} export KOHA_PASS={whatever your password is} before attempting to run the test. Also, this test was failing because of a validation check on the passwords requiring uppercase letters, lowercase letters, and numbers. Changed the sample data passwords to fix. Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
The readability of this code is a vast improvement over bug 18974. :)
This and the other selenium tests all are blocked by bug 19243.
Created attachment 74854 [details] [review] Bug 19181: Add new tests This patch reuses the method newly added to Selenium.pm and improve existing tests.
Comment on attachment 74854 [details] [review] Bug 19181: Add new tests Review of attachment 74854 [details] [review]: ----------------------------------------------------------------- ::: t/lib/Selenium.pm @@ +74,4 @@ > $login_button->submit(); > } > > +sub opac_auth { We don't have anything which calls this.
Nope but we may use it later. I wanted to tell explicitly which form we use to login from the authentication.t tests.
I can remove it anyway if you think it should.
Created attachment 75156 [details] [review] Bug 19181: Selenium test for logging into the Koha intranet and OPAC This selenium test goes through the process of creating a category and patron user (as is completed in the basic_workflow.t test) then the superlibrarian used to create them is logged out and the newly created patron user authenticates into the OPAC and staff intranet therefore testing the authenitcation of both. Test plan (this test plan includes how to install Selenium as well as how to run this test, for the benefit of people who have not got Selenium installed on their machines): 1. wget https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-2.53.0.jar 2. vim /etc/apt/sources.list.d/firefox.list 3. Paste into the file: deb http://packages.linuxmint.com debian import 4. sudo apt-get update 5. sudo apt-get install firefox 6. sudo apt-get install xvfb 7. Set the SELENIUM_PATH vartiable: SELENIUM_PATH=/home/vagrant/kohaclone/selenium-server-standalone-2.53.0.jar 8. Xvfb :1 -screen 0 1024x768x24 2>&1 >/dev/null & 9. DISPLAY=:1 java -jar $SELENIUM_PATH Note: This will start up the selenium server. Everytime you want to shut down this terminal window and want to restart Selenium just run the step 9 command to restart the Selenium server 10. Open a new terminal window and write in: git clone https://github.com/gempesaw/Selenium-Remote-Driver --branch build/master --single-branch --depth 1 11. cd Selenium-Remote-Driver 12. perl Makefile.PL 13. make 14. make test 15. sudo make install 16. Now everything is installed and you can et up for running the selenium tests 17. Create a superlibrarian user with the username koha and password koha 18. If your usual port configuration for the intranet and OPAC is 8081 and 8080 respectively then set the staffClientBaseURL and OPACBaseURL system preferences to localhost:8080 and localhost:80 respectively 19. sudo koha-shell <instancename> 20. perl t/db_dependent/selenium/authenticate.t 21. The test should pass. Note: The time_diff comments in the test output showing what the test is doing Note: If you have issues with installing Selenium and Selenium::Remote::Driver please write a comment on the bug report and I will be more than happy to create a screencapture video showing all the steps Sponsored-By: Catalyst IT https://bugs.koha-community.org/show_bug.cgi?id=19181 Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 75157 [details] [review] Bug 19181: Change to use ENV, fix login and passwords The kohadevbox has admin/admin set, so for testing when creating the initial superuser, if you wish to minimize effort, use admin/admin. Otherwise, make sure to: export KOHA_USER={whatever your user is} export KOHA_PASS={whatever your password is} before attempting to run the test. Also, this test was failing because of a validation check on the passwords requiring uppercase letters, lowercase letters, and numbers. Changed the sample data passwords to fix. Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 75158 [details] [review] Bug 19181: Add new tests This patch reuses the method newly added to Selenium.pm and improve existing tests. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Pushed to master for 18.05, thanks to everybody involved!
Created attachment 75278 [details] [review] Bug 19181: Fix jenkins failure
Pushed to master
Created attachment 75285 [details] [review] Bug 19181: Do not screenshot
Last patch pushed to master.