Add link to Swagger UI in Readme & Redirect root 10/132710/3
authoreschcam <cameron.scholes@est.tech>
Wed, 14 Dec 2022 11:34:25 +0000 (11:34 +0000)
committerVasyl Razinkov <vasyl.razinkov@est.tech>
Thu, 15 Dec 2022 17:45:55 +0000 (17:45 +0000)
Turns out the default URL of http://localhost:8080/ only loads the index.html and not the other assets.
Going to http://localhost:8080/swagger-ui/index.html loads everything correctly

Also added a redirect for the root URL to the correct address for the Swagger UI

Issue-ID: SDC-4292
Signed-off-by: eschcam <cameron.scholes@est.tech>
Change-Id: Ibca5956d1d2f5e18ba41e623329b199c8e9db9a5

README.md
catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/recipes/BE_4_jetty_Modules.rb
catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-jetty-rewrite.yaml.erb [new file with mode: 0644]
catalog-be/src/main/docker/backend/startup.sh

index ac67247..03e7301 100644 (file)
--- a/README.md
+++ b/README.md
@@ -83,7 +83,11 @@ More flags to use in the build process are:
 ## Accessing SDC
 
 After having started SDC with the command `mvn clean install -P start-sdc`, you can access it by accessing this URL: `http://<ip_address>:8285/login`
 ## Accessing SDC
 
 After having started SDC with the command `mvn clean install -P start-sdc`, you can access it by accessing this URL: `http://<ip_address>:8285/login`
+
+[Swagger UI](http://localhost:8080/swagger-ui/index.html) lists some endpoints available from catalog-BE. `http://<IP_ADDRESS>:8080/swagger-ui/index.html`
+
 As ONAP AAF is not present, the url provided uses the 8285 simulator ports, just click on the user you want to use for accessing SDC (i.e. Carlos Santana)
 As ONAP AAF is not present, the url provided uses the 8285 simulator ports, just click on the user you want to use for accessing SDC (i.e. Carlos Santana)
+
 For more information regarding using the webseal_simulator please refer to the following guide: [SDC Simulator](https://wiki.onap.org/display/DW/SDC+Simulator)
 
 ### SDC Containers
 For more information regarding using the webseal_simulator please refer to the following guide: [SDC Simulator](https://wiki.onap.org/display/DW/SDC+Simulator)
 
 ### SDC Containers
@@ -108,9 +112,9 @@ For further information and an image explaining the containers dependency map pl
 
 To access the logs, there are different options:
 * Connect to the docker container you want to inspect by doing `docker exec -it -u root sdc-XXXXXXXX-1 sh` 
 
 To access the logs, there are different options:
 * Connect to the docker container you want to inspect by doing `docker exec -it -u root sdc-XXXXXXXX-1 sh` 
-    Then look at the logs generally in /var/lib/jetty/logs or /var/log/onap (that may differ !)
+    Then look at the logs generally in /var/lib/jetty/logs or /var/log/onap (that may differ !)
 * A volume is shared between the BE, onboard-BE and FE containers, this volume is mapped to `/tmp/sdc-integration-tests`,
 * A volume is shared between the BE, onboard-BE and FE containers, this volume is mapped to `/tmp/sdc-integration-tests`,
-    In that folder you can obtain the logs of the different containers 
+    In that folder you can obtain the logs of the different containers 
 
 ### Debugging SDC
 
 
 ### Debugging SDC
 
@@ -124,6 +128,7 @@ It's therefore possible to connect your IDE to those debug ports remotely to wal
 
 ### Integration tests
 The integration are composed of 2 parts, one to test the BE Apis and another one to test the FE with selenium.
 
 ### Integration tests
 The integration are composed of 2 parts, one to test the BE Apis and another one to test the FE with selenium.
+
 The selenium tests make use of the selenium/standalone-firefox:2.53.1 container.
 
 About BE APIs tests, onboarding E2E flow :
 The selenium tests make use of the selenium/standalone-firefox:2.53.1 container.
 
 About BE APIs tests, onboarding E2E flow :
index 9e57212..5655d0f 100644 (file)
@@ -6,7 +6,7 @@ else
 end
 
 execute "create-jetty-modules" do
 end
 
 execute "create-jetty-modules" do
-  command "java -jar #{ENV['JETTY_HOME']}/start.jar --add-to-start=deploy && java -jar #{ENV['JETTY_HOME']}/start.jar --create-startd --add-to-start=http,https,setuid"
+  command "java -jar #{ENV['JETTY_HOME']}/start.jar --add-to-start=deploy && java -jar #{ENV['JETTY_HOME']}/start.jar --create-startd --add-to-start=http,https,setuid,rewrite"
   cwd "#{ENV['JETTY_BASE']}"
   action :run
 end
   cwd "#{ENV['JETTY_BASE']}"
   action :run
 end
@@ -21,7 +21,15 @@ template "http-ini" do
     :http_option => http_option ,
     :http_port => "#{node['BE'][:http_port]}"
   })
     :http_option => http_option ,
     :http_port => "#{node['BE'][:http_port]}"
   })
-   
+
+end
+
+template "jetty-rewrite" do
+  path "#{ENV['JETTY_BASE']}/etc/rewrite-root-to-swagger-ui.xml"
+  source "BE-jetty-rewrite.yaml.erb"
+  owner "#{ENV['JETTY_USER']}"
+  group "#{ENV['JETTY_GROUP']}"
+  mode "0644"
 end
 
 
 end
 
 
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-jetty-rewrite.yaml.erb b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-jetty-rewrite.yaml.erb
new file mode 100644 (file)
index 0000000..ea0e9aa
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
+<Configure id="Server" class="org.eclipse.jetty.server.Server">
+  <Ref refid="Rewrite">
+    <Call name="addRule">
+      <Arg>
+        <New class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
+          <Set name="pattern" type="String"/>
+          <Set name="location">/swagger-ui/index.html</Set>
+        </New>
+      </Arg>
+    </Call>
+  </Ref>
+
+  <!-- ===================== -->
+  <!-- DefaultHandler config -->
+  <!-- ===================== -->
+  <Ref id="DefaultHandler">
+    <Set name="showContexts">false</Set>
+  </Ref>
+</Configure>
index c64e4ac..0f778a3 100644 (file)
@@ -8,7 +8,7 @@ export JAVA_OPTIONS="$JAVA_OPTIONS -Dconfig.home=$JETTY_BASE/config \
        -Dartifactgenerator.config=$JETTY_BASE/config/catalog-be/Artifact-Generator.properties \
             -Donboarding_configuration.yaml=$JETTY_BASE/config/onboarding-be/onboarding_configuration.yaml \
        -Djavax.net.ssl.trustStore=$JETTY_BASE/etc/org.onap.sdc.trust.jks \
        -Dartifactgenerator.config=$JETTY_BASE/config/catalog-be/Artifact-Generator.properties \
             -Donboarding_configuration.yaml=$JETTY_BASE/config/onboarding-be/onboarding_configuration.yaml \
        -Djavax.net.ssl.trustStore=$JETTY_BASE/etc/org.onap.sdc.trust.jks \
-       -Djavax.net.ssl.trustStorePassword=z+KEj;t+,KN^iimSiS89e#p0" 
+       -Djavax.net.ssl.trustStorePassword=z+KEj;t+,KN^iimSiS89e#p0"
 
 cd $JETTY_BASE/chef-solo
 chef-solo -c solo.rb -E ${ENVNAME}
 
 cd $JETTY_BASE/chef-solo
 chef-solo -c solo.rb -E ${ENVNAME}
@@ -16,5 +16,6 @@ chef-solo -c solo.rb -E ${ENVNAME}
 # Execute Jetty
 cd $JETTY_HOME
 echo "jetty.httpConfig.sendServerVersion=false" >> $JETTY_HOME/start.d/start.ini
 # Execute Jetty
 cd $JETTY_HOME
 echo "jetty.httpConfig.sendServerVersion=false" >> $JETTY_HOME/start.d/start.ini
+echo "$JETTY_BASE/etc/rewrite-root-to-swagger-ui.xml" >> $JETTY_HOME/start.d/rewrite.ini
 
 java $JAVA_OPTIONS -jar "$JETTY_HOME/start.jar"
 
 java $JAVA_OPTIONS -jar "$JETTY_HOME/start.jar"