Skip to content

Commit

Permalink
[RHPAM-3162] - WSS - Wrong URL generated in secure communication betw…
Browse files Browse the repository at this point in the history
…een BC and KS in OCP (#386)

Signed-off-by: spolti <fspolti@redhat.com>
  • Loading branch information
spolti committed Sep 16, 2020
1 parent cb8dff9 commit 9bcb79a
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 16 deletions.
16 changes: 10 additions & 6 deletions jboss-kie-kieserver/added/launch/jboss-kie-kieserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,20 @@ function configure_controller_access {
if [ "${kieServerControllerHost}" != "" ]; then
# protocol
local kieServerControllerProtocol=$(find_env "KIE_SERVER_CONTROLLER_PROTOCOL" "http")
# port
local kieServerControllerPort="${KIE_SERVER_CONTROLLER_PORT}"
if [ "${kieServerControllerPort}" = "" ]; then
kieServerControllerPort=$(find_env "${kieServerControllerService}_SERVICE_PORT" "8080")
fi
# path
local kieServerControllerPath="/rest/controller"
if [ "${kieServerControllerProtocol}" = "ws" ]; then
if [[ "${kieServerControllerProtocol}" =~ ws?(s) ]]; then
kieServerControllerPath="/websocket/controller"
fi
# port
local kieServerControllerPort="${KIE_SERVER_CONTROLLER_PORT}"
if [ "${kieServerControllerPort}" = "" ]; then
if [[ "${kieServerControllerProtocol}" =~ https|wss ]]; then
kieServerControllerPort="8443"
else
kieServerControllerPort=$(find_env "${kieServerControllerService}_SERVICE_PORT" "8080")
fi
fi
# url
local kieServerControllerUrl=$(build_simple_url "${kieServerControllerProtocol}" "${kieServerControllerHost}" "${kieServerControllerPort}" "${kieServerControllerPath}")
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.kie.server.controller=${kieServerControllerUrl}"
Expand Down
115 changes: 114 additions & 1 deletion jboss-kie-kieserver/tests/bats/jboss-kie-kieserver.bats
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,117 @@ teardown() {
echo "Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ $JBOSS_KIE_ARGS == *"-Dorg.optaplanner.server.ext.thread.pool.queue.size=${expected}"* ]]
}
}

@test "test controller access with default values" {
KIE_SERVER_CONTROLLER_SERVICE="my-cool-service"
# *_SERVICE_HOST are generated by k8s
MY_COOL_SERVICE_SERVICE_HOST="10.10.10.10"

local expected=" -Dorg.kie.server.controller=http://10.10.10.10:8080/rest/controller -Dorg.kie.server.controller.user=\"adminUser\" -Dorg.kie.server.controller.pwd=\"admin1!\""

configure_controller_access

echo " Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ "${JBOSS_KIE_ARGS}" == "${expected}" ]]
}

@test "test controller access with default protocol and with port 9191" {
KIE_SERVER_CONTROLLER_SERVICE="my-cool-service"
# *_SERVICE_HOST are generated by k8s
MY_COOL_SERVICE_SERVICE_HOST="10.10.10.10"
KIE_SERVER_CONTROLLER_PORT="9191"
local expected=" -Dorg.kie.server.controller=http://10.10.10.10:9191/rest/controller -Dorg.kie.server.controller.user=\"adminUser\" -Dorg.kie.server.controller.pwd=\"admin1!\""

configure_controller_access

echo " Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ "${JBOSS_KIE_ARGS}" == "${expected}" ]]
}

@test "test controller access with custom host, port and protocol" {
KIE_SERVER_CONTROLLER_HOST="my-cool-host"
KIE_SERVER_CONTROLLER_PORT="443"
KIE_SERVER_CONTROLLER_PROTOCOL="https"
local expected=" -Dorg.kie.server.controller=https://my-cool-host:443/rest/controller -Dorg.kie.server.controller.user=\"adminUser\" -Dorg.kie.server.controller.pwd=\"admin1!\""

configure_controller_access

echo " Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ "${JBOSS_KIE_ARGS}" == "${expected}" ]]
}


@test "test controller access with https protocol and default port" {
KIE_SERVER_CONTROLLER_SERVICE="my-cool-service"
# *_SERVICE_HOST are generated by k8s
MY_COOL_SERVICE_SERVICE_HOST="10.10.10.10"
KIE_SERVER_CONTROLLER_PROTOCOL="https"
local expected=" -Dorg.kie.server.controller=https://10.10.10.10:8443/rest/controller -Dorg.kie.server.controller.user=\"adminUser\" -Dorg.kie.server.controller.pwd=\"admin1!\""

configure_controller_access

echo "Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ "${JBOSS_KIE_ARGS}" == "${expected}" ]]
}

@test "test controller access with ws protocol" {
KIE_SERVER_CONTROLLER_SERVICE="my-cool-service"
# *_SERVICE_HOST are generated by k8s
MY_COOL_SERVICE_SERVICE_HOST="10.10.10.10"
KIE_SERVER_CONTROLLER_PROTOCOL="ws"
local expected=" -Dorg.kie.server.controller=ws://10.10.10.10:8080/websocket/controller -Dorg.kie.server.controller.user=\"adminUser\" -Dorg.kie.server.controller.pwd=\"admin1!\""

configure_controller_access

echo "Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ "${JBOSS_KIE_ARGS}" == "${expected}" ]]
}

@test "Test controller access with wss protocol and default port" {
KIE_SERVER_CONTROLLER_SERVICE="my-cool-service"
# *_SERVICE_HOST are generated by k8s
MY_COOL_SERVICE_SERVICE_HOST="10.10.10.10"
KIE_SERVER_CONTROLLER_PROTOCOL="wss"
local expected=" -Dorg.kie.server.controller=wss://10.10.10.10:8443/websocket/controller -Dorg.kie.server.controller.user=\"adminUser\" -Dorg.kie.server.controller.pwd=\"admin1!\""

configure_controller_access

echo "Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ "${JBOSS_KIE_ARGS}" == "${expected}" ]]
}

@test "Test controller access with wss protocol and custom port" {
KIE_SERVER_CONTROLLER_SERVICE="my-cool-service"
# *_SERVICE_HOST are generated by k8s
MY_COOL_SERVICE_SERVICE_HOST="10.10.10.10"
KIE_SERVER_CONTROLLER_PORT="443"
KIE_SERVER_CONTROLLER_PROTOCOL="wss"
local expected=" -Dorg.kie.server.controller=wss://10.10.10.10:443/websocket/controller -Dorg.kie.server.controller.user=\"adminUser\" -Dorg.kie.server.controller.pwd=\"admin1!\""

configure_controller_access

echo "Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ "${JBOSS_KIE_ARGS}" == "${expected}" ]]
}

@test "test controller access with wss protocol, custom host and port" {
KIE_SERVER_CONTROLLER_HOST="my-cool-host"
KIE_SERVER_CONTROLLER_PORT="9443"
KIE_SERVER_CONTROLLER_PROTOCOL="wss"
local expected=" -Dorg.kie.server.controller=wss://my-cool-host:9443/websocket/controller -Dorg.kie.server.controller.user=\"adminUser\" -Dorg.kie.server.controller.pwd=\"admin1!\""

configure_controller_access

echo " Result: ${JBOSS_KIE_ARGS}"
echo "Expected: ${expected}"
[[ "${JBOSS_KIE_ARGS}" == "${expected}" ]]
}

66 changes: 57 additions & 9 deletions tests/features/common/kie-kieserver-common.feature
Original file line number Diff line number Diff line change
Expand Up @@ -263,21 +263,69 @@ Feature: Kie Server common features
And run sh -c 'test -f /home/jboss/.m2/repository/org/openshift/quickstarts/rhdm-kieserver-hellorules/1.6.0-SNAPSHOT/rhdm-kieserver-hellorules-1.6.0-SNAPSHOT.jar && echo all good' in container and check its output for all good
And run sh -c 'test -f /home/jboss/.m2/repository/org/openshift/quickstarts/rhdm-kieserver-hellorules-model/1.6.0-SNAPSHOT/rhdm-kieserver-hellorules-model-1.6.0-SNAPSHOT.jar && echo all good' in container and check its output for all good

Scenario: test Kie Server controller configuration
Scenario: test Kie Server controller access with default values
When container is started with env
| variable | value |
| KIE_SERVER_CONTROLLER_HOST | localhost |
| KIE_SERVER_CONTROLLER_PORT | 8080 |
| KIE_SERVER_CONTROLLER_PROTOCOL | ws |
Then container log should contain -Dorg.kie.server.controller=ws://localhost:8080/websocket/controller
| variable | value |
| KIE_SERVER_CONTROLLER_SERVICE | MY_COOL_SERVICE |
| MY_COOL_SERVICE_SERVICE_HOST | 10.10.10.10 |
Then container log should contain -Dorg.kie.server.controller=http://10.10.10.10:8080/rest/controller

Scenario: test Kie Server controller service configuration
Scenario: test Kie Server controller service configuration with default protocol and with port 9191
When container is started with env
| variable | value |
| KIE_SERVER_CONTROLLER_SERVICE | SERVICE_ONE |
| SERVICE_ONE_SERVICE_HOST | localhost |
| SERVICE_ONE_SERVICE_PORT | 8080 |
Then container log should contain -Dorg.kie.server.controller=http://localhost:8080/rest/controller
| SERVICE_ONE_SERVICE_PORT | 9191 |
Then container log should contain -Dorg.kie.server.controller=http://localhost:9191/rest/controller

Scenario: test Kie Server controller service configuration with custom host, port and protocol
When container is started with env
| variable | value |
| KIE_SERVER_CONTROLLER_HOST | my-cool-host |
| KIE_SERVER_CONTROLLER_PORT | 443 |
| KIE_SERVER_CONTROLLER_PROTOCOL | https |
Then container log should contain -Dorg.kie.server.controller=https://my-cool-host:443/rest/controller

Scenario: test Kie Server controller service configuration with https protocol and default port
When container is started with env
| variable | value |
| KIE_SERVER_CONTROLLER_SERVICE | SERVICE_ONE |
| SERVICE_ONE_SERVICE_HOST | localhost |
| KIE_SERVER_CONTROLLER_PROTOCOL | https |
Then container log should contain -Dorg.kie.server.controller=https://localhost:8443/rest/controller

Scenario: test Kie Server controller service configuration with with ws protocol
When container is started with env
| variable | value |
| KIE_SERVER_CONTROLLER_SERVICE | SERVICE_ONE |
| SERVICE_ONE_SERVICE_HOST | localhost |
| KIE_SERVER_CONTROLLER_PROTOCOL | ws |
Then container log should contain -Dorg.kie.server.controller=ws://localhost:8080/websocket/controller

Scenario: test Kie Server controller service configuration with wss protocol and default port
When container is started with env
| variable | value |
| KIE_SERVER_CONTROLLER_SERVICE | SERVICE_ONE |
| SERVICE_ONE_SERVICE_HOST | 10.10.10.10 |
| KIE_SERVER_CONTROLLER_PROTOCOL | wss |
Then container log should contain -Dorg.kie.server.controller=wss://10.10.10.10:8443/websocket/controller

Scenario: test Kie Server controller service configuration with wss protocol and custom port
When container is started with env
| variable | value |
| KIE_SERVER_CONTROLLER_SERVICE | SERVICE_ONE |
| SERVICE_ONE_SERVICE_HOST | localhost |
| KIE_SERVER_CONTROLLER_PORT | 443 |
| KIE_SERVER_CONTROLLER_PROTOCOL | wss |
Then container log should contain -Dorg.kie.server.controller=wss://localhost:443/websocket/controller

Scenario: test Kie Server controller service configuration wss protocol, custom host and port
When container is started with env
| variable | value |
| KIE_SERVER_CONTROLLER_HOST | localhost |
| KIE_SERVER_CONTROLLER_PORT | 9443 |
| KIE_SERVER_CONTROLLER_PROTOCOL | wss |
Then container log should contain -Dorg.kie.server.controller=wss://localhost:9443/websocket/controller

Scenario: test Kie Server router configuration
When container is started with env
Expand Down

0 comments on commit 9bcb79a

Please sign in to comment.