You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2019/11/15 15:46:43 UTC

[GitHub] [knox] smolnar82 opened a new pull request #196: KNOX-1654 - Ability to exclude services to apply global rewrite rules

smolnar82 opened a new pull request #196: KNOX-1654 - Ability to exclude services to apply global rewrite rules
URL: https://github.com/apache/knox/pull/196
 
 
   ## What changes were proposed in this pull request?
   
   We need to allow end-users to declare certain service(s) which are not affected by global rules even if they would match by them.
   
   ## How was this patch tested?
   
   Added new uni tests; updated existing ones and ran them:
   ```
   [INFO] ------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time: 18:23 min (Wall Clock)
   [INFO] Finished at: 2019-11-15T16:19:43+01:00
   [INFO] Final Memory: 408M/1814M
   [INFO] ------------------------------------------------------------------------
   ```
   
   In addition to unit testing the following E2E test steps were executed:
   1. started a local web server with `netcat` with the following content:
   ```
   <!doctype html>
   <html>
   <body>
   <h1>A webpage served by netcat</h1>
   <a href="http://localhost:1234/testLink">test link</a>
   </body>
   </html>
   ```
   2. Added two new service definitions:
   SERVICE 1 without any outboud rule:
   <img width="938" alt="Screen Shot 2019-11-15 at 4 36 19 PM" src="https://user-images.githubusercontent.com/34065904/68955435-4cb3eb00-07c6-11ea-840c-7ca23d4bd450.png">
   SERVICE2 with an outbound rule which matches the above link in the test HTML:
   <img width="947" alt="Screen Shot 2019-11-15 at 4 36 30 PM" src="https://user-images.githubusercontent.com/34065904/68955449-53426280-07c6-11ea-860a-938eac4e3584.png">
   3. Added these services in `sandbox` topology
   <img width="945" alt="Screen Shot 2019-11-15 at 4 39 37 PM" src="https://user-images.githubusercontent.com/34065904/68955533-8edd2c80-07c6-11ea-8eb4-44273de1069a.png">
   
   4. Made SERVICE2 global in `gateway-site.xml` and re-started the gateway:
   ```
       <property>
           <name>gateway.global.rules.services</name>
           <value>SERVICE2</value>
       </property>
   ```
   5. Tested both services using `curl`:
   ```
   $ curl -ku guest:guest-password 'https://localhost:8443/gateway/sandbox/service2/test'
   <!doctype html>
   <html>
   <body>
   <h1>A webpage served by netcat</h1>
   <a href="/gateway/sandbox/SERVICE2/">test link</a>
   </body>
   </html>
   ```
   ```
   $ curl -ku guest:guest-password 'https://localhost:8443/gateway/sandbox/service1/test'
   <!doctype html>
   <html>
   <body>
   <h1>A webpage served by netcat</h1>
   <a href="/gateway/sandbox/SERVICE2/">test link</a>
   </body>
   </html>
   ```
   As expected, the global rule `SERVICE2/service2/outbound/links` defined in `SERVICE2` has been applied here too.
   
   6. Marked `SERVICE1`  as a service to exclude global rules in `gateway-site.xml` and re-started the gateway:
   ```
       <property>
           <name>gateway.global.rules.excluded.services</name>
           <value>SERVICE1</value>
       </property>
   ```
   
   7. Re-tested the services:
   ```
   $ curl -ku guest:guest-password 'https://localhost:8443/gateway/sandbox/service2/test:
   <!doctype html>
   <html>
   <body>
   <h1>A webpage served by netcat</h1>
   <a href="/gateway/sandbox/SERVICE2/">test link</a>
   </body>
   </html>
   ```
   ```
   $ curl -ku guest:guest-password 'https://localhost:8443/gateway/sandbox/service1/test'
   <!doctype html>
   <html>
   <body>
   <h1>A webpage served by netcat</h1>
   <a href="http://localhost:1234/testLink">test link</a>
   </body>
   </html>
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services