From b610d2dbfa445e2ed8fd7f9976ae7a776666d630 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Wed, 19 Jul 2017 15:14:29 +0530 Subject: Add seed code from Open-O It migrated the code from Open-O into onap namespace and adds the required framework, main, deployment and some sample plugins for msb. CLI-7 CLI-8 CLI-11 Change-Id: I499e34237daccb971ef74bd10e50f50707baa4d3 Signed-off-by: Kanagaraj Manickam k00365106 --- .../META-INF/services/org.onap.cli.fw.OnapCommand | 1 + .../onap-cli-schema/sample-test1-schema-http.yaml | 91 ++++++++++++ framework/src/test/resources/onap-test-schema.yaml | 81 +++++++++++ framework/src/test/resources/onap.properties | 4 + .../src/test/resources/sample-cmd-test-help.txt | 72 ++++++++++ ...e-test-invalid-schema-duplicate-longoption.yaml | 78 +++++++++++ .../sample-test-invalid-schema-duplicate-name.yaml | 85 ++++++++++++ ...-test-invalid-schema-duplicate-shortoption.yaml | 79 +++++++++++ .../test/resources/sample-test-invalid-schema.yaml | 78 +++++++++++ .../test/resources/sample-test-schema-http.yaml | 90 ++++++++++++ .../test/resources/sample-test-schema-swagger.yaml | 26 ++++ .../src/test/resources/sample-test-schema.yaml | 82 +++++++++++ .../test/resources/schema-invalid-file-null.yaml | 0 .../src/test/resources/schema-invalid-file.yaml | 6 + .../src/test/resources/schema-validate-basic.yaml | 68 +++++++++ .../src/test/resources/schema-validate-http.yaml | 89 ++++++++++++ .../test/resources/schema-validate-invalid.yaml | 151 ++++++++++++++++++++ .../schema-validate-invalidschematype.yaml | 88 ++++++++++++ .../src/test/resources/schema-validate-pass.yaml | 153 +++++++++++++++++++++ 19 files changed, 1322 insertions(+) create mode 100644 framework/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand create mode 100644 framework/src/test/resources/onap-cli-schema/sample-test1-schema-http.yaml create mode 100644 framework/src/test/resources/onap-test-schema.yaml create mode 100644 framework/src/test/resources/onap.properties create mode 100644 framework/src/test/resources/sample-cmd-test-help.txt create mode 100644 framework/src/test/resources/sample-test-invalid-schema-duplicate-longoption.yaml create mode 100644 framework/src/test/resources/sample-test-invalid-schema-duplicate-name.yaml create mode 100644 framework/src/test/resources/sample-test-invalid-schema-duplicate-shortoption.yaml create mode 100644 framework/src/test/resources/sample-test-invalid-schema.yaml create mode 100644 framework/src/test/resources/sample-test-schema-http.yaml create mode 100644 framework/src/test/resources/sample-test-schema-swagger.yaml create mode 100644 framework/src/test/resources/sample-test-schema.yaml create mode 100644 framework/src/test/resources/schema-invalid-file-null.yaml create mode 100644 framework/src/test/resources/schema-invalid-file.yaml create mode 100644 framework/src/test/resources/schema-validate-basic.yaml create mode 100644 framework/src/test/resources/schema-validate-http.yaml create mode 100644 framework/src/test/resources/schema-validate-invalid.yaml create mode 100644 framework/src/test/resources/schema-validate-invalidschematype.yaml create mode 100644 framework/src/test/resources/schema-validate-pass.yaml (limited to 'framework/src/test/resources') diff --git a/framework/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand b/framework/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand new file mode 100644 index 00000000..a01b9d53 --- /dev/null +++ b/framework/src/test/resources/META-INF/services/org.onap.cli.fw.OnapCommand @@ -0,0 +1 @@ +org.onap.cli.cmd.sample.OnapCommandSample \ No newline at end of file diff --git a/framework/src/test/resources/onap-cli-schema/sample-test1-schema-http.yaml b/framework/src/test/resources/onap-cli-schema/sample-test1-schema-http.yaml new file mode 100644 index 00000000..18a7bb16 --- /dev/null +++ b/framework/src/test/resources/onap-cli-schema/sample-test1-schema-http.yaml @@ -0,0 +1,91 @@ +onap_cmd_schema_version: 1.0 +name: sample-test1 +description: Onap sample command to test the command features +service: + name: sample + version: v1 +parameters: + - name: bool-param + type: bool + description: Onap boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: secure-param + type: string + description: Onap secure param such as password + short_option: x + long_option: secure + is_secured: true + is_optional: false + default_Value: pass123# + - name: string-param + type: string + description: Onap string param + long_option: string-param + short_option: c + is_optional: false + default_Value: test + - name: yaml-param + type: json + description: Onap yaml file location param + long_option: yaml-param + short_option: y + is_optional: false + - name: json-param + type: json + description: Onap json file location param + long_option: json-param + short_option: j + is_optional: false + - name: long-param + type: long + description: Onap long param + short_option: l + long_option: long-opt + is_optional: false + default_value: 10 + - name: url-param + type: url + description: Onap url param + short_option: r + long_option: url + is_optional: false + default_value: http://localhost:8082/file.txt + - name: env-param + type: string + description: Onap env param. + short_option: z + long_option: env + is_optional: false + default_value: ${ENV_VAR} + - name: positional-args + type: string + description: Onap positional args, if no short option and no long option given for it + is_optional: false + default_value: http://localhost:8082/file.txt +http: + request: + uri: /vims + method: POST + body: '{"name":"${name}","vendor":"${vendor}","version":"${vim-version}","description":"${description}","type":"${type}","url":"${url}","userName":"${username}","password":"${password}","domain":"${domain}","tenant":"${tenant}"}' + headers: + success_codes: + - 201 + - 200 + result_map: + id: $b{$.vimId} + name: $b{$.name} + vendor: $b{$.vendor} + type: $b{$.type} + version: $b{$.version} + url: $b{$.url} + description: $b{$.description} + username: $b{$.userName} + password: $b{$.password} + domain: $b{$.domain} + tenant: $b{$.tenant} + create-time: $b{$.createTime} + sample_response: + body:'{"id":"string","name":"string","vendor":"string","version":"string","description":"string","type":"string","createTime":"string","url":"string","userName":"string","password":"string","domain":"string","tenant":"string"}' \ No newline at end of file diff --git a/framework/src/test/resources/onap-test-schema.yaml b/framework/src/test/resources/onap-test-schema.yaml new file mode 100644 index 00000000..df260502 --- /dev/null +++ b/framework/src/test/resources/onap-test-schema.yaml @@ -0,0 +1,81 @@ +onap_cmd_schema_version: 1.0 +name: sample-test +description: Onap sample command to test the command features +service: + name: sample + version: v1 + no-auth: true +parameters: + - name: bool-param + type: bool + description: Onap boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: secure-param + type: string + description: Onap secure param such as password + short_option: x + long_option: secure + is_secured: true + is_optional: false + default_Value: pass123# + - name: string-param + type: string + description: Onap string param + long_option: string-param + short_option: c + is_optional: false + default_Value: test + - name: yaml-param + type: json + description: Onap yaml file location param + long_option: yaml-param + short_option: y + is_optional: false + - name: json-param + type: json + description: Onap json file location param + long_option: json-param + short_option: j + is_optional: false + - name: long-param + type: long + description: Onap long param + short_option: l + long_option: long-opt + is_optional: false + default_value: 10 + - name: url-param + type: url + description: Onap url param + short_option: r + long_option: url + is_optional: false + default_value: http://localhost:8082/file.txt + - name: env-param + type: string + description: Onap env param. + short_option: z + long_option: env + is_optional: false + default_value: ${ENV_VAR} + - name: positional-args + type: string + description: Onap positional args, if no short option and no long option given for it + is_optional: false + default_value: http://localhost:8082/file.txt +results: + direction: portrait + attributes: + - name: output-1 + description: Onap output attribute marked in short + scope: short + type: string + is_secured: true + - name: output-2 + description: Onap output attribute marked in long + scope: short + is_secured: false + type: string \ No newline at end of file diff --git a/framework/src/test/resources/onap.properties b/framework/src/test/resources/onap.properties new file mode 100644 index 00000000..3b185174 --- /dev/null +++ b/framework/src/test/resources/onap.properties @@ -0,0 +1,4 @@ +cli.ignore_auth=true +cli.version=1.0 +http.api_key=X-Auth-Token +http.api_key_use_cookies=true \ No newline at end of file diff --git a/framework/src/test/resources/sample-cmd-test-help.txt b/framework/src/test/resources/sample-cmd-test-help.txt new file mode 100644 index 00000000..d8ce1ef5 --- /dev/null +++ b/framework/src/test/resources/sample-cmd-test-help.txt @@ -0,0 +1,72 @@ +usage: onap sample-test + +Onap sample command to test the command features + +Onap service: sample v1 + +Options: +[-u | --onap-username] [-p | --onap-password] [-m | --msb-url] +[-h | --help] [-v | --version] [-d | --debug] +[-f | --format] [-s | --long] [-t | --no-title] +[-a | --no-auth] [-b | --bool] [-x | --secure] +[-c | --string-param] [-y | --yaml-param] [-j | --json-param] +[-l | --long-opt] [-r | --url] [-z | --env] + +where, +-u | --onap-username Onap user name. It is of type STRING. By + default, it is read from environment variable + ONAP_USERNAME. +-p | --onap-password Onap user password. It is of type STRING. By + default, it is read from environment variable + ONAP_PASSWORD. Secured. +-m | --msb-url Onap MSB url. It is of type URL. By default, it + is read from environment variable ONAP_MSB_URL. +-h | --help Onap command help message. It is of type STRING. + By default, it is false. +-v | --version Onap command service version. It is of type + STRING. By default, it is false. +-d | --debug Enable debug output. It is of type BOOL. By + default, it is false. +-f | --format Output formats, supported formats such as table, + csv, json, yaml. It is of type STRING. By default, + it is table. +-s | --long whether to print all attributes or only short + attributes. It is of type BOOL. By default, it is + false. +-t | --no-title whether to print title or not. It is of type BOOL. + By default, it is false. +-a | --no-auth whether to authenticate user or not. It is of type + BOOL. By default, it is false. +-b | --bool Onap boolean param, by default its always false. + It is of type BOOL. It is optional. By default, it + is false. +-x | --secure Onap secure param such as password. It is of + type STRING. Secured. +-c | --string-param Onap string param. It is of type STRING. +-y | --yaml-param Onap yaml file location param. It is of type + JSON. It's recommended to input the complete path + of the file, which is having the value for it. +-j | --json-param Onap json file location param. It is of type + JSON. It's recommended to input the complete path + of the file, which is having the value for it. +-l | --long-opt Onap long param. It is of type LONG. By default, + it is 10. +-r | --url Onap url param. It is of type URL. By default, + it is http://localhost:8082/file.txt. +-z | --env Onap env param. It is of type STRING. By + default, it is read from environment variable + ENV_VAR. +positional-args Onap positional args, if no short option and no + long option given for it. It is of type STRING. By + default, it is http://localhost:8082/file.txt. + + +Results: +output-1 Onap output attribute marked in short and is of + type STRING. It is secured. +output-2 Onap output attribute marked in long and is of + type STRING. + + +Error: +On error, it prints :::: diff --git a/framework/src/test/resources/sample-test-invalid-schema-duplicate-longoption.yaml b/framework/src/test/resources/sample-test-invalid-schema-duplicate-longoption.yaml new file mode 100644 index 00000000..8761bb30 --- /dev/null +++ b/framework/src/test/resources/sample-test-invalid-schema-duplicate-longoption.yaml @@ -0,0 +1,78 @@ +onap_cmd_schema_version: 1.0 +name: sample-test +description: Onap sample command to test the command features +service: + name: sample + version: v1 +parameters: + - name: bool-param + type: bool + description: Onap boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: secure-param + type: string + description: Onap secure param such as password + short_option: x + long_option: secure + is_secured: true + is_optional: false + default_Value: pass123# + - name: string-param + type: string + description: Onap string param + long_option: secure + short_option: c + is_optional: false + default_Value: test + - name: yaml-param + type: json + description: Onap yaml file location param + long_option: yaml-param + short_option: y + is_optional: false + - name: json-param + type: json + description: Onap json file location param + long_option: json-param + short_option: j + is_optional: false + - name: long-param + type: long + description: Onap long param + short_option: l + long_option: long-opt + is_optional: false + default_value: 10 + - name: url-param + type: url + description: Onap url param + short_option: r + long_option: url + is_optional: false + default_value: http://localhost:8082/file.txt + - name: env-param + type: string + description: Onap env param. + short_option: z + long_option: env + is_optional: false + default_value: ${ENV_VAR} + - name: positional-args + type: string + description: Onap positional args, if no short option and no long option given for it + is_optional: false + default_value: http://localhost:8082/file.txt +results: + direction: portrait + attributes: + - name: output-1 + description: Onap output attribute marked in short + scope: short + type: string + - name: output-2 + description: Onap output attribute marked in long + scope: short + type: string \ No newline at end of file diff --git a/framework/src/test/resources/sample-test-invalid-schema-duplicate-name.yaml b/framework/src/test/resources/sample-test-invalid-schema-duplicate-name.yaml new file mode 100644 index 00000000..df4ed316 --- /dev/null +++ b/framework/src/test/resources/sample-test-invalid-schema-duplicate-name.yaml @@ -0,0 +1,85 @@ +onap_cmd_schema_version: 1.0 +name: sample-test +description: Onap sample command to test the command features +service: + name: sample + version: v1 +parameters: + - name: bool-param + type: bool + description: Onap boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: bool-param + type: bool + description: Onap boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: secure-param + type: string + description: Onap secure param such as password + short_option: x + long_option: secure + is_secured: true + is_optional: false + default_Value: pass123# + - name: string-param + type: string + description: Onap string param + long_option: string-param + short_option: c + is_optional: false + default_Value: test + - name: yaml-param + type: json + description: Onap yaml file location param + long_option: yaml-param + short_option: y + is_optional: false + - name: json-param + type: json + description: Onap json file location param + long_option: json-param + short_option: j + is_optional: false + - name: long-param + type: long + description: Onap long param + short_option: l + long_option: long-opt + is_optional: false + default_value: 10 + - name: url-param + type: url + description: Onap url param + short_option: r + long_option: url + is_optional: false + default_value: http://localhost:8082/file.txt + - name: env-param + type: string + description: Onap env param. + short_option: z + long_option: env + is_optional: false + default_value: ${ENV_VAR} + - name: positional-args + type: string + description: Onap positional args, if no short option and no long option given for it + is_optional: false + default_value: http://localhost:8082/file.txt +results: + direction: portrait + attributes: + - name: output-1 + description: Onap output attribute marked in short + scope: short + type: string + - name: output-2 + description: Onap output attribute marked in long + scope: short + type: string \ No newline at end of file diff --git a/framework/src/test/resources/sample-test-invalid-schema-duplicate-shortoption.yaml b/framework/src/test/resources/sample-test-invalid-schema-duplicate-shortoption.yaml new file mode 100644 index 00000000..519f6e3b --- /dev/null +++ b/framework/src/test/resources/sample-test-invalid-schema-duplicate-shortoption.yaml @@ -0,0 +1,79 @@ +onap_cmd_schema_version: 1.0 +name: sample-test +description: Onap sample command to test the command features +service: + name: sample + version: v1 +parameters: + - name: bool-param + type: bool + description: Onap boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: secure-param + type: string + description: Onap secure param such as password + short_option: x + short_option: y + long_option: secure + is_secured: true + is_optional: false + default_Value: pass123# + - name: string-param + type: string + description: Onap string param + long_option: string-param + short_option: c + is_optional: false + default_Value: test + - name: yaml-param + type: json + description: Onap yaml file location param + long_option: yaml-param + short_option: y + is_optional: false + - name: json-param + type: json + description: Onap json file location param + long_option: json-param + short_option: j + is_optional: false + - name: long-param + type: long + description: Onap long param + short_option: l + long_option: long-opt + is_optional: false + default_value: 10 + - name: url-param + type: url + description: Onap url param + short_option: r + long_option: url + is_optional: false + default_value: http://localhost:8082/file.txt + - name: env-param + type: string + description: Onap env param. + short_option: z + long_option: env + is_optional: false + default_value: ${ENV_VAR} + - name: positional-args + type: string + description: Onap positional args, if no short option and no long option given for it + is_optional: false + default_value: http://localhost:8082/file.txt +results: + direction: portrait + attributes: + - name: output-1 + description: Onap output attribute marked in short + scope: short + type: string + - name: output-2 + description: Onap output attribute marked in long + scope: short + type: string \ No newline at end of file diff --git a/framework/src/test/resources/sample-test-invalid-schema.yaml b/framework/src/test/resources/sample-test-invalid-schema.yaml new file mode 100644 index 00000000..ed21772c --- /dev/null +++ b/framework/src/test/resources/sample-test-invalid-schema.yaml @@ -0,0 +1,78 @@ +onap_cmd_schema_version: 1.0 +name: sample-test +description: Onap sample command to test the command features +service: + name: sample + version: v1 +parameters: + -- name: bool-param + type: bool + description: Onap boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: secure-param + type: string + description: Onap secure param such as password + short_option: x + long_option: secure + is_secured: true + is_optional: false + default_Value: pass123# + - name: string-param + type: string + description: Onap string param + long_option: string-param + short_option: c + is_optional: false + default_Value: test + - name: yaml-param + type: json + description: Onap yaml file location param + long_option: yaml-param + short_option: y + is_optional: false + - name: json-param + type: json + description: Onap json file location param + long_option: json-param + short_option: j + is_optional: false + - name: long-param + type: long + description: Onap long param + short_option: l + long_option: long-opt + is_optional: false + default_value: 10 + - name: url-param + type: url + description: Onap url param + short_option: r + long_option: url + is_optional: false + default_value: http://localhost:8082/file.txt + - name: env-param + type: string + description: Onap env param. + short_option: z + long_option: env + is_optional: false + default_value: ${ENV_VAR} + - name: positional-args + type: string + description: Onap positional args, if no short option and no long option given for it + is_optional: false + default_value: http://localhost:8082/file.txt +results: + direction: portrait + attributes: + - name: output-1 + description: Onap output attribute marked in short + scope: short + type: string + - name: output-2 + description: Onap output attribute marked in long + scope: short + type: string \ No newline at end of file diff --git a/framework/src/test/resources/sample-test-schema-http.yaml b/framework/src/test/resources/sample-test-schema-http.yaml new file mode 100644 index 00000000..7bbf6775 --- /dev/null +++ b/framework/src/test/resources/sample-test-schema-http.yaml @@ -0,0 +1,90 @@ +onap_cmd_schema_version: 1.0 +name: sample-create-http +description: Register microservice into Onap +service: + name: msb + version: v1 +parameters: + - name: service-name + description: Onap service name + type: string + short_option: x + long_option: service-name + is_optional: false + - name: service-version + description: Onap service version + type: string + short_option: y + long_option: service-version + is_optional: false + - name: service-url + description: Onap service base url + type: url + short_option: r + long_option: service-url + is_optional: false + - name: status + description: Onap service status + type: long + short_option: z + long_option: service-status + is_optional: true + default_value: 1 + - name: node-ip + description: Onap service running node IP + type: string + - name: node-port + description: Onap service running node port + type: string + - name: create-or-update + description: Onap service create or update + type: bool + default_value: true +results: + direction: portrait + attributes: + - name: name + description: Onap service name + scope: short + type: string + - name: version + description: Onap service version + scope: short + type: string + - name: url + description: Onap service base url + scope: short + type: url + - name: status + description: Onap service status + scope: short + type: long + - name: nodes + description: Onap service running nodes + scope: long + type: string + - name: location + description: Onap service location + scope: long + type: url +http: + request: + uri: /services + method: POST + body: '{"serviceName":"${service-name}","version":"${service-version}","url":"${service-url}","protocol":"REST","visualRange":"1","lb_policy":"hash","nodes":[{"ip":"${node-ip}","port":"${node-port}","ttl":0}]}' + headers: + queries: + createOrUpdate: ${create-or-update} + success_codes: + - 201 + - 200 + result_map: + name: $b{$.serviceName} + version: $b{$.version} + url: $b{$.url} + status: $b{$.status} + nodes: $b{$.nodes[*].ip}:$b{$.nodes[*].port} + location: $h{Location} + + sample_response: + body: {"serviceName":"test","version":"v1","url":"/api/test/v1","protocol":"REST","visualRange":"1","lb_policy":"hash","nodes":[{"ip":"127.0.0.1","port":"8012","ttl":0,"nodeId":"test_127.0.0.1_8012","expiration":"2017-02-10T05:33:25Z","created_at":"2017-02-10T05:33:25Z","updated_at":"2017-02-10T05:33:25Z"}],"status":"1"} \ No newline at end of file diff --git a/framework/src/test/resources/sample-test-schema-swagger.yaml b/framework/src/test/resources/sample-test-schema-swagger.yaml new file mode 100644 index 00000000..c88ddb7a --- /dev/null +++ b/framework/src/test/resources/sample-test-schema-swagger.yaml @@ -0,0 +1,26 @@ +onap_cmd_schema_version: 1.0 +name: sample-test-swagger +description: Sample swagger command test. +service: + name: sample + version: v1 +parameters: + - name: user + type: string + description: Onap user + short_option: n + long_option: username + is_optional: false +results: + direction: portrait + attributes: + - name: name + description: Onap user + scope: short + type: string +exec: + api: org.onap.common_services.auth.auth_service.client.api.DefaultApi + client: org.onap.common_services.auth.auth_service.client.invoker.ApiClient + entity: org.onap.common_services.auth.auth_service.client.model.User, username(userName), password, description + method: create + exception: org.onap.common_services.auth.auth_service.client.invoker.ApiException \ No newline at end of file diff --git a/framework/src/test/resources/sample-test-schema.yaml b/framework/src/test/resources/sample-test-schema.yaml new file mode 100644 index 00000000..a480147d --- /dev/null +++ b/framework/src/test/resources/sample-test-schema.yaml @@ -0,0 +1,82 @@ +onap_cmd_schema_version: 1.0 +name: sample-test +description: Onap sample command to test the command features +service: + name: sample + version: v1 + no-auth: true +parameters: + - name: bool-param + type: bool + description: Onap boolean param, by default its always false. + short_option: b + long_option: bool + is_optional: true + default_value: false + - name: secure-param + type: string + description: Onap secure param such as password + short_option: x + long_option: secure + is_secured: true + is_optional: false + default_Value: pass123# + - name: string-param + type: string + description: Onap string param + long_option: string-param + short_option: c + is_optional: false + default_Value: test + - name: yaml-param + type: json + description: Onap yaml file location param + long_option: yaml-param + short_option: y + is_optional: false + - name: json-param + type: json + description: Onap json file location param + long_option: json-param + short_option: j + is_optional: false + is_secured: false + - name: long-param + type: long + description: Onap long param + short_option: l + long_option: long-opt + is_optional: false + default_value: 10 + - name: url-param + type: url + description: Onap url param + short_option: r + long_option: url + is_optional: false + default_value: http://localhost:8082/file.txt + - name: env-param + type: string + description: Onap env param. + short_option: z + long_option: env + is_optional: false + default_value: ${ENV_VAR} + - name: positional-args + type: string + description: Onap positional args, if no short option and no long option given for it + is_optional: false + default_value: http://localhost:8082/file.txt +results: + direction: portrait + attributes: + - name: output-1 + description: Onap output attribute marked in short + scope: short + type: string + is_secured: true + - name: output-2 + description: Onap output attribute marked in long + scope: short + is_secured: false + type: string \ No newline at end of file diff --git a/framework/src/test/resources/schema-invalid-file-null.yaml b/framework/src/test/resources/schema-invalid-file-null.yaml new file mode 100644 index 00000000..e69de29b diff --git a/framework/src/test/resources/schema-invalid-file.yaml b/framework/src/test/resources/schema-invalid-file.yaml new file mode 100644 index 00000000..7b5937d5 --- /dev/null +++ b/framework/src/test/resources/schema-invalid-file.yaml @@ -0,0 +1,6 @@ +onap_cmd_schema_version: 1.0 +description: Register microservice into Onap +name: schema-validate +service:dasd + name: msbdsa + - name: service-name1 \ No newline at end of file diff --git a/framework/src/test/resources/schema-validate-basic.yaml b/framework/src/test/resources/schema-validate-basic.yaml new file mode 100644 index 00000000..80a9e1c6 --- /dev/null +++ b/framework/src/test/resources/schema-validate-basic.yaml @@ -0,0 +1,68 @@ +onap_cmd_schema_version: 1.0 +description: Register microservice into Onap +name: schema-validate +service: + name: msb +parameters: + - name: service-name1 + description: Onap service name + type: string + short_option: x + long_option: service-name + is_optional: false + - name: service-version + description: Onap service version + type: string + short_option: x + long_option: service-version + is_optional: false + - name: service-url + description: Onap service base url + type: url1 + short_option: u + long_option: service-url + is_optional: false1 + - name: status + description: Onap service status + type: long + short_option: z + long_option: service-version + is_optional: true + default_value: 1 + - name: node-ip + description: Onap service running node IP + type: string + - name: node-port + description: Onap service running node port + type: string + - name: create-or-update + description: Onap service create or update + type: cfbcv + default_value: true +results: + direction: portrait1 + attributes: + - name: name + description: Onap service name + scope: short + type: string + - name: version + description: Onap service version + scope: short + type: string + - name: status + description: Onap service base url + scope: short + type: url + - name: status + description: Onap service status + scope: short1 + type: long + - name: nodes + description: Onap service running nodes + scope: long + type: string + - name: location + description: Onap service location + scope: long + type: url \ No newline at end of file diff --git a/framework/src/test/resources/schema-validate-http.yaml b/framework/src/test/resources/schema-validate-http.yaml new file mode 100644 index 00000000..82f44aed --- /dev/null +++ b/framework/src/test/resources/schema-validate-http.yaml @@ -0,0 +1,89 @@ +onap_cmd_schema_version: 1.0 +description: Register microservice into Onap +name: schema-validate +service: + name: msb +parameters: + - name: service-name1 + description: Onap service name + type: string + short_option: x + long_option: service-name + is_optional: false + - name: service-version + description: Onap service version + type: string + short_option: x + long_option: service-version + is_optional: false + - name: service-url + description: Onap service base url + type: url1 + short_option: u + long_option: service-url + is_optional: false1 + - name: status + description: Onap service status + type: long + short_option: z + long_option: service-version + is_optional: true + default_value: 1 + - name: node-ip + description: Onap service running node IP + type: string + - name: node-port + description: Onap service running node port + type: string + - name: create-or-update + description: Onap service create or update + type: cfbcv + default_value: true +results: + direction: portrait + attributes: + - name: name + description: Onap service name + scope: short + type: string + - name: version + description: Onap service version + scope: short + type: string + - name: status + description: Onap service base url + scope: short + type: url + - name: status + description: Onap service status + scope: short1 + type: long + - name: nodes + description: Onap service running nodes + scope: long + type: string + - name: location + description: Onap service location + scope: long + type: url +http: + request: + uri: /services + method: POST1 + body: '{"serviceName":"${service}","serviceName":"${service-name}","version":"${service-version}","url":"${service-url}","protocol":"REST","visualRange":"1","lb_policy":"hash","nodes":[{"ip":"${node-ip}","port":"${node-port}","ttl":0}]}' + headers: + queries: + createOrUpdate: ${create-or-update1} + success_codes: + - 201 + - 300 + result_map: + name: $b{$.serviceName} + version: $b{$.version} + url: $b{$.url} + status1: $b{$.status} + nodes: $b{$.nodes[*].ip}:$b{$.nodes[*].port} + location: $h{Location} + sample_response: + body: {"serviceName":"test","version":"v1","url":"/api/test/v1","protocol":"REST","visualRange":"1","lb_policy":"hash","nodes":[{"ip":"127.0.0.1","port":"8012","ttl":0,"nodeId":"test_127.0.0.1_8012","expiration":"2017-02-10T05:33:25Z","created_at":"2017-02-10T05:33:25Z","updated_at":"2017-02-10T05:33:25Z"}],"status":"1"} + diff --git a/framework/src/test/resources/schema-validate-invalid.yaml b/framework/src/test/resources/schema-validate-invalid.yaml new file mode 100644 index 00000000..61f3eeba --- /dev/null +++ b/framework/src/test/resources/schema-validate-invalid.yaml @@ -0,0 +1,151 @@ +onap_cmd_schema_version: 1.0 +name: sdnc-create +description: Register SDNC into Onap +service: + name: extsys + version: v1 +parameters: + - name: name + description: Onap SDNC name + scope: short + type: string + short_option: n + long_option: name + is_optional: false + - name: vendor + description: Onap SDNC vendor + scope: short + type: string + short_option: e + long_option: vendor + is_optional: false + - name: type + description: Onap SDNC type + scope: short + type: string + short_option: y + long_option: type + is_optional: false + - name: sdnc-version + description: Onap SDNC version + scope: short + type: string + short_option: r + long_option: sdnc-version + is_optional: false + - name: url + description: Onap SDNC base url + scope: short + type: url + short_option: l + long_option: url + is_optional: false + - name: description + description: Onap SDNC description + scope: short + type: string + short_option: i + long_option: description + is_optional: false + - name: username + description: Onap SDNC username + scope: short + type: string + short_option: g + long_option: username + is_optional: false + - name: password + description: Onap SDNC password + scope: short + type: string + is_secured: true + short_option: j + long_option: password + is_optional: false + - name: product-name + description: Onap SDNC product-name + scope: short + type: string + short_option: o + long_option: product-name + is_optional: false + - name: protocol + description: Onap SDNC protocol + scope: short + type: string + short_option: k + long_option: protocol + is_optional: false +results: + direction: portrait + attributes: + - name: id + description: Onap SDNC ID + scope: short + type: string + - name: name + description: Onap SDNC name + scope: short + type: string + - name: vendor + description: Onap SDNC vendor + scope: short + type: string + - name: type + description: Onap SDNC type + scope: short + type: string + - name: version + description: Onap SDNC version + scope: short + type: string + - name: url + description: Onap SDNC base url + scope: short + type: url + - name: description + description: Onap SDNC description + scope: short + type: string + - name: username + description: Onap SDNC username + scope: short + type: string + - name: password + description: Onap SDNC password + scope: short + type: string + is_secured: true + - name: product-name + description: Onap SDNC product name + scope: short + type: string + - name: protocol + description: Onap SDNC protocol + scope: short + type: string + - name: create-time + description: Onap SDNC create-time + scope: long + type: string +http: + request: + headers: + createOrUpdate: ${create-or-update1} + body: + success_codes: + result_map: + id: $b{$.sdnControllerId} + name: $b{$.name} + vendor: $b{$.vendor} + type: $b{$.type} + version: $b{$.version} + url: $b{$.url} + description: $b{$.description} + username: $b{$.userName} + password: $b{$.password} + protocol: $b{$.protocol} + product-name: $b{$.productName} + create-time: $b{$.createTime} + sample_response: + body: diff --git a/framework/src/test/resources/schema-validate-invalidschematype.yaml b/framework/src/test/resources/schema-validate-invalidschematype.yaml new file mode 100644 index 00000000..cacf9c06 --- /dev/null +++ b/framework/src/test/resources/schema-validate-invalidschematype.yaml @@ -0,0 +1,88 @@ +onap_cmd_schema_version: 1.0 +description: Register microservice into Onap +name: schema-validate +parameters: + - name: service-name1 + description: Onap service name + type: string + short_option: x + long_option: service-name + is_optional: false + - name: service-version + description: Onap service version + type: string + short_option: x + long_option: service-version + is_optional: false + - name: service-url + description: Onap service base url + type: url1 + short_option: u + long_option: service-url + is_optional: false1 + - name: status + description: Onap service status + type: long + short_option: z + long_option: service-version + is_optional: true + default_value: 1 + - name: node-ip + description: Onap service running node IP + type: string + - name: node-port + description: Onap service running node port + type: string + - name: create-or-update + description: Onap service create or update + type: cfbcv + default_value: true +results: + direction: portrait + attributes: + - name: name + description: Onap service name + scope: short + type: string + - name: version + description: Onap service version + scope: short + type: string + - name: status + description: Onap service base url + scope: short + type: url + - name: status + description: Onap service status + scope: short1 + type: long + - name: nodes + description: Onap service running nodes + scope: long + type: string + - name: location + description: Onap service location + scope: long + type: url +http: + request: + uri: + method: POST + body: + headers: + queries: + createOrUpdate: ${create-or-update1} + success_codes: + - 201 + - 300 + result_map: + name: $b{$.serviceName} + version: $b{$.version} + url: $b{$.url} + status1: $b{$.status} + nodes: $b{$.nodes[*].ip}:$b{$.nodes[*].port} + location: $h{Location} + + sample_response: + body: {"serviceName":"test","version":"v1","url":"/api/test/v1","protocol":"REST","visualRange":"1","lb_policy":"hash","nodes":[{"ip":"127.0.0.1","port":"8012","ttl":0,"nodeId":"test_127.0.0.1_8012","expiration":"2017-02-10T05:33:25Z","created_at":"2017-02-10T05:33:25Z","updated_at":"2017-02-10T05:33:25Z"}],"status":"1"} + diff --git a/framework/src/test/resources/schema-validate-pass.yaml b/framework/src/test/resources/schema-validate-pass.yaml new file mode 100644 index 00000000..91fb3141 --- /dev/null +++ b/framework/src/test/resources/schema-validate-pass.yaml @@ -0,0 +1,153 @@ +onap_cmd_schema_version: 1.0 +name: sdnc-create +description: Register SDNC into Onap +service: + name: extsys + version: v1 +parameters: + - name: name + description: Onap SDNC name + scope: short + type: string + short_option: n + long_option: name + is_optional: false + - name: vendor + description: Onap SDNC vendor + scope: short + type: string + short_option: e + long_option: vendor + is_optional: false + - name: type + description: Onap SDNC type + scope: short + type: string + short_option: y + long_option: type + is_optional: false + - name: sdnc-version + description: Onap SDNC version + scope: short + type: string + short_option: r + long_option: sdnc-version + is_optional: false + - name: url + description: Onap SDNC base url + scope: short + type: url + short_option: l + long_option: url + is_optional: false + - name: description + description: Onap SDNC description + scope: short + type: string + short_option: i + long_option: description + is_optional: false + - name: username + description: Onap SDNC username + scope: short + type: string + short_option: g + long_option: username + is_optional: false + - name: password + description: Onap SDNC password + scope: short + type: string + is_secured: true + short_option: j + long_option: password + is_optional: false + - name: product-name + description: Onap SDNC product-name + scope: short + type: string + short_option: o + long_option: product-name + is_optional: false + - name: protocol + description: Onap SDNC protocol + scope: short + type: string + short_option: k + long_option: protocol + is_optional: false +results: + direction: portrait + attributes: + - name: id + description: Onap SDNC ID + scope: short + type: string + - name: name + description: Onap SDNC name + scope: short + type: string + - name: vendor + description: Onap SDNC vendor + scope: short + type: string + - name: type + description: Onap SDNC type + scope: short + type: string + - name: version + description: Onap SDNC version + scope: short + type: string + - name: url + description: Onap SDNC base url + scope: short + type: url + - name: description + description: Onap SDNC description + scope: short + type: string + - name: username + description: Onap SDNC username + scope: short + type: string + - name: password + description: Onap SDNC password + scope: short + type: string + is_secured: true + - name: product-name + description: Onap SDNC product name + scope: short + type: string + - name: protocol + description: Onap SDNC protocol + scope: short + type: string + - name: create-time + description: Onap SDNC create-time + scope: long + type: string +http: + request: + headers: + createOrUpdate: ${create-or-update1} + body: {"name":"${name}","vendor":"${vendor}","version":"${sdnc-version}","description":"${description}","type":"${type}","url":"${url}","userName":"${username}","password":"${password}","productName":"${product-name}","protocol":"${protocol}"} + success_codes: + - 201 + - 200 + result_map: + id: $b{$.sdnControllerId} + name: $b{$.name} + vendor: $b{$.vendor} + type: $b{$.type} + version: $b{$.version} + url: $b{$.url} + description: $b{$.description} + username: $b{$.userName} + password: $b{$.password} + protocol: $b{$.protocol} + product-name: $b{$.productName} + create-time: $b{$.createTime} + sample_response: + body: '{"id":"string","name":"string","vendor":"string","version":"string","description":"string","type":"string","createTime":"string","url":"string","userName":"string","password":"string","productName":"string","protocol":"string"}' -- cgit 1.2.3-korg