Improve docs and fix some mistakes on the selenium tests
This commit is contained in:
		
							parent
							
								
									c8f6d9ee86
								
							
						
					
					
						commit
						99930e1fef
					
				|  | @ -15,11 +15,9 @@ For instance, all OAuth2 related tests are under `test/oauth`. And under this fo | ||||||
| we have another subfolder, `tests/oauth/with-uaa` to group all the tests cases which run against UAA as OAuth2 server. | we have another subfolder, `tests/oauth/with-uaa` to group all the tests cases which run against UAA as OAuth2 server. | ||||||
| 
 | 
 | ||||||
| At the moment, there are no smart around discovering all the tests under subfolders. That will come later. | At the moment, there are no smart around discovering all the tests under subfolders. That will come later. | ||||||
| For now, the command `make run-tests` runs just the test cases under `oauth/with-uaa`. But first, the script `setup.sh` is | For now, the command `make run-tests` explicitly runs the test cases under `oauth/with-uaa`. | ||||||
| invoked which launches a container running RabbitMQ configured with UAA, and another container running UAA configured with a number of users, permissions, and clients. |  | ||||||
| 
 | 
 | ||||||
| 
 | # Get environment ready before running any tests | ||||||
| # Run single test |  | ||||||
| 
 | 
 | ||||||
| Before running a test we need to set up its environment by running the command below. It will | Before running a test we need to set up its environment by running the command below. It will | ||||||
| launch RabbitMQ and UAA as a docker containers, and set up UAA with the right users, clients and scopes.   | launch RabbitMQ and UAA as a docker containers, and set up UAA with the right users, clients and scopes.   | ||||||
|  | @ -27,27 +25,12 @@ launch RabbitMQ and UAA as a docker containers, and set up UAA with the right us | ||||||
| test/oauth/with-uaa/setup.sh | test/oauth/with-uaa/setup.sh | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| **IMPORTANT**: When we combine browser running the local machine and UAA and RabbitMQ is docker it is not | **IMPORTANT**: When we run UAA and RabbitMQ in docker and the browser in our local machine, we have to use | ||||||
| possible to refer to localhost anymore. Hence we use `local-rabbitmq` and `local-uaa` instead. And we need | the hostnames aliases `local-rabbitmq` and `local-uaa` which must be declared in our /etc/hosts file. | ||||||
| this line into our /etc/hosts: |  | ||||||
| ``` | ``` | ||||||
| 127.0.0.1 local-uaa local-rabbitmq | 127.0.0.1 local-uaa local-rabbitmq | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| And now we can run the test: |  | ||||||
| ```bash |  | ||||||
| RUN_LOCAL=TRUE ./node_modules/.bin/mocha  --timeout 20000 test/oauth/with-uaa/happy-login.js |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| ## Run RabbitMQ from source |  | ||||||
| 
 |  | ||||||
| If we prefer, we can run RabbitMQ from source. We just kill+rm the `local-rabbitmq` container and launch |  | ||||||
| RabbitMQ as follows: |  | ||||||
| ```bash |  | ||||||
| gmake run-broker PLUGINS="rabbitmq_management rabbitmq_auth_backend_oauth2" RABBITMQ_CONFIG_FILE=deps/rabbitmq_management/selenium/test/oauth/with-uaa/rabbitmq.config |  | ||||||
| ``` |  | ||||||
| > Run the command from the root of rabbitmq-server checked out folder |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| # Run all tests (WIP) | # Run all tests (WIP) | ||||||
| 
 | 
 | ||||||
|  | @ -57,3 +40,31 @@ Chrome browser. This way we can see all the interactions driven by the tests on | ||||||
| should anything failed, we can see where it failed. To use this mode, we run the tests with the command `RUN_LOCAL=TRUE make run-tests` | should anything failed, we can see where it failed. To use this mode, we run the tests with the command `RUN_LOCAL=TRUE make run-tests` | ||||||
| - **Continuous integration way** - We run the tests against a standalone chrome browser which runs in silent mode (no UI) in | - **Continuous integration way** - We run the tests against a standalone chrome browser which runs in silent mode (no UI) in | ||||||
| a docker container. To launch the standalone chrome browser we run `make run-chrome` followed by `make run-tests` to run the tests. | a docker container. To launch the standalone chrome browser we run `make run-chrome` followed by `make run-tests` to run the tests. | ||||||
|  | 
 | ||||||
|  | Both methods run the tests from a docker container using a docker image that we have to build first by running the following command: | ||||||
|  | ``` | ||||||
|  | make init-tests | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | In summary, if we want to run all tests against our local browser, we have to run these commands: | ||||||
|  | ``` | ||||||
|  | test/oauth/with-uaa/setup.sh | ||||||
|  | make init-tests | ||||||
|  | RUN_LOCAL=TRUE make run-tests | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | # Run single test | ||||||
|  | 
 | ||||||
|  | If we want to run a single tests rather than all tests under `oauth/with-uaa`, we run a command similar to this one: | ||||||
|  | ```bash | ||||||
|  | RUN_LOCAL=TRUE ./node_modules/.bin/mocha  --timeout 20000 test/oauth/with-uaa/happy-login.js | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ## Run RabbitMQ from source | ||||||
|  | 
 | ||||||
|  | If we prefer, we can run RabbitMQ from source rather from a docker container, we launch it as follows: | ||||||
|  | ```bash | ||||||
|  | gmake run-broker PLUGINS="rabbitmq_management rabbitmq_auth_backend_oauth2" RABBITMQ_CONFIG_FILE=deps/rabbitmq_management/selenium/test/oauth/with-uaa/rabbitmq.config | ||||||
|  | ``` | ||||||
|  | > Run the command from the root of rabbitmq-server checked out folder | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ | ||||||
|       {oauth_enable, true}, |       {oauth_enable, true}, | ||||||
|       {oauth_client_id, "rabbit_client_code"}, |       {oauth_client_id, "rabbit_client_code"}, | ||||||
|       {oauth_client_secret, "rabbit_client_code"}, |       {oauth_client_secret, "rabbit_client_code"}, | ||||||
|       {oauth_provider_url, "http://localhost:8080/uaa"} |       {oauth_provider_url, "http://local-uaa:8080/uaa"} | ||||||
|   ]}, |   ]}, | ||||||
|   {rabbitmq_auth_backend_oauth2, [ |   {rabbitmq_auth_backend_oauth2, [ | ||||||
|     {resource_server_id, <<"rabbitmq">>}, |     {resource_server_id, <<"rabbitmq">>}, | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ var BasePage = require('./BasePage') | ||||||
| const LOGIN_BUTTON = By.css('div#outer div#login div#login-status button#loginWindow'); | const LOGIN_BUTTON = By.css('div#outer div#login div#login-status button#loginWindow'); | ||||||
| const WARNING = By.css('p.warning') | const WARNING = By.css('p.warning') | ||||||
| 
 | 
 | ||||||
| module.exports = class SSOLoginPage extends BasePage { | module.exports = class SSOHomePage extends BasePage { | ||||||
| 
 | 
 | ||||||
|   async isLoaded () { |   async isLoaded () { | ||||||
|     return this.waitForDisplayed(LOGIN_BUTTON) |     return this.waitForDisplayed(LOGIN_BUTTON) | ||||||
|  |  | ||||||
|  | @ -6,10 +6,10 @@ const FORM = By.css('form'); | ||||||
| const USERNAME = By.css('input[name="username"]') | const USERNAME = By.css('input[name="username"]') | ||||||
| const PASSWORD = By.css('input[name="password"]') | const PASSWORD = By.css('input[name="password"]') | ||||||
| 
 | 
 | ||||||
| module.exports = class UAAHomePage extends BasePage { | module.exports = class UAALoginPage extends BasePage { | ||||||
| 
 | 
 | ||||||
|   async isLoaded () { |   async isLoaded () { | ||||||
|     return this.waitForDisplayed(FORM)     |     return this.waitForDisplayed(FORM) | ||||||
|   } |   } | ||||||
|   async login(username, password) { |   async login(username, password) { | ||||||
|     await this.isLoaded(); |     await this.isLoaded(); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue