Skip to content

Commit

Permalink
[KIECLOUD-160] Adding http(s) support for git (#256)
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Zanini <zanini@redhat.com>
  • Loading branch information
ricardozanini authored and errantepiphany committed Aug 6, 2019
1 parent c3445d6 commit e31ae60
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
28 changes: 23 additions & 5 deletions jboss-kie-workbench/added/launch/jboss-kie-workbench.sh
Expand Up @@ -192,7 +192,7 @@ function configure_guvnor_settings() {
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.dir=${kieDataDir}"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.ssh.cert.dir=${kieDataDir}"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.daemon.enabled=false"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.ssh.host=0.0.0.0"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.ssh.enabled=false"
if [[ $JBOSS_PRODUCT != *monitoring && "${GIT_HOOKS_DIR}" != "" ]]; then
if [ ! -e "${GIT_HOOKS_DIR}" ]; then
echo "GIT_HOOKS_DIR directory \"${GIT_HOOKS_DIR}\" does not exist; creating..."
Expand All @@ -213,10 +213,28 @@ function configure_guvnor_settings() {
log_info "Setting workbench org.appformer.m2repo.url to: ${maven_url}"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.appformer.m2repo.url=${maven_url}"
# workbench host
local workbench_host=$(query_route_host "${WORKBENCH_ROUTE_NAME}" "${HOSTNAME}")
workbench_host=$(query_route_service_host "${WORKBENCH_ROUTE_NAME}" "${workbench_host}")
log_info "Setting workbench org.uberfire.nio.git.ssh.hostname to: ${workbench_host}"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.ssh.hostname=${workbench_host}"
local defaultInsecureHost="${HOSTNAME_HTTP:-${HOSTNAME:-localhost}}"
local workbench_host=$(query_route_host "${WORKBENCH_ROUTE_NAME}" "${defaultInsecureHost}")
local workbench_host_protocol=$(query_route_protocol "${WORKBENCH_ROUTE_NAME}" "http")
if [ -n "${workbench_host}" ]; then
if [ "${workbench_host_protocol}" = "https" ]; then
log_info "Setting workbench org.uberfire.nio.git.https.hostname to: ${workbench_host}"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.http.enabled=false"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.https.enabled=true"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.https.hostname=${workbench_host}"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.https.port=443"
elif [ "${workbench_host_protocol}" = "http" ]; then
log_info "Setting workbench org.uberfire.nio.git.http.hostname to: ${workbench_host}"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.https.enabled=false"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.http.enabled=true"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.http.hostname=${workbench_host}"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.http.port=80"
fi
else
# Since we don't have a hostname, the git over http(s) should be disabled
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.https.enabled=false"
JBOSS_KIE_ARGS="${JBOSS_KIE_ARGS} -Dorg.uberfire.nio.git.http.enabled=false"
fi
}

# Set the max metaspace size only for the workbench
Expand Down
31 changes: 25 additions & 6 deletions jboss-kie-workbench/tests/bats/jboss-kie-workbench.bats
Expand Up @@ -5,24 +5,25 @@ mkdir -p $JBOSS_HOME/bin/launch

cp $BATS_TEST_DIRNAME/../../../tests/bats/common/launch-common.sh $JBOSS_HOME/bin/launch
cp $BATS_TEST_DIRNAME/../../../tests/bats/common/logging.bash $JBOSS_HOME/bin/launch/logging.sh
cp $BATS_TEST_DIRNAME/../../../jboss-kie-common/added/launch/jboss-kie-common.sh $JBOSS_HOME/bin/launch/jboss-kie-common.sh

# begin mocks - import if require in future tests
touch "${JBOSS_HOME}/bin/launch/login-modules-common.sh"
touch "${JBOSS_HOME}/bin/launch/jboss-kie-common.sh"
#touch "${JBOSS_HOME}/bin/launch/jboss-kie-common.sh"
touch "${JBOSS_HOME}/bin/launch/jboss-kie-wildfly-common.sh"
touch "${JBOSS_HOME}/bin/launch/management-common.sh"
touch "${JBOSS_HOME}/bin/launch/logging.sh"
touch "${JBOSS_HOME}/bin/launch/jboss-kie-wildfly-security.sh"

function query_route_host() {
echo ""
function query_default_route_host() {
echo "${WORKBENCH_ROUTE_NAME}-host"
}

function query_route_service_host() {
echo ""
function query_route_protocol() {
echo "http"
}

function build_route_url() {
function query_route_service_host() {
echo ""
}
# end mocks
Expand All @@ -41,4 +42,22 @@ teardown() {

configure_guvnor_settings >&2
[ -d "${GIT_HOOKS_DIR}" ]
}

@test "Check git http protocol was enabled successfully" {
WORKBENCH_ROUTE_NAME="businesscentral-route"
JBOSS_KIE_ARGS=""
local expected=$HOSTNAME
configure_guvnor_settings >&2
[[ $JBOSS_KIE_ARGS == *"-Dorg.uberfire.nio.git.http.enabled=true"* ]]
[[ $JBOSS_KIE_ARGS == *"-Dorg.uberfire.nio.git.http.hostname=${expected}"* ]]
}

@test "Check maven repo url has been correctly set" {
WORKBENCH_ROUTE_NAME="businesscentral-route"
JBOSS_KIE_ARGS=""
local expected="http://${HOSTNAME}:80/maven2"
echo "Expected is ${expected}" >&2
configure_guvnor_settings >&2
[[ $JBOSS_KIE_ARGS == *"-Dorg.appformer.m2repo.url=${expected}"* ]]
}
10 changes: 10 additions & 0 deletions tests/features/rhpam/businesscentral/rhpam-businesscentral.feature
Expand Up @@ -69,3 +69,13 @@ Feature: RHPAM Business Central configuration tests
Scenario: Check Workbench profile for rhpam
When container is ready
Then container log should contain -Dorg.kie.workbench.profile=FORCE_FULL
# https://issues.jboss.org/browse/KIECLOUD-160
Scenario: Check Workbench for Git http support
When container is started with env
| variable | value |
| HOSTNAME_HTTP | example.com |
Then container log should contain -Dorg.uberfire.nio.git.https.enabled=false
And container log should contain -Dorg.uberfire.nio.git.http.enabled=true
And container log should contain -Dorg.uberfire.nio.git.http.hostname=example.com
And container log should contain -Dorg.uberfire.nio.git.http.port=80

0 comments on commit e31ae60

Please sign in to comment.