3 # ============LICENSE_START===============================================
4 # Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
20 # This is a script that contains specific test functions for ECS NB/SB API
22 . ../common/api_curl.sh
24 ############### EXPERIMENTAL #############
26 ##########################################
27 ###### Mainly only function skeletons ####
28 ##########################################
30 ##########################################
31 ### A1-E Enrichment Data Consumer API ####
32 ##########################################
33 #Function prefix: ecs_api_a1
35 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs
36 # args: <response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
37 # args (flat uri structure): <response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]
38 # (Function for test scripts)
39 ecs_api_a1_get_job_ids() {
40 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
41 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
44 if [ -z "$FLAT_A1_EI" ]; then
45 # Valid number of parameters 4,5,6 etc
47 __print_err "<response-code> <type-id> <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
51 echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
52 # Valid number of parameters 4,5,6 etc
54 __print_err "<response-code> <type-id>|NOTYPE <owner-id>|NOOWNER [ EMPTY | <job-id>+ ]" $@
59 if [ $3 != "NOWNER" ]; then
63 if [ -z "$FLAT_A1_EI" ]; then
64 query="/A1-EI/v1/eitypes/$2/eijobs$search"
66 if [ $2 != "NOTYPE" ]; then
67 if [ -z "$search" ]; then
70 search=$search"&eiTypeId="$2
73 query="/A1-EI/v1/eijobs$search"
75 res="$(__do_curl_to_api ECS GET $query)"
76 status=${res:${#res}-3}
78 if [ $status -ne $1 ]; then
79 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
86 body=${res:0:${#res}-3}
89 for pid in ${@:4} ; do
90 if [ "$targetJson" != "[" ]; then
91 targetJson=$targetJson","
93 if [ $pid != "EMPTY" ]; then
94 targetJson=$targetJson"\"$pid\""
98 targetJson=$targetJson"]"
99 echo " TARGET JSON: $targetJson" >> $HTTPLOG
100 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
102 if [ $res -ne 0 ]; then
103 echo -e $RED" FAIL, returned body not correct"$ERED
105 __check_stop_at_error
111 echo -e $GREEN" PASS"$EGREEN
115 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}
116 # args: <response-code> <type-id> [<schema-file>]
117 # (Function for test scripts)
118 ecs_api_a1_get_type() {
119 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
120 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
123 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
124 __print_err "<response-code> <type-id> [<schema-file>]" $@
128 query="/A1-EI/v1/eitypes/$2"
129 res="$(__do_curl_to_api ECS GET $query)"
130 status=${res:${#res}-3}
132 if [ $status -ne $1 ]; then
133 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
135 __check_stop_at_error
139 if [ $# -eq 3 ]; then
140 body=${res:0:${#res}-3}
144 echo -e $RED" FAIL. Schema file "$3", does not exist"$ERED
146 __check_stop_at_error
149 if [ -z "$FLAT_A1_EI" ]; then
150 targetJson="{\"eiJobParametersSchema\":$schema}"
154 echo " TARGET JSON: $targetJson" >> $HTTPLOG
155 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
157 if [ $res -ne 0 ]; then
158 echo -e $RED" FAIL, returned body not correct"$ERED
160 __check_stop_at_error
166 echo -e $GREEN" PASS"$EGREEN
170 # API Test function: GET /A1-EI/v1/eitypes
171 # args: <response-code> [ (EMPTY | [<type-id>]+) ]
172 # (Function for test scripts)
173 ecs_api_a1_get_type_ids() {
174 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
175 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
178 if [ $# -lt 1 ]; then
179 __print_err "<response-code> [ (EMPTY | [<type-id>]+) ]" $@
183 query="/A1-EI/v1/eitypes"
184 res="$(__do_curl_to_api ECS GET $query)"
185 status=${res:${#res}-3}
187 if [ $status -ne $1 ]; then
188 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
190 __check_stop_at_error
193 if [ $# -gt 1 ]; then
194 body=${res:0:${#res}-3}
196 if [ $2 != "EMPTY" ]; then
197 for pid in ${@:2} ; do
198 if [ "$targetJson" != "[" ]; then
199 targetJson=$targetJson","
201 targetJson=$targetJson"\"$pid\""
204 targetJson=$targetJson"]"
205 echo " TARGET JSON: $targetJson" >> $HTTPLOG
206 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
208 if [ $res -ne 0 ]; then
209 echo -e $RED" FAIL, returned body not correct"$ERED
211 __check_stop_at_error
217 echo -e $GREEN" PASS"$EGREEN
221 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}/status
222 # args: <response-code> <type-id> <job-id> [<status>]
223 # args (flat uri structure): <response-code> <job-id> [<status>]
224 # (Function for test scripts)
225 ecs_api_a1_get_job_status() {
226 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
227 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
230 if [ -z "$FLAT_A1_EI" ]; then
231 if [ $# -ne 3 ] && [ $# -ne 4 ]; then
232 __print_err "<response-code> <type-id> <job-id> [<status>]" $@
236 query="/A1-EI/v1/eitypes/$2/eijobs/$3/status"
238 res="$(__do_curl_to_api ECS GET $query)"
239 status=${res:${#res}-3}
241 if [ $status -ne $1 ]; then
242 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
244 __check_stop_at_error
247 if [ $# -eq 4 ]; then
248 body=${res:0:${#res}-3}
249 targetJson="{\"operationalState\": \"$4\"}"
250 echo " TARGET JSON: $targetJson" >> $HTTPLOG
251 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
253 if [ $res -ne 0 ]; then
254 echo -e $RED" FAIL, returned body not correct"$ERED
256 __check_stop_at_error
261 echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
262 if [ $# -ne 2 ] && [ $# -ne 3 ]; then
263 __print_err "<response-code> <job-id> [<status>]" $@
267 query="/A1-EI/v1/eijobs/$2/status"
269 res="$(__do_curl_to_api ECS GET $query)"
270 status=${res:${#res}-3}
272 if [ $status -ne $1 ]; then
273 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
275 __check_stop_at_error
278 if [ $# -eq 3 ]; then
279 body=${res:0:${#res}-3}
280 targetJson="{\"eiJobStatus\": \"$3\"}"
281 echo " TARGET JSON: $targetJson" >> $HTTPLOG
282 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
284 if [ $res -ne 0 ]; then
285 echo -e $RED" FAIL, returned body not correct"$ERED
287 __check_stop_at_error
294 echo -e $GREEN" PASS"$EGREEN
298 # API Test function: GET /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
299 # args: <response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]
300 # args (flat uri structure): <response-code> <job-id> [<type-id> <target-url> <owner-id> <template-job-file>]
301 # (Function for test scripts)
302 ecs_api_a1_get_job() {
303 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
304 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
307 if [ -z "$FLAT_A1_EI" ]; then
308 if [ $# -ne 3 ] && [ $# -ne 6 ]; then
309 __print_err "<response-code> <type-id> <job-id> [<target-url> <owner-id> <template-job-file>]" $@
312 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
314 echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
315 if [ $# -ne 2 ] && [ $# -ne 7 ]; then
316 __print_err "<response-code> <job-id> [<type-id> <target-url> <owner-id> <notification-url> <template-job-file>]" $@
319 query="/A1-EI/v1/eijobs/$2"
321 res="$(__do_curl_to_api ECS GET $query)"
322 status=${res:${#res}-3}
324 if [ $status -ne $1 ]; then
325 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
327 __check_stop_at_error
331 if [ -z "$FLAT_A1_EI" ]; then
332 if [ $# -eq 6 ]; then
333 body=${res:0:${#res}-3}
337 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
339 echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
341 __check_stop_at_error
344 targetJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
345 echo " TARGET JSON: $targetJson" >> $HTTPLOG
346 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
348 if [ $res -ne 0 ]; then
349 echo -e $RED" FAIL, returned body not correct"$ERED
351 __check_stop_at_error
356 if [ $# -eq 7 ]; then
357 body=${res:0:${#res}-3}
361 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
363 echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
365 __check_stop_at_error
368 targetJson="{\"eiTypeId\": \"$3\", \"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
369 echo " TARGET JSON: $targetJson" >> $HTTPLOG
370 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
372 if [ $res -ne 0 ]; then
373 echo -e $RED" FAIL, returned body not correct"$ERED
375 __check_stop_at_error
382 echo -e $GREEN" PASS"$EGREEN
386 # API Test function: DELETE /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
387 # args: <response-code> <type-id> <job-id>
388 # args (flat uri structure): <response-code> <job-id>
389 # (Function for test scripts)
390 ecs_api_a1_delete_job() {
391 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
392 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
395 if [ -z "$FLAT_A1_EI" ]; then
396 if [ $# -ne 3 ]; then
397 __print_err "<response-code> <type-id> <job-id>" $@
401 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
403 echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
404 if [ $# -ne 2 ]; then
405 __print_err "<response-code> <job-id>" $@
408 query="/A1-EI/v1/eijobs/$2"
410 res="$(__do_curl_to_api ECS DELETE $query)"
411 status=${res:${#res}-3}
413 if [ $status -ne $1 ]; then
414 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
416 __check_stop_at_error
421 echo -e $GREEN" PASS"$EGREEN
425 # API Test function: PUT /A1-EI/v1/eitypes/{eiTypeId}/eijobs/{eiJobId}
426 # args: <response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>
427 # args (flat uri structure): <response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>
428 # (Function for test scripts)
429 ecs_api_a1_put_job() {
430 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
431 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
434 if [ -z "$FLAT_A1_EI" ]; then
435 if [ $# -lt 6 ]; then
436 __print_err "<response-code> <type-id> <job-id> <target-url> <owner-id> <template-job-file>" $@
441 jobfile=$(echo "$jobfile" | sed "s/XXXX/$3/g")
443 echo -e $RED" FAIL. Job template file "$6", does not exist"$ERED
445 __check_stop_at_error
449 inputJson="{\"targetUri\": \"$4\",\"jobOwner\": \"$5\",\"jobParameters\": $jobfile}"
451 echo "$inputJson" > $file
453 query="/A1-EI/v1/eitypes/$2/eijobs/$3"
455 echo -e $YELLOW"USING NOT CONFIRMED INTERFACE - FLAT URI STRUCTURE"$EYELLOW
456 if [ $# -lt 7 ]; then
457 __print_err "<response-code> <job-id> <type-id> <target-url> <owner-id> <notification-url> <template-job-file>" $@
462 jobfile=$(echo "$jobfile" | sed "s/XXXX/$2/g")
464 echo -e $RED" FAIL. Job template file "$7", does not exist"$ERED
466 __check_stop_at_error
470 inputJson="{\"eiTypeId\": \"$3\", \"jobResultUri\": \"$4\",\"jobOwner\": \"$5\",\"jobStatusNotificationUri\": \"$6\",\"jobDefinition\": $jobfile}"
472 echo "$inputJson" > $file
474 query="/A1-EI/v1/eijobs/$2"
477 res="$(__do_curl_to_api ECS PUT $query $file)"
478 status=${res:${#res}-3}
480 if [ $status -ne $1 ]; then
481 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
483 __check_stop_at_error
488 echo -e $GREEN" PASS"$EGREEN
493 ##########################################
494 #### Enrichment Data Producer API ####
495 ##########################################
496 # Function prefix: ecs_api_edp
498 # API Test function: GET /ei-producer/v1/eitypes
499 # args: <response-code> [ EMPTY | <type-id>+]
500 # (Function for test scripts)
501 ecs_api_edp_get_type_ids() {
502 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
503 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
506 if [ $# -lt 1 ]; then
507 __print_err "<response-code> [ EMPTY | <type-id>+]" $@
511 query="/ei-producer/v1/eitypes"
512 res="$(__do_curl_to_api ECS GET $query)"
513 status=${res:${#res}-3}
515 if [ $status -ne $1 ]; then
516 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
518 __check_stop_at_error
522 if [ $# -gt 1 ]; then
523 body=${res:0:${#res}-3}
525 if [ $2 != "EMPTY" ]; then
526 for pid in ${@:2} ; do
527 if [ "$targetJson" != "[" ]; then
528 targetJson=$targetJson","
530 targetJson=$targetJson"\"$pid\""
533 targetJson=$targetJson"]"
534 echo " TARGET JSON: $targetJson" >> $HTTPLOG
535 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
537 if [ $res -ne 0 ]; then
538 echo -e $RED" FAIL, returned body not correct"$ERED
540 __check_stop_at_error
546 echo -e $GREEN" PASS"$EGREEN
550 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/status
551 # args: <response-code> <producer-id> [<status>]
552 # (Function for test scripts)
553 ecs_api_edp_get_producer_status() {
554 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
555 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
558 if [ $# -lt 2 ] || [ $# -gt 3 ]; then
559 __print_err "<response-code> <producer-id> [<status>]" $@
563 query="/ei-producer/v1/eiproducers/$2/status"
564 res="$(__do_curl_to_api ECS GET $query)"
565 status=${res:${#res}-3}
567 if [ $status -ne $1 ]; then
568 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
570 __check_stop_at_error
573 if [ $# -eq 3 ]; then
574 body=${res:0:${#res}-3}
575 targetJson="{\"operational_state\": \"$3\"}"
576 echo " TARGET JSON: $targetJson" >> $HTTPLOG
577 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
579 if [ $res -ne 0 ]; then
580 echo -e $RED" FAIL, returned body not correct"$ERED
582 __check_stop_at_error
588 echo -e $GREEN" PASS"$EGREEN
593 # API Test function: GET /ei-producer/v1/eiproducers
594 # args: <response-code> [ EMPTY | <producer-id>+]
595 # (Function for test scripts)
596 ecs_api_edp_get_producer_ids() {
597 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
598 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
601 if [ $# -lt 1 ]; then
602 __print_err "<response-code> [ EMPTY | <producer-id>+]" $@
606 query="/ei-producer/v1/eiproducers"
607 res="$(__do_curl_to_api ECS GET $query)"
608 status=${res:${#res}-3}
610 if [ $status -ne $1 ]; then
611 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
613 __check_stop_at_error
617 if [ $# -gt 1 ]; then
618 body=${res:0:${#res}-3}
621 for pid in ${@:2} ; do
622 if [ "$targetJson" != "[" ]; then
623 targetJson=$targetJson","
625 if [ $pid != "EMPTY" ]; then
626 targetJson=$targetJson"\"$pid\""
630 targetJson=$targetJson"]"
631 echo " TARGET JSON: $targetJson" >> $HTTPLOG
632 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
634 if [ $res -ne 0 ]; then
635 echo -e $RED" FAIL, returned body not correct"$ERED
637 __check_stop_at_error
643 echo -e $GREEN" PASS"$EGREEN
647 # API Test function: GET /ei-producer/v1/eitypes/{eiTypeId}
648 # args: <response-code> <type-id> [<job-schema-file> (EMPTY | [<producer-id>]+)]
649 # (Function for test scripts)
650 ecs_api_edp_get_type() {
651 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
652 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
656 if [ $# -eq 2 ]; then
659 if [ $# -gt 3 ]; then
662 if [ $paramError -ne 0 ]; then
663 __print_err "<response-code> <type-id> [<job-schema-file> 'EMPTY' | ([<producer-id>]+)]" $@
667 query="/ei-producer/v1/eitypes/$2"
668 res="$(__do_curl_to_api ECS GET $query)"
669 status=${res:${#res}-3}
671 if [ $status -ne $1 ]; then
672 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
674 __check_stop_at_error
677 if [ $# -gt 3 ]; then
678 body=${res:0:${#res}-3}
683 echo -e $RED" FAIL. Job template file "$3", does not exist"$ERED
685 __check_stop_at_error
690 if [ $4 != "EMPTY" ]; then
691 for pid in ${@:4} ; do
692 if [ "$targetJson" != "" ]; then
693 targetJson=$targetJson","
695 targetJson=$targetJson"\"$pid\""
698 targetJson="{\"ei_job_data_schema\":$schema, \"ei_producer_ids\": [$targetJson]}"
700 echo " TARGET JSON: $targetJson" >> $HTTPLOG
701 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
703 if [ $res -ne 0 ]; then
704 echo -e $RED" FAIL, returned body not correct"$ERED
706 __check_stop_at_error
711 echo -e $GREEN" PASS"$EGREEN
715 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}
716 # args: <response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (EMPTY | [<type-id> <schema-file>]+) ]
717 # (Function for test scripts)
718 ecs_api_edp_get_producer() {
719 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
720 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
723 #Possible arg count: 2, 6 7, 9, 11 etc
725 if [ $# -eq 2 ]; then
728 if [ $# -eq 6 ] && [ "$6" == "EMPTY" ]; then
731 variablecount=$(($#-5))
732 if [ $# -gt 5 ] && [ $(($variablecount%2)) -eq 0 ]; then
736 if [ $paramError -ne 0 ]; then
737 __print_err "<response-code> <producer-id> [<create-callback> <delete-callback> <supervision-callback> (NOID | [<type-id> <schema-file>]+) ]" $@
741 query="/ei-producer/v1/eiproducers/$2"
742 res="$(__do_curl_to_api ECS GET $query)"
743 status=${res:${#res}-3}
745 if [ $status -ne $1 ]; then
746 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
748 __check_stop_at_error
752 if [ $# -gt 2 ]; then
753 body=${res:0:${#res}-3}
755 if [ $# -gt 6 ]; then
757 for ((i=0; i<$(($#-6)); i=i+2)); do
758 if [ "$targetJson" != "[" ]; then
759 targetJson=$targetJson","
761 if [ -f ${arr[$i+1]} ]; then
762 schema=$(cat ${arr[$i+1]})
764 echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED
766 __check_stop_at_error
770 targetJson=$targetJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
773 targetJson=$targetJson"]"
774 if [ $# -gt 4 ]; then
775 targetJson="{\"supported_ei_types\":$targetJson,\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\"}"
777 echo " TARGET JSON: $targetJson" >> $HTTPLOG
778 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
780 if [ $res -ne 0 ]; then
781 echo -e $RED" FAIL, returned body not correct"$ERED
783 __check_stop_at_error
789 echo -e $GREEN" PASS"$EGREEN
793 # API Test function: DELETE /ei-producer/v1/eiproducers/{eiProducerId}
794 # args: <response-code> <producer-id>
795 # (Function for test scripts)
796 ecs_api_edp_delete_producer() {
797 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
798 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
801 if [ $# -lt 2 ]; then
802 __print_err "<response-code> <producer-id>" $@
806 query="/ei-producer/v1/eiproducers/$2"
807 res="$(__do_curl_to_api ECS DELETE $query)"
808 status=${res:${#res}-3}
810 if [ $status -ne $1 ]; then
811 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
813 __check_stop_at_error
818 echo -e $GREEN" PASS"$EGREEN
822 # API Test function: PUT /ei-producer/v1/eiproducers/{eiProducerId}
823 # args: <response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> NOTYPE|[<type-id> <schema-file>]+
824 # (Function for test scripts)
825 ecs_api_edp_put_producer() {
826 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
827 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
830 #Valid number of parametrer 6,7,9,11,
832 if [ $# -eq 6 ] && [ "$6" == "NOTYPE" ]; then
834 elif [ $# -gt 6 ] && [ $(($#%2)) -eq 1 ]; then
837 if [ $paramError -ne 0 ]; then
838 __print_err "<response-code> <producer-id> <create-callback> <delete-callback> <supervision-callback> [<type-id> <schema-file>]+" $@
843 if [ $# -gt 6 ]; then
845 for ((i=0; i<$(($#-6)); i=i+2)); do
846 if [ "$inputJson" != "[" ]; then
847 inputJson=$inputJson","
849 if [ -f ${arr[$i+1]} ]; then
850 schema=$(cat ${arr[$i+1]})
852 echo -e $RED" FAIL. Schema file "${arr[$i+1]}", does not exist"$ERED
854 __check_stop_at_error
857 inputJson=$inputJson"{\"ei_type_identity\":\"${arr[$i]}\",\"ei_job_data_schema\":$schema}"
860 inputJson="\"supported_ei_types\":"$inputJson"]"
862 inputJson=$inputJson",\"ei_job_creation_callback_url\": \"$3\",\"ei_job_deletion_callback_url\": \"$4\",\"ei_producer_supervision_callback_url\": \"$5\""
864 inputJson="{"$inputJson"}"
867 echo "$inputJson" > $file
868 query="/ei-producer/v1/eiproducers/$2"
869 res="$(__do_curl_to_api ECS PUT $query $file)"
870 status=${res:${#res}-3}
872 if [ $status -ne $1 ]; then
873 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
875 __check_stop_at_error
880 echo -e $GREEN" PASS"$EGREEN
884 # API Test function: GET /ei-producer/v1/eiproducers/{eiProducerId}/eijobs
885 # args: <response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)
886 # (Function for test scripts)
887 ecs_api_edp_get_producer_jobs() {
888 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
889 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
892 #Valid number of parameter 2,3,6,10
894 if [ $# -eq 2 ]; then
897 if [ $# -eq 3 ] && [ "$3" == "EMPTY" ]; then
900 variablecount=$(($#-2))
901 if [ $# -gt 3 ] && [ $(($variablecount%4)) -eq 0 ]; then
904 if [ $paramError -eq 1 ]; then
905 __print_err "<response-code> <producer-id> (EMPTY | [<job-id> <type-id> <target-url> <template-job-file>]+)" $@
909 query="/ei-producer/v1/eiproducers/$2/eijobs"
910 res="$(__do_curl_to_api ECS GET $query)"
911 status=${res:${#res}-3}
912 if [ $status -ne $1 ]; then
913 echo -e $RED" FAIL. Exepected status "$1", got "$status $ERED
915 __check_stop_at_error
918 if [ $# -gt 2 ]; then
919 body=${res:0:${#res}-3}
921 if [ $# -gt 3 ]; then
923 for ((i=0; i<$(($#-3)); i=i+4)); do
924 if [ "$targetJson" != "[" ]; then
925 targetJson=$targetJson","
927 if [ -f ${arr[$i+3]} ]; then
928 jobfile=$(cat ${arr[$i+3]})
929 jobfile=$(echo "$jobfile" | sed "s/XXXX/${arr[$i]}/g")
931 echo -e $RED" FAIL. Job template file "${arr[$i+3]}", does not exist"$ERED
933 __check_stop_at_error
936 targetJson=$targetJson"{\"ei_job_identity\":\"${arr[$i]}\",\"ei_type_identity\":\"${arr[$i+1]}\",\"target_uri\":\"${arr[$i+2]}\",\"ei_job_data\":$jobfile}"
939 targetJson=$targetJson"]"
941 echo " TARGET JSON: $targetJson" >> $HTTPLOG
942 res=$(python3 ../common/compare_json.py "$targetJson" "$body")
944 if [ $res -ne 0 ]; then
945 echo -e $RED" FAIL, returned body not correct"$ERED
947 __check_stop_at_error
953 echo -e $GREEN" PASS"$EGREEN
958 ##########################################
959 #### Service status ####
960 ##########################################
961 # Function prefix: ecs_api_service
963 # API Test function: GET /status
964 # args: <response-code>
965 # (Function for test scripts)
966 ecs_api_service_status() {
967 echo -e $BOLD"TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ $EBOLD
968 echo "TEST(${BASH_LINENO[0]}): ${FUNCNAME[0]}" $@ >> $HTTPLOG
971 if [ $# -lt 1 ]; then
972 __print_err "<response-code> [<producer-id>]*|NOID" $@
977 echo -e $GREEN" PASS"$EGREEN