From 99a769b52cf20bca4803320df819af0133330baa Mon Sep 17 00:00:00 2001 From: ecaiyanlinux Date: Fri, 15 May 2020 13:58:02 +0200 Subject: [PATCH] Update test scripts to support a1-interface with https Issue-ID: NONRTRIC-218 Signed-off-by: ecaiyanlinux Change-Id: I7f8c6eaf1deccadbdfe0a80cab7a06d4f3e18b3a --- test/common/testcase_common.sh | 10 +++------- .../ric/cert/generate_cert_and_key.sh | 21 +++++++++++++++++++++ test/simulator-group/ric/cert/pass | 1 + test/simulator-group/ric/docker-compose.yml | 9 ++++++--- 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100755 test/simulator-group/ric/cert/generate_cert_and_key.sh create mode 100644 test/simulator-group/ric/cert/pass diff --git a/test/common/testcase_common.sh b/test/common/testcase_common.sh index 28c65d26..57344fb2 100755 --- a/test/common/testcase_common.sh +++ b/test/common/testcase_common.sh @@ -63,7 +63,7 @@ G3_COUNT=0 export RIC_SIM_HTTPX="http" export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:" export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT -export RIC_SIM_CERT_MOUNT_DIR="./fakedir" #Fake dir so that the sim container does not find any cert +export RIC_SIM_CERT_MOUNT_DIR="./cert" export MR_HTTPX="http" export MR_PORT=$MR_INTERNAL_PORT @@ -715,10 +715,8 @@ __print_err() { # (Not for test scripts) __find_sim_port() { name=$1" " #Space appended to prevent matching 10 if 1 is desired.... - cmdstr="docker ps --filter name=${name} --format \"{{.Names}} {{.Ports}}\" | grep '${name}' | sed s/0.0.0.0:// | cut -f 2 -d ' ' | cut -f 1 -d '-'" - cmdstr="docker ps --filter name=${name} --format \"{{.Names}} {{.Ports}}\" | grep '${name}' | cut -f 3 -d ',' | sed s/0.0.0.0:// | cut -f 2 -d ' ' | cut -f 1 -d '-'" - - res=$(eval $cmdstr) + cmdstr="docker inspect --format='{{(index (index .NetworkSettings.Ports \"$RIC_SIM_PORT/tcp\") 0).HostPort}}' ${name}" + res=$(eval $cmdstr) if [[ "$res" =~ ^[0-9]+$ ]]; then echo $res else @@ -1079,7 +1077,6 @@ use_simulator_http() { export RIC_SIM_HTTPX="http" export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:" export RIC_SIM_PORT=$RIC_SIM_INTERNAL_PORT - export RIC_SIM_CERT_MOUNT_DIR="./fakedir" #Fake dir so that the sim container does not find any cert echo "" } @@ -1088,7 +1085,6 @@ use_simulator_https() { export RIC_SIM_HTTPX="https" export RIC_SIM_LOCALHOST=$RIC_SIM_HTTPX"://localhost:" export RIC_SIM_PORT=$RIC_SIM_INTERNAL_SECURE_PORT - export RIC_SIM_CERT_MOUNT_DIR="./cert" echo "" } diff --git a/test/simulator-group/ric/cert/generate_cert_and_key.sh b/test/simulator-group/ric/cert/generate_cert_and_key.sh new file mode 100755 index 00000000..0f79bbf7 --- /dev/null +++ b/test/simulator-group/ric/cert/generate_cert_and_key.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# ============LICENSE_START=============================================== +# Copyright (C) 2020 Nordix Foundation. All rights reserved. +# ======================================================================== +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END================================================= +# + +# This will generate a self-signed certificate with password 'test' +openssl req -x509 -passout pass:"test" -newkey rsa:2048 -keyout key.crt -out cert.crt -days 9999 diff --git a/test/simulator-group/ric/cert/pass b/test/simulator-group/ric/cert/pass new file mode 100644 index 00000000..30d74d25 --- /dev/null +++ b/test/simulator-group/ric/cert/pass @@ -0,0 +1 @@ +test \ No newline at end of file diff --git a/test/simulator-group/ric/docker-compose.yml b/test/simulator-group/ric/docker-compose.yml index fd8fc00d..701a7f56 100644 --- a/test/simulator-group/ric/docker-compose.yml +++ b/test/simulator-group/ric/docker-compose.yml @@ -29,7 +29,8 @@ services: networks: - default ports: - - ${RIC_SIM_PORT}/tcp + - ${RIC_SIM_INTERNAL_PORT}/tcp + - ${RIC_SIM_INTERNAL_SECURE_PORT}/tcp environment: - A1_VERSION=${G1_A1_VERSION} - REMOTE_HOSTS_LOGGING=1 @@ -40,7 +41,8 @@ services: networks: - default ports: - - ${RIC_SIM_PORT}/tcp + - ${RIC_SIM_INTERNAL_PORT}/tcp + - ${RIC_SIM_INTERNAL_SECURE_PORT}/tcp environment: - A1_VERSION=${G2_A1_VERSION} - REMOTE_HOSTS_LOGGING=1 @@ -51,7 +53,8 @@ services: networks: - default ports: - - ${RIC_SIM_PORT}/tcp + - ${RIC_SIM_INTERNAL_PORT}/tcp + - ${RIC_SIM_INTERNAL_SECURE_PORT}/tcp environment: - A1_VERSION=${G3_A1_VERSION} - REMOTE_HOSTS_LOGGING=1 -- 2.16.6