Add functions test cases for ECS
Documentation in README files not yet included
Issue-ID: NONRTRIC-297
Signed-off-by: BjornMagnussonXA <bjorn.magnusson@est.tech>
Change-Id: I9365d6100f7ef0232e4787e350c69e3a8390de32
diff --git a/test/prodstub/.gitignore b/test/prodstub/.gitignore
new file mode 100644
index 0000000..4aa3a7a
--- /dev/null
+++ b/test/prodstub/.gitignore
@@ -0,0 +1,2 @@
+.tmp.json
+.dockererr
\ No newline at end of file
diff --git a/test/prodstub/Dockerfile b/test/prodstub/Dockerfile
new file mode 100644
index 0000000..bdc3521
--- /dev/null
+++ b/test/prodstub/Dockerfile
@@ -0,0 +1,33 @@
+# ============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=================================================
+#
+
+FROM python:3.8-slim-buster
+
+COPY app/ /usr/src/app/
+COPY cert/ /usr/src/app/cert/
+
+WORKDIR /usr/src/app
+
+RUN pip install -r requirements.txt
+
+RUN chmod +x start.sh
+
+#install nginx
+RUN apt-get update
+RUN apt-get install -y nginx=1.14.*
+
+CMD [ "./start.sh" ]
diff --git a/test/prodstub/README.md b/test/prodstub/README.md
new file mode 100644
index 0000000..aa23b78
--- /dev/null
+++ b/test/prodstub/README.md
@@ -0,0 +1,46 @@
+## producer stub - a stub interface to simulate data producers ##
+
+The producer stub is intended for function tests to simulate data producers.
+
+
+# Ports and certificates
+TBD
+
+| Port | Protocol |
+| -------- | ----- |
+| 8092 | http |
+| 8093 | https |
+
+
+
+### Control interface ###
+
+TBD
+
+
+### Build and start ###
+
+>Build image<br>
+```docker build -t producer-stub .```
+
+>Start the image on both http and https<br>
+```docker run -it -p 8092:8092 -p 8093:8093 --name producer-stub producer-stub```
+
+It will listen to http 8092 port and https 8093 port(using default certificates) at the same time.
+
+TBD
+
+## License
+
+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.
\ No newline at end of file
diff --git a/test/prodstub/app/job-schema.json b/test/prodstub/app/job-schema.json
new file mode 100644
index 0000000..1662066
--- /dev/null
+++ b/test/prodstub/app/job-schema.json
@@ -0,0 +1,20 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "title": "EI Job Schema",
+ "description": "Schema for EI Job",
+ "type": "object",
+ "properties": {
+ "ei_job_identity": {
+ "type": "string"
+ },
+ "ei_type_identity": {
+ "type": "string"
+ },
+ "target_uri": {
+ "type": "string"
+ },
+ "ei_job_data": {
+ "type": "object"
+ }
+ }
+ }
\ No newline at end of file
diff --git a/test/prodstub/app/nginx.conf b/test/prodstub/app/nginx.conf
new file mode 100644
index 0000000..8119b0d
--- /dev/null
+++ b/test/prodstub/app/nginx.conf
@@ -0,0 +1,100 @@
+user www-data;
+worker_processes auto;
+pid /run/nginx.pid;
+include /etc/nginx/modules-enabled/*.conf;
+
+events {
+ worker_connections 768;
+ # multi_accept on;
+}
+
+http {
+
+ ##
+ # Basic Settings
+ ##
+
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+ keepalive_timeout 65;
+ types_hash_max_size 2048;
+ # server_tokens off;
+
+ # server_names_hash_bucket_size 64;
+ # server_name_in_redirect off;
+
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ server { # simple reverse-proxy
+ listen 8092;
+ listen [::]:8092;
+ listen 8093 ssl;
+ listen [::]:8093 ssl;
+ server_name localhost;
+ ssl_certificate /usr/src/app/cert/cert.crt;
+ ssl_certificate_key /usr/src/app/cert/key.crt;
+ ssl_password_file /usr/src/app/cert/pass;
+
+ # serve dynamic requests
+ location / {
+ proxy_pass http://localhost:2222;
+ }
+ }
+ ##
+ # SSL Settings
+ ##
+
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
+ ssl_prefer_server_ciphers on;
+
+ ##
+ # Logging Settings
+ ##
+
+ access_log /var/log/nginx/access.log;
+ error_log /var/log/nginx/error.log;
+
+ ##
+ # Gzip Settings
+ ##
+
+ gzip on;
+
+ # gzip_vary on;
+ # gzip_proxied any;
+ # gzip_comp_level 6;
+ # gzip_buffers 16 8k;
+ # gzip_http_version 1.1;
+ # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
+
+ ##
+ # Virtual Host Configs
+ ##
+
+ include /etc/nginx/conf.d/*.conf;
+ include /etc/nginx/sites-enabled/*;
+}
+
+
+#mail {
+# # See sample authentication script at:
+# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
+#
+# # auth_http localhost/auth.php;
+# # pop3_capabilities "TOP" "USER";
+# # imap_capabilities "IMAP4rev1" "UIDPLUS";
+#
+# server {
+# listen localhost:110;
+# protocol pop3;
+# proxy on;
+# }
+#
+# server {
+# listen localhost:143;
+# protocol imap;
+# proxy on;
+# }
+#}
diff --git a/test/prodstub/app/prodstub.py b/test/prodstub/app/prodstub.py
new file mode 100644
index 0000000..c21a7ab
--- /dev/null
+++ b/test/prodstub/app/prodstub.py
@@ -0,0 +1,463 @@
+
+# ============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=================================================
+#
+
+from flask import Flask
+from flask import request
+
+import json
+from jsonschema import validate
+
+app = Flask(__name__)
+
+# # list of callback messages
+# msg_callbacks={}
+
+# Server info
+HOST_IP = "::"
+HOST_PORT = 2222
+
+# # Metrics vars
+# cntr_msg_callbacks=0
+# cntr_msg_fetched=0
+
+# Request and response constants
+CALLBACK_CREATE_URL="/callbacks/create/<string:producer_id>"
+CALLBACK_DELETE_URL="/callbacks/delete/<string:producer_id>"
+CALLBACK_SUPERVISION_URL="/callbacks/supervision/<string:producer_id>"
+
+ARM_CREATE_RESPONSE="/arm/create/<string:producer_id>/<string:job_id>"
+ARM_DELETE_RESPONSE="/arm/delete/<string:producer_id>/<string:job_id>"
+ARM_SUPERVISION_RESPONSE="/arm/supervision/<string:producer_id>"
+ARM_TYPE="/arm/type/<string:producer_id>/<string:type_id>"
+
+COUNTER_SUPERVISION="/counter/supervision/<string:producer_id>"
+COUNTER_CREATE="/counter/create/<string:producer_id>/<string:job_id>"
+COUNTER_DELETE="/counter/delete/<string:producer_id>/<string:job_id>"
+
+JOB_DATA="/jobdata/<string:producer_id>/<string:job_id>"
+
+STATUS="/status"
+
+#Constsants
+APPL_JSON='application/json'
+UNKNOWN_QUERY_PARAMETERS="Unknown query parameter(s)"
+RETURNING_CONFIGURED_RESP="returning configured response code"
+JOBID_NO_MATCH="job id in stored json does not match request"
+PRODUCER_OR_JOB_NOT_FOUND="producer or job not found"
+PRODUCER_NOT_FOUND="producer not found"
+TYPE_NOT_FOUND="type not found"
+TYPE_IN_USE="type is in use in a job"
+JSON_CORRUPT="json in request is corrupt or missing"
+
+#Producer and job db, including armed responses
+db={}
+# producer
+# armed response for supervision
+# armed types
+# supervision counter
+# job
+# job json
+# armed response for create
+# armed response for delete
+# create counter
+# delete counter
+
+# Helper function to populate a callback dict with the basic structure
+# if job_id is None then only the producer level is setup and the producer dict is returned
+# if job_id is not None, the job level is setup and the job dict is returned (producer must exist)
+def setup_callback_dict(producer_id, job_id):
+
+ producer_dict=None
+ if (producer_id in db.keys()):
+ producer_dict=db[producer_id]
+ else:
+ if (job_id is not None):
+ return None
+ producer_dict={}
+ db[producer_id]=producer_dict
+
+ producer_dict['supervision_response']=200
+ producer_dict['supervision_counter']=0
+ producer_dict['types']=[]
+
+ if (job_id is None):
+ return producer_dict
+
+ job_dict=None
+ if (job_id in producer_dict.keys()):
+ job_dict=producer_dict[job_id]
+ else:
+ job_dict={}
+ producer_dict[job_id]=job_dict
+ job_dict['create_response']=201
+ job_dict['delete_response']=404
+ job_dict['json']=None
+ job_dict['create_counter']=0
+ job_dict['delete_counter']=0
+ return job_dict
+
+
+# Helper function to get an entry from the callback db
+# if job_id is None then only the producer dict is returned (or None if producer is not found)
+# if job_id is not None, the job is returned (or None if producer/job is not found)
+def get_callback_dict(producer_id, job_id):
+
+ producer_dict=None
+ if (producer_id in db.keys()):
+ producer_dict=db[producer_id]
+
+ if (job_id is None):
+ return producer_dict
+
+ job_dict=None
+ if (job_id in producer_dict.keys()):
+ job_dict=producer_dict[job_id]
+
+ return job_dict
+
+# Helper function find if a key/valye exist in the dictionay tree
+# True if found
+def recursive_search(s_dict, s_key, s_id):
+ for pkey in s_dict:
+ if (pkey == s_key) and (s_dict[pkey] == s_id):
+ return True
+ if (isinstance(s_dict[pkey], dict)):
+ recursive_search(s_dict[pkey], s_key, s_id)
+
+ return False
+
+# I'm alive function
+# response: always 200
+@app.route('/',
+ methods=['GET'])
+def index():
+ return 'OK', 200
+
+# Arm the create callback with a response code
+# Omitting the query parameter switch to response back to the standard 200/201 response
+# URI and parameters (PUT): /arm/create/<producer_id>/<job-id>[?response=<resonsecode>]
+# Setting
+# response: 200 (400 if incorrect query params)
+@app.route(ARM_CREATE_RESPONSE,
+ methods=['PUT'])
+def arm_create(producer_id, job_id):
+
+ arm_response=request.args.get('response')
+
+ if (arm_response is None):
+ if (len(request.args) != 0):
+ return UNKNOWN_QUERY_PARAMETERS,400
+ else:
+ if (len(request.args) != 1):
+ return UNKNOWN_QUERY_PARAMETERS,400
+
+ print("Arm create received for producer: "+str(producer_id)+" and job: "+str(job_id)+" and response: "+str(arm_response))
+
+ job_dict=setup_callback_dict(producer_id, job_id)
+
+ if (arm_response is None): #Reset the response depending if a job exists or not
+ if (job_dict['json'] is None):
+ job_dict['create_response']=201
+ else:
+ job_dict['create_response']=200
+ else:
+ job_dict['create_response']=arm_response
+
+ return "",200
+
+# Arm the delete callback with a response code
+# Omitting the query parameter switch to response back to the standard 204 response
+# URI and parameters (PUT): /arm/delete/<producer_id>/<job-id>[?response=<resonsecode>]
+# response: 200 (400 if incorrect query params)
+@app.route(ARM_DELETE_RESPONSE,
+ methods=['PUT'])
+def arm_delete(producer_id, job_id):
+
+ arm_response=request.args.get('response')
+
+ if (arm_response is None):
+ if (len(request.args) != 0):
+ return UNKNOWN_QUERY_PARAMETERS,400
+ else:
+ if (len(request.args) != 1):
+ return UNKNOWN_QUERY_PARAMETERS,400
+
+ print("Arm delete received for producer: "+str(producer_id)+" and job: "+str(job_id)+" and response: "+str(arm_response))
+
+ arm_response=request.args.get('response')
+
+ job_dict=setup_callback_dict(producer_id, job_id)
+
+ if (arm_response is None): #Reset the response depening if a job exists or not
+ if (job_dict['json'] is None):
+ job_dict['delete_response']=404
+ else:
+ job_dict['delete_response']=204
+ else:
+ job_dict['delete_response']=arm_response
+
+ return "",200
+
+# Arm the supervision callback with a response code
+# Omitting the query parameter switch to response back to the standard 200 response
+# URI and parameters (PUT): /arm/supervision/<producer_id>[?response=<resonsecode>]
+# response: 200 (400 if incorrect query params)
+@app.route(ARM_SUPERVISION_RESPONSE,
+ methods=['PUT'])
+def arm_supervision(producer_id):
+
+ arm_response=request.args.get('response')
+
+ if (arm_response is None):
+ if (len(request.args) != 0):
+ return UNKNOWN_QUERY_PARAMETERS,400
+ else:
+ if (len(request.args) != 1):
+ return UNKNOWN_QUERY_PARAMETERS,400
+
+ print("Arm supervision received for producer: "+str(producer_id)+" and response: "+str(arm_response))
+
+ producer_dict=setup_callback_dict(producer_id, None)
+ if (arm_response is None):
+ producer_dict['supervision_response']=200
+ else:
+ producer_dict['supervision_response']=arm_response
+
+ return "",200
+
+# Arm a producer with a type
+# URI and parameters (PUT): /arm/type/<string:producer_id>/<string:type-id>
+# response: 200 (404)
+@app.route(ARM_TYPE,
+ methods=['PUT'])
+def arm_type(producer_id, type_id):
+
+ print("Arm type received for producer: "+str(producer_id)+" and type: "+str(type_id))
+
+ producer_dict=get_callback_dict(producer_id, None)
+
+ if (producer_dict is None):
+ return PRODUCER_NOT_FOUND,404
+
+ type_list=producer_dict['types']
+ if (type_id not in type_list):
+ type_list.append(type_id)
+
+ return "",200
+
+# Disarm a producer with a type
+# URI and parameters (DELETE): /arm/type/<string:producer_id>/<string:type-id>
+# response: 200 (404)
+@app.route(ARM_TYPE,
+ methods=['DELETE'])
+def disarm_type(producer_id, type_id):
+
+ print("Disarm type received for producer: "+str(producer_id)+" and type: "+str(type_id))
+
+ producer_dict=get_callback_dict(producer_id, None)
+
+ if (producer_dict is None):
+ return PRODUCER_NOT_FOUND,404
+
+ if (recursive_search(producer_dict, "ei_job_type",type_id) is True):
+ return "TYPE_IN_USE",400
+
+ type_list=producer_dict['types']
+ type_list.remove(type_id)
+
+ return "",200
+
+# Callback for create job
+# URI and parameters (POST): /callbacks/create/<producer_id>
+# response 201 at create, 200 at update or other configured response code
+@app.route(CALLBACK_CREATE_URL,
+ methods=['POST'])
+def callback_create(producer_id):
+
+ req_json_dict=None
+ try:
+ req_json_dict = json.loads(request.data)
+ with open('job-schema.json') as f:
+ schema = json.load(f)
+ validate(instance=req_json_dict, schema=schema)
+ except Exception:
+ return JSON_CORRUPT,400
+
+ producer_dict=get_callback_dict(producer_id, None)
+ if (producer_dict is None):
+ return PRODUCER_OR_JOB_NOT_FOUND,400
+ type_list=producer_dict['types']
+ type_id=req_json_dict['ei_type_identity']
+ if (type_id not in type_list):
+ return TYPE_NOT_FOUND
+
+ job_id=req_json_dict['ei_job_identity']
+ job_dict=get_callback_dict(producer_id, job_id)
+ if (job_dict is None):
+ return PRODUCER_OR_JOB_NOT_FOUND,400
+ return_code=0
+ return_msg=""
+ if (req_json_dict['ei_job_identity'] == job_id):
+ print("Create callback received for producer: "+str(producer_id)+" and job: "+str(job_id))
+ return_code=job_dict['create_response']
+ if ((job_dict['create_response'] == 200) or (job_dict['create_response'] == 201)):
+ job_dict['json']=req_json_dict
+ if (job_dict['create_response'] == 201): #Set up next response code if create was ok
+ job_dict['create_response'] = 200
+ if (job_dict['delete_response'] == 404):
+ job_dict['delete_response'] = 204
+ else:
+ return_msg=RETURNING_CONFIGURED_RESP
+
+ job_dict['create_counter']=job_dict['create_counter']+1
+ else:
+ return JOBID_NO_MATCH, 400
+
+ return return_msg,return_code
+
+# Callback for delete job
+# URI and parameters (POST): /callbacks/delete/<producer_id>
+# response: 204 at delete or other configured response code
+@app.route(CALLBACK_DELETE_URL,
+ methods=['POST'])
+def callback_delete(producer_id):
+
+ req_json_dict=None
+ try:
+ req_json_dict = json.loads(request.data)
+ with open('job-schema.json') as f:
+ schema = json.load(f)
+ validate(instance=req_json_dict, schema=schema)
+ except Exception:
+ return JSON_CORRUPT,400
+
+ job_id=req_json_dict['ei_job_identity']
+ job_dict=get_callback_dict(producer_id, job_id)
+ if (job_dict is None):
+ return PRODUCER_OR_JOB_NOT_FOUND,400
+ return_code=0
+ return_msg=""
+ if (req_json_dict['ei_job_identity'] == job_id):
+ print("Delete callback received for producer: "+str(producer_id)+" and job: "+str(job_id))
+ return_code=job_dict['delete_response']
+ if (job_dict['delete_response'] == 204):
+ job_dict['json']=None
+ job_dict['delete_response']=404
+ if (job_dict['create_response'] == 200):
+ job_dict['create_response'] = 201 # reset create response if delete was ok
+ else:
+ return_msg=RETURNING_CONFIGURED_RESP
+
+ job_dict['delete_counter']=job_dict['delete_counter']+1
+ else:
+ return JOBID_NO_MATCH, 400
+
+ return return_msg, return_code
+
+# Callback for supervision of producer
+# URI and parameters (GET): /callbacks/supervision/<producer_id>
+# response: 200 or other configured response code
+@app.route(CALLBACK_SUPERVISION_URL,
+ methods=['GET'])
+def callback_supervision(producer_id):
+
+ print("Supervision callback received for producer: "+str(producer_id))
+
+ producer_dict=get_callback_dict(producer_id, None)
+ if (producer_dict is None):
+ return PRODUCER_NOT_FOUND,400
+ return_code=producer_dict['supervision_response']
+ return_msg=""
+ if (return_code != 200):
+ return_msg="returning configured response code"
+
+ producer_dict['supervision_counter']=producer_dict['supervision_counter']+1
+
+ return return_msg,producer_dict['supervision_response']
+
+# Callback for supervision of producer
+# URI and parameters (GET): "/jobdata/<string:producer_id>/<string:job_id>"
+# response: 200 or 204
+@app.route(JOB_DATA,
+ methods=['GET'])
+def get_jobdata(producer_id, job_id):
+
+ print("Get job data received for producer: "+str(producer_id)+" and job: "+str(job_id))
+
+ job_dict=setup_callback_dict(producer_id, job_id)
+ if (job_dict['json'] is None):
+ return "",204
+ else:
+ return json.dumps(job_dict['json']), 200
+
+
+# Counter for create calls for a job
+# URI and parameters (GET): "/counter/create/<string:producer_id>/<string:job_id>"
+# response: 200 and counter value
+@app.route(COUNTER_CREATE,
+ methods=['GET'])
+def counter_create(producer_id, job_id):
+ job_dict=get_callback_dict(producer_id, job_id)
+ if (job_dict is None):
+ return -1,200
+ return str(job_dict['create_counter']),200
+
+# Counter for delete calls for a job
+# URI and parameters (GET): "/counter/delete/<string:producer_id>/<string:job_id>"
+# response: 200 and counter value
+@app.route(COUNTER_DELETE,
+ methods=['GET'])
+def counter_delete(producer_id, job_id):
+ job_dict=get_callback_dict(producer_id, job_id)
+ if (job_dict is None):
+ return -1,200
+ return str(job_dict['delete_counter']),200
+
+# Counter for supervision calls for a producer
+# URI and parameters (GET): "/counter/supervision/<string:producer_id>"
+# response: 200 and counter value
+@app.route(COUNTER_SUPERVISION,
+ methods=['GET'])
+def counter_supervision(producer_id):
+ producer_dict=get_callback_dict(producer_id, None)
+ if (producer_dict is None):
+ return -1,200
+ return str(producer_dict['supervision_counter']),200
+
+# Get status info
+# URI and parameters (GET): "/status"
+# -
+@app.route(STATUS,
+ methods=['GET'])
+def status():
+ global db
+ return json.dumps(db),200
+
+
+# Reset db
+@app.route('/reset',
+ methods=['GET', 'POST', 'PUT'])
+def reset():
+ global db
+ db={}
+ return "",200
+
+### Main function ###
+
+if __name__ == "__main__":
+ app.run(port=HOST_PORT, host=HOST_IP)
diff --git a/test/prodstub/app/requirements.txt b/test/prodstub/app/requirements.txt
new file mode 100644
index 0000000..cc0dabf
--- /dev/null
+++ b/test/prodstub/app/requirements.txt
@@ -0,0 +1,3 @@
+Flask==1.1.1
+jsonschema==3.2.0
+
diff --git a/test/prodstub/app/start.sh b/test/prodstub/app/start.sh
new file mode 100755
index 0000000..21858c8
--- /dev/null
+++ b/test/prodstub/app/start.sh
@@ -0,0 +1,23 @@
+#!/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=================================================
+#
+
+#start nginx
+nginx -c /usr/src/app/nginx.conf
+
+#start mrstub
+python3 -u prodstub.py
diff --git a/test/prodstub/basic_test.sh b/test/prodstub/basic_test.sh
new file mode 100755
index 0000000..c0af24e
--- /dev/null
+++ b/test/prodstub/basic_test.sh
@@ -0,0 +1,54 @@
+#!/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=================================================
+#
+
+# Automated test script for producer stub container
+
+if [ $# -ne 1 ]; then
+ echo "Usage: ./basic_test.sh nonsecure|secure"
+ exit 1
+fi
+if [ "$1" != "nonsecure" ] && [ "$1" != "secure" ]; then
+ echo "Usage: ./basic_test.sh nonsecure|secure"
+ exit 1
+fi
+
+if [ $1 == "nonsecure" ]; then
+ #Default http port for the simulator
+ PORT=8092
+ # Set http protocol
+ HTTPX="http"
+else
+ #Default https port for the simulator
+ PORT=8093
+ # Set https protocol
+ HTTPX="https"
+fi
+
+# source function to do curl and check result
+. ../common/do_curl_function.sh
+
+echo "=== hello world ==="
+RESULT="OK"
+do_curl GET / 200
+
+
+
+echo "********************"
+echo "*** All tests ok ***"
+echo "********************"
diff --git a/test/prodstub/cert/cert.crt b/test/prodstub/cert/cert.crt
new file mode 100644
index 0000000..a24dfc4
--- /dev/null
+++ b/test/prodstub/cert/cert.crt
@@ -0,0 +1,16 @@
+-----BEGIN CERTIFICATE-----
+MIICljCCAX4CCQCv7SV/aTc/YjANBgkqhkiG9w0BAQsFADANMQswCQYDVQQGEwJT
+RTAeFw0yMDA1MDMwMDI0MzdaFw00NzA5MTgwMDI0MzdaMA0xCzAJBgNVBAYTAlNF
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApsGQcCv+Ce/+AbHx+3Wu
+ujGtWF7uLX+/MahOHPfdXqidwG7OpmYnGkL06cA52P0BcZdc1hPGQbQdFJC8aW6U
+5X9owRz9IRiwpzRhRqmMJfeqrLaqLL9K5MpCv+qsDzXu9ngRLJDk5CyeEfTjosEr
+GWDywWahQKHChamdH701djFGwWGP3gttGvQoMnaSpzeyDKitBZql6bSxKkhWgFop
+yxfU7qjbzOASLWaMx2r+MIJ88+AYDqYBTj649N534AYrIdjlQnvEKzGH0sOgHFYO
+oaTTvmE/vRPlmbSX1U7mo/SvMWNPZkKUPDltyapOpBltfMiRJH4ndLOXJWRgmYha
+SQIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQAdAwQpntpgUWUxCTk/Pw2+w5v+VxMM
+K6QWhm9JdRn3XKQnKrFexVRso/x8TA8V50EUGwQwbnKApNXvJsV2jvbP/YwDsG2u
+jBxs0DSspjDvbhUTkuWNYufQZIUGYMyccHap+CKD4rD2loMkmwbh5rII3SGEzUFE
+rOY4VhqDjGCcILbChiY/QMA6Uyb6jLGxTARhgblWi9RWr9LuKv7raaUcnAIz1GO8
+z559kUnOKbsB46RZKRa0uIumz9qqXqxnVLWnIwT3DinpXsnzcPqNyyhTk6XR+W5o
+0AuUCyT1WKlejrfMmmV6hRNHbT4x7cQrx4EjNf5hM00mN++F+QdGMa/G
+-----END CERTIFICATE-----
diff --git a/test/prodstub/cert/generate_cert_and_key.sh b/test/prodstub/cert/generate_cert_and_key.sh
new file mode 100755
index 0000000..0f79bbf
--- /dev/null
+++ b/test/prodstub/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/prodstub/cert/key.crt b/test/prodstub/cert/key.crt
new file mode 100644
index 0000000..105ee75
--- /dev/null
+++ b/test/prodstub/cert/key.crt
@@ -0,0 +1,30 @@
+-----BEGIN ENCRYPTED PRIVATE KEY-----
+MIIFHzBJBgkqhkiG9w0BBQ0wPDAbBgkqhkiG9w0BBQwwDgQIpz2Uxhl1+ZwCAggA
+MB0GCWCGSAFlAwQBKgQQu1or54X1Bk5IMPGoDrdxkASCBNCBKcePejHXlG0fb2qt
+TtQrpEr8UR60iFOaeUQ2Lc1zK0wzFCXAIXEWEcaozv75mJ5ReemkBMCyuzPJnoiM
+LTeKuoUw8l48S9arB9l+/vVgUnMY0fm+QDsnPffkXKxC2kNwwFgGCT7tIGezuo/e
+a9a5JJY707YEnkhUKWAQI2Oz/I95tbeYu64d/WtSN2OLu5JVLsCGAhV4cqcShjEb
+pFlfgOHrT0z+qK7YXVR9P74qAZtGsH2ydUrtPtdvddKRpOAm4LzDNmox4Bs6e9nr
+jY56sVRiHGhqeeqW04qRks5ReZF7zuwEgUSzGNlAcbbHn6FNJPOZKuN0e8KYexEM
+y0G04rSNW8qppMsvez6txsou62CeIZ5LyAumwaJJYzwkob0nCmWYcZl5tSpkXZly
+HsQKI2UlO3tiRKd057a46/kxcK85Pwav3Il+FaRXJkzl2rkU3DSy9SjaGL0ROD0U
+1EaZCjeDdzN2GmqRQ1WhN5ivowQyWVf6H/mrxtkWZ3qLKmpa1JmvUgOybPcbqqQr
+tqjj3Oj0zvLFZDqBjfIlTAAimXPgh6qLHH+qUGrI62pMpaldNZNy/swnpPuTX2sF
+TUxFZvnGOmG3qHyvPm91+PypbdVSMb0PeB75XQFqWmajwnua7xfWrH8PLSijp5xQ
+aLyiJ1jjFqXWE9D2v7JhB2BNCYlHxP98UI8kHxh7Fw5y0EKT5pCcbrg2nuLzMrCz
+D4QaxZRuiIiPgy21kowk3WbHLYAjG7f9cIcbbX6Khc/3ulbB8xJ24WNRuzv4EHeh
+TATHqk8nIgpkn1zmvPsKILdWzqZh70IlSctSzoIGzI6C2J76ycSZmcKtar2BZya9
+f1coUlFgXMvdmrf4bt4j2u/biA48OJaVlWBYVfIXUbliFTAQ8biRZFC2n3Xg+W8t
+U2xqW14lZWBOIQFJp27foG6Z4JzyL2WZgQ0PWe0m0+tDaKA/LSWB2Qpwt4o2n0cb
+RCs++c0eFCeOgErEfmmeburMhzQsfkUqpsL+J/ZMaRSiuTCpYM8qbz+KKT/Z6zbl
+2cHWxSFRIqRKAMsj2a61IANjNIdwi2uBHZrWH1HMVVXAbGUJQFKZhxdpn5PBrXqg
+vHRa9u0MQFCjs9NcQAGnBQDS6u+pUVO02WT4MvTker+hbu+f6NPU9FMLu+QbQUEP
+SUdEZL4W9ZuBTdS3n/fTHEL8wKRB5yEW/CS5JuD+8YinZZXrsd3n3Oky05fdk6Bk
+QH9cjMXdsd0Sb0Epw3CWGtXZ6YTHlVWqjdTNlOQdzQ7qfzktgcKujGwvQK0Mgd8x
+nmG+f/HWMOss0JEL3ZR+K9Rr50u8/R+W5+e4VE57yw1fg9Jpq2/sVe2Pt8S7isFK
+qDLoFZtF5RXi1O9KcA9BpnQX1ihPSC1RoY1pGXoF2D4KkV9U4/4j2qM6MGxjQ6lw
+MN0qJ/N70Lti3YWqvYiTymLwVJr8FqoMQsV19MB8012Xd51Bvy6igddhrO83wuuV
+b8PlUzl3Tl7yOviYqxiJ0xd8qw+Hs4+FkHbZIFJcUzTHVbb4SlPUE3wn6nrrIcfK
+rT4wsYhK3afrlvK3ILi6kzzazS1dK+Hv9+mNozNf5u5nNBFQ+7MhtttzLWIaiV6D
+ilLpOwcoO0X0qrzXKR7a+rQ/Dw==
+-----END ENCRYPTED PRIVATE KEY-----
diff --git a/test/prodstub/cert/pass b/test/prodstub/cert/pass
new file mode 100644
index 0000000..30d74d2
--- /dev/null
+++ b/test/prodstub/cert/pass
@@ -0,0 +1 @@
+test
\ No newline at end of file
diff --git a/test/prodstub/prod-stub-build-start.sh b/test/prodstub/prod-stub-build-start.sh
new file mode 100755
index 0000000..7f111b6
--- /dev/null
+++ b/test/prodstub/prod-stub-build-start.sh
@@ -0,0 +1,24 @@
+#!/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=================================================
+#
+
+#Builds the producer stub container and starts it in interactive mode
+
+docker build -t producer-stub .
+
+docker run -it -p 8092:8092 -p 8093:8093 --name producer-stub producer-stub