From 0e3b5c46528bcec584616ea8df6fca63dcde53fc Mon Sep 17 00:00:00 2001 From: aadityasinha-dotcom Date: Tue, 10 Oct 2023 21:55:27 +0530 Subject: [PATCH 1/5] Dynamically generate invalid config files in unit tests Signed-off-by: aadityasinha-dotcom --- src/core/zowe/core_for_zowe_sdk/config_file.py | 1 + tests/unit/fixtures/invalid.zowe.schema.json | 4 ++-- tests/unit/test_zowe_core.py | 9 +++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/zowe/core_for_zowe_sdk/config_file.py b/src/core/zowe/core_for_zowe_sdk/config_file.py index b9e01b3d..aab694f5 100644 --- a/src/core/zowe/core_for_zowe_sdk/config_file.py +++ b/src/core/zowe/core_for_zowe_sdk/config_file.py @@ -158,6 +158,7 @@ def validate_schema( # validate the $schema property if path_schema_json: + print(self.jsonc, path_schema_json) validate_config_json(self.jsonc, path_schema_json, cwd = self.location) def schema_list( diff --git a/tests/unit/fixtures/invalid.zowe.schema.json b/tests/unit/fixtures/invalid.zowe.schema.json index cbb1cc9a..8d1a8a22 100644 --- a/tests/unit/fixtures/invalid.zowe.schema.json +++ b/tests/unit/fixtures/invalid.zowe.schema.json @@ -76,9 +76,9 @@ "description": "The z/OSMF server host name." }, "port": { - "type": "number", + "type": "string", "description": "The z/OSMF server port.", - "default": 443 + "default": "443" }, "user": { "type": "string", diff --git a/tests/unit/test_zowe_core.py b/tests/unit/test_zowe_core.py index bf71ef6f..03fd4097 100644 --- a/tests/unit/test_zowe_core.py +++ b/tests/unit/test_zowe_core.py @@ -633,9 +633,14 @@ def test_profile_loading_with_invalid_schema(self, get_pass_func): # Setup - copy profile to fake filesystem created by pyfakefs with self.assertRaises(ValidationError): custom_file_path = os.path.join(self.custom_dir, "invalid.zowe.config.json") - shutil.copy(self.original_invalid_file_path, custom_file_path) - shutil.copy(self.original_invalid_schema_file_path, self.custom_dir) + # shutil.copy(self.original_invalid_file_path, custom_file_path) + # shutil.copy(self.original_invalid_schema_file_path, self.custom_dir) os.chdir(self.custom_dir) + with open(self.original_file_path, 'r') as f: + original_config = commentjson.load(f) + original_config["$schema"] = "./invalid.zowe.schema.json" + with open(os.path.join(self.custom_dir, "invalid.zowe.config.json"), 'w') as f: + commentjson.dump(original_config, f) self.setUpCreds(custom_file_path, { "profiles.zosmf.properties.user": "user", From 66ceb940535a06afa4ad8e34e43043dafaf39f5c Mon Sep 17 00:00:00 2001 From: aadityasinha-dotcom Date: Wed, 25 Oct 2023 17:33:36 +0530 Subject: [PATCH 2/5] chanhes to the tests Signed-off-by: aadityasinha-dotcom --- .vscode/settings.json | 15 +++++++++------ src/core/zowe/core_for_zowe_sdk/config_file.py | 1 - tests/unit/test_zowe_core.py | 15 ++++++++------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index baf3b191..a0091b4c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,9 +1,12 @@ { - "editor.formatOnSave": true, - "python.formatting.provider": "black", - "[python]": { - "editor.codeActionsOnSave": { - "source.organizeImports": true - } + "editor.formatOnSave": true, + "python.formatting.provider": "black", + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true } + }, + "python.testing.pytestArgs": ["tests"], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true } diff --git a/src/core/zowe/core_for_zowe_sdk/config_file.py b/src/core/zowe/core_for_zowe_sdk/config_file.py index 91eade5b..42bb1daf 100644 --- a/src/core/zowe/core_for_zowe_sdk/config_file.py +++ b/src/core/zowe/core_for_zowe_sdk/config_file.py @@ -152,7 +152,6 @@ def validate_schema(self) -> None: # validate the $schema property if path_schema_json: - print(self.jsonc, path_schema_json) validate_config_json(self.jsonc, path_schema_json, cwd = self.location) def schema_list( diff --git a/tests/unit/test_zowe_core.py b/tests/unit/test_zowe_core.py index dcbc9839..cce5d136 100644 --- a/tests/unit/test_zowe_core.py +++ b/tests/unit/test_zowe_core.py @@ -609,13 +609,11 @@ def test_profile_loading_with_invalid_schema(self, get_pass_func): """ # Setup - copy profile to fake filesystem created by pyfakefs with self.assertRaises(ValidationError): - custom_file_path = os.path.join(self.custom_dir, "invalid.zowe.config.json") - # shutil.copy(self.original_invalid_file_path, custom_file_path) - # shutil.copy(self.original_invalid_schema_file_path, self.custom_dir) + custom_file_path = os.path.join(self.custom_dir, "zowe.config.json") os.chdir(self.custom_dir) with open(self.original_file_path, 'r') as f: original_config = commentjson.load(f) - original_config["$schema"] = "./invalid.zowe.schema.json" + original_config["$schema"] = "fixtures/invalid.zowe.schema.json" with open(os.path.join(self.custom_dir, "invalid.zowe.config.json"), 'w') as f: commentjson.dump(original_config, f) @@ -639,10 +637,13 @@ def test_profile_loading_with_invalid_schema_internet_URI(self, get_pass_func): """ # Setup - copy profile to fake filesystem created by pyfakefs with self.assertRaises(SchemaError): - custom_file_path = os.path.join(self.custom_dir, "invalidUri.zowe.config.json") - shutil.copy(self.original_invalidUri_file_path, custom_file_path) - shutil.copy(self.original_invalidUri_schema_file_path, self.custom_dir) + custom_file_path = os.path.join(self.custom_dir, "zowe.config.json") os.chdir(self.custom_dir) + with open(self.original_file_path, 'r') as f: + original_config = commentjson.load(f) + original_config["$schema"] = "fixtures/invalidUri.zowe.schema.json" + with open(os.path.join(self.custom_dir, "invalidUri.zowe.config.json"), 'w') as f: + commentjson.dump(original_config, f) self.setUpCreds( custom_file_path, From 22a036f2a11d5dff164eb9fa70a413ee2f056394 Mon Sep 17 00:00:00 2001 From: aadityasinha-dotcom Date: Fri, 10 Nov 2023 18:36:37 +0530 Subject: [PATCH 3/5] removed invalidUri file Signed-off-by: aadityasinha-dotcom --- .../unit/fixtures/invalidUri.zowe.config.json | 55 ------------------- tests/unit/test_zowe_core.py | 10 ++-- 2 files changed, 4 insertions(+), 61 deletions(-) delete mode 100644 tests/unit/fixtures/invalidUri.zowe.config.json diff --git a/tests/unit/fixtures/invalidUri.zowe.config.json b/tests/unit/fixtures/invalidUri.zowe.config.json deleted file mode 100644 index 68b06dbe..00000000 --- a/tests/unit/fixtures/invalidUri.zowe.config.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "$schema": "./invalidUri.zowe.schema.json", - "profiles": { - "zosmf": { - "type": "zosmf", - "properties": { - "port": 10443 - }, - "secure": [] - }, - "tso": { - "type": "tso", - "properties": { - "account": "", - "codePage": "1047", - "logonProcedure": "IZUFPROC" - }, - "secure": [] - }, - "ssh": { - "type": "ssh", - "properties": { - "port": 22 - }, - "secure": ["user"] - }, - "zftp": { - "type": "zftp", - "properties": { - "port": 21, - "secureFtp": true - }, - "secure": [] - }, - "base": { - "type": "base", - "properties": { - "host": "zowe.test.cloud", - "rejectUnauthorized": false - }, - "secure": [ - "user", - "password" - ] - } - }, - "defaults": { - "zosmf": "zosmf", - "tso": "tso", - "ssh": "ssh", - "zftp": "zftp", - "base": "base" - }, - "autoStore": true -} \ No newline at end of file diff --git a/tests/unit/test_zowe_core.py b/tests/unit/test_zowe_core.py index cce5d136..0781e195 100644 --- a/tests/unit/test_zowe_core.py +++ b/tests/unit/test_zowe_core.py @@ -198,9 +198,7 @@ def setUp(self): self.fs.add_real_file(self.original_user_file_path) self.fs.add_real_file(self.original_nested_file_path) self.fs.add_real_file(self.original_schema_file_path) - self.fs.add_real_file(self.original_invalid_file_path) self.fs.add_real_file(self.original_invalid_schema_file_path) - self.fs.add_real_file(self.original_invalidUri_file_path) self.fs.add_real_file(self.original_invalidUri_schema_file_path) self.custom_dir = os.path.dirname(FIXTURES_PATH) self.custom_appname = "zowe_abcd" @@ -611,10 +609,10 @@ def test_profile_loading_with_invalid_schema(self, get_pass_func): with self.assertRaises(ValidationError): custom_file_path = os.path.join(self.custom_dir, "zowe.config.json") os.chdir(self.custom_dir) - with open(self.original_file_path, 'r') as f: + with open(self.original_file_path, "r") as f: original_config = commentjson.load(f) original_config["$schema"] = "fixtures/invalid.zowe.schema.json" - with open(os.path.join(self.custom_dir, "invalid.zowe.config.json"), 'w') as f: + with open(os.path.join(self.custom_dir, "invalid.zowe.config.json"), "w") as f: commentjson.dump(original_config, f) self.setUpCreds( @@ -639,10 +637,10 @@ def test_profile_loading_with_invalid_schema_internet_URI(self, get_pass_func): with self.assertRaises(SchemaError): custom_file_path = os.path.join(self.custom_dir, "zowe.config.json") os.chdir(self.custom_dir) - with open(self.original_file_path, 'r') as f: + with open(self.original_file_path, "r") as f: original_config = commentjson.load(f) original_config["$schema"] = "fixtures/invalidUri.zowe.schema.json" - with open(os.path.join(self.custom_dir, "invalidUri.zowe.config.json"), 'w') as f: + with open(os.path.join(self.custom_dir, "invalidUri.zowe.config.json"), "w") as f: commentjson.dump(original_config, f) self.setUpCreds( From 72042204c2d37a5c7e50b3a337a560c9232b23b8 Mon Sep 17 00:00:00 2001 From: aadityasinha-dotcom Date: Wed, 22 Nov 2023 17:22:52 +0530 Subject: [PATCH 4/5] created the schema file dynamically as well Signed-off-by: aadityasinha-dotcom --- tests/unit/fixtures/invalid.zowe.config.json | 55 --- tests/unit/fixtures/invalid.zowe.schema.json | 427 ------------------ .../unit/fixtures/invalidUri.zowe.schema.json | 427 ------------------ tests/unit/invalid.zowe.config.json | 1 + tests/unit/invalid.zowe.schema.json | 1 + tests/unit/test_zowe_core.py | 41 +- 6 files changed, 32 insertions(+), 920 deletions(-) delete mode 100644 tests/unit/fixtures/invalid.zowe.config.json delete mode 100644 tests/unit/fixtures/invalid.zowe.schema.json delete mode 100644 tests/unit/fixtures/invalidUri.zowe.schema.json create mode 100644 tests/unit/invalid.zowe.config.json create mode 100644 tests/unit/invalid.zowe.schema.json diff --git a/tests/unit/fixtures/invalid.zowe.config.json b/tests/unit/fixtures/invalid.zowe.config.json deleted file mode 100644 index 89be0a69..00000000 --- a/tests/unit/fixtures/invalid.zowe.config.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "$schema": "./invalid.zowe.schema.json", - "profiles": { - "zosmf": { - "type": "zosmf", - "properties": { - "port": 10443 - }, - "secure": [] - }, - "tso": { - "type": "tso", - "properties": { - "account": "", - "codePage": "1047", - "logonProcedure": "IZUFPROC" - }, - "secure": [] - }, - "ssh": { - "type": "ssh", - "properties": { - "port": 22 - }, - "secure": ["user"] - }, - "zftp": { - "type": "zftp", - "properties": { - "port": 21, - "secureFtp": true - }, - "secure": [] - }, - "base": { - "type": "base", - "properties": { - "host": "zowe.test.cloud", - "rejectUnauthorized": false - }, - "secure": [ - "user", - "password" - ] - } - }, - "defaults": { - "zosmf": "zosmf", - "tso": "tso", - "ssh": "ssh", - "zftp": "zftp", - "base": "base" - }, - "autoStore": true -} \ No newline at end of file diff --git a/tests/unit/fixtures/invalid.zowe.schema.json b/tests/unit/fixtures/invalid.zowe.schema.json deleted file mode 100644 index 8d1a8a22..00000000 --- a/tests/unit/fixtures/invalid.zowe.schema.json +++ /dev/null @@ -1,427 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$version": "1.0", - "type": "object", - "description": "Zowe configuration", - "properties": { - "profiles": { - "type": "object", - "description": "Mapping of profile names to profile configurations", - "patternProperties": { - "^\\S*$": { - "type": "object", - "description": "Profile configuration object", - "properties": { - "type": { - "description": "Profile type", - "type": "boolean", - "enum": [ - "zosmf", - "tso", - "ssh", - "zftp", - "base" - ] - }, - "properties": { - "description": "Profile properties object", - "type": "object" - }, - "profiles": { - "description": "Optional subprofile configurations", - "type": "object", - "$ref": "#/properties/profiles" - }, - "secure": { - "description": "Secure property names", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - } - }, - "allOf": [ - { - "if": { - "properties": { - "type": false - } - }, - "then": { - "properties": { - "properties": { - "title": "Missing profile type" - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "zosmf" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "z/OSMF Profile", - "description": "z/OSMF Profile", - "properties": { - "host": { - "type": "string", - "description": "The z/OSMF server host name." - }, - "port": { - "type": "string", - "description": "The z/OSMF server port.", - "default": "443" - }, - "user": { - "type": "string", - "description": "Mainframe (z/OSMF) user name, which can be the same as your TSO login." - }, - "password": { - "type": "string", - "description": "Mainframe (z/OSMF) password, which can be the same as your TSO password." - }, - "rejectUnauthorized": { - "type": "boolean", - "description": "Reject self-signed certificates.", - "default": true - }, - "certFile": { - "type": "string", - "description": "The file path to a certificate file to use for authentication" - }, - "certKeyFile": { - "type": "string", - "description": "The file path to a certificate key file to use for authentication" - }, - "basePath": { - "type": "string", - "description": "The base path for your API mediation layer instance. Specify this option to prepend the base path to all z/OSMF resources when making REST requests. Do not specify this option if you are not using an API mediation layer." - }, - "protocol": { - "type": "string", - "description": "The protocol used (HTTP or HTTPS)", - "default": "https", - "enum": [ - "http", - "https" - ] - }, - "encoding": { - "type": "string", - "description": "The encoding for download and upload of z/OS data set and USS files. The default encoding if not specified is IBM-1047." - }, - "responseTimeout": { - "type": "number", - "description": "The maximum amount of time in seconds the z/OSMF Files TSO servlet should run before returning a response. Any request exceeding this amount of time will be terminated and return an error. Allowed values: 5 - 600" - } - }, - "required": [] - }, - "secure": { - "items": { - "enum": [ - "user", - "password" - ] - } - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "tso" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "TSO Profile", - "description": "z/OS TSO/E User Profile", - "properties": { - "account": { - "type": "string", - "description": "Your z/OS TSO/E accounting information." - }, - "characterSet": { - "type": "string", - "description": "Character set for address space to convert messages and responses from UTF-8 to EBCDIC.", - "default": "697" - }, - "codePage": { - "type": "string", - "description": "Codepage value for TSO/E address space to convert messages and responses from UTF-8 to EBCDIC.", - "default": "1047" - }, - "columns": { - "type": "number", - "description": "The number of columns on a screen.", - "default": 80 - }, - "logonProcedure": { - "type": "string", - "description": "The logon procedure to use when creating TSO procedures on your behalf.", - "default": "IZUFPROC" - }, - "regionSize": { - "type": "number", - "description": "Region size for the TSO/E address space.", - "default": 4096 - }, - "rows": { - "type": "number", - "description": "The number of rows on a screen.", - "default": 24 - } - }, - "required": [] - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "ssh" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "z/OS SSH Profile", - "description": "z/OS SSH Profile", - "properties": { - "host": { - "type": "string", - "description": "The z/OS SSH server host name." - }, - "port": { - "type": "number", - "description": "The z/OS SSH server port.", - "default": 22 - }, - "user": { - "type": "string", - "description": "Mainframe user name, which can be the same as your TSO login." - }, - "password": { - "type": "string", - "description": "Mainframe password, which can be the same as your TSO password." - }, - "privateKey": { - "type": "string", - "description": "Path to a file containing your private key, that must match a public key stored in the server for authentication" - }, - "keyPassphrase": { - "type": "string", - "description": "Private key passphrase, which unlocks the private key." - }, - "handshakeTimeout": { - "type": "number", - "description": "How long in milliseconds to wait for the SSH handshake to complete." - } - }, - "required": [] - }, - "secure": { - "items": { - "enum": [ - "user", - "password", - "keyPassphrase" - ] - } - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "zftp" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "Configuration profile for z/OS FTP", - "description": "Configuration profile for z/OS FTP", - "properties": { - "host": { - "type": "string", - "description": "The hostname or IP address of the z/OS server to connect to." - }, - "port": { - "type": "number", - "description": "The port of the z/OS FTP server.", - "default": 21 - }, - "user": { - "type": "string", - "description": "Username for authentication on z/OS" - }, - "password": { - "type": "string", - "description": "Password to authenticate to FTP." - }, - "secureFtp": { - "type": [ - "boolean", - "null" - ], - "description": "Set to true for both control and data connection encryption, 'control' for control connection encryption only, or 'implicit' for implicitly encrypted control connection (this mode is deprecated in modern times, but usually uses port 990). Note: Unfortunately, this plugin's functionality only works with FTP and FTPS, not 'SFTP' which is FTP over SSH.", - "default": true - }, - "rejectUnauthorized": { - "type": [ - "boolean", - "null" - ], - "description": "Reject self-signed certificates. Only specify this if you are connecting to a secure FTP instance." - }, - "servername": { - "type": [ - "string", - "null" - ], - "description": "Server name for the SNI (Server Name Indication) TLS extension. Only specify if you are connecting securely" - }, - "connectionTimeout": { - "type": "number", - "description": "How long (in milliseconds) to wait for the control connection to be established.", - "default": 10000 - } - } - }, - "secure": { - "items": { - "enum": [ - "user", - "password" - ] - } - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "base" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "Base Profile", - "description": "Base profile that stores values shared by multiple service profiles", - "properties": { - "host": { - "type": "string", - "description": "Host name of service on the mainframe." - }, - "port": { - "type": "number", - "description": "Port number of service on the mainframe." - }, - "user": { - "type": "string", - "description": "User name to authenticate to service on the mainframe." - }, - "password": { - "type": "string", - "description": "Password to authenticate to service on the mainframe." - }, - "rejectUnauthorized": { - "type": "boolean", - "description": "Reject self-signed certificates.", - "default": true - }, - "tokenType": { - "type": "string", - "description": "The type of token to get and use for the API. Omit this option to use the default token type, which is provided by 'zowe auth login'." - }, - "tokenValue": { - "type": "string", - "description": "The value of the token to pass to the API." - }, - "certFile": { - "type": "string", - "description": "The file path to a certificate file to use for authentication" - }, - "certKeyFile": { - "type": "string", - "description": "The file path to a certificate key file to use for authentication" - } - }, - "required": [] - }, - "secure": { - "items": { - "enum": [ - "user", - "password", - "tokenValue" - ] - } - } - } - } - } - ] - } - } - }, - "defaults": { - "type": "object", - "description": "Mapping of profile types to default profile names", - "properties": { - "zosmf": { - "description": "Default zosmf profile", - "type": "string" - }, - "tso": { - "description": "Default tso profile", - "type": "string" - }, - "ssh": { - "description": "Default ssh profile", - "type": "string" - }, - "zftp": { - "description": "Default zftp profile", - "type": "string" - }, - "base": { - "description": "Default base profile", - "type": "string" - } - } - }, - "autoStore": { - "type": "boolean", - "description": "If true, values you enter when prompted are stored for future use" - } - } -} \ No newline at end of file diff --git a/tests/unit/fixtures/invalidUri.zowe.schema.json b/tests/unit/fixtures/invalidUri.zowe.schema.json deleted file mode 100644 index 3ef45c26..00000000 --- a/tests/unit/fixtures/invalidUri.zowe.schema.json +++ /dev/null @@ -1,427 +0,0 @@ -{ - "$schema": "https://json-schema.org/draft/2020-12/schema", - "$version": "1.0", - "type": "invalid", - "description": "Zowe configuration", - "properties": { - "profiles": { - "type": "object", - "description": "Mapping of profile names to profile configurations", - "patternProperties": { - "^\\S*$": { - "type": "object", - "description": "Profile configuration object", - "properties": { - "type": { - "description": "Profile type", - "type": "boolean", - "enum": [ - "zosmf", - "tso", - "ssh", - "zftp", - "base" - ] - }, - "properties": { - "description": "Profile properties object", - "type": "object" - }, - "profiles": { - "description": "Optional subprofile configurations", - "type": "object", - "$ref": "#/properties/profiles" - }, - "secure": { - "description": "Secure property names", - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - } - }, - "allOf": [ - { - "if": { - "properties": { - "type": false - } - }, - "then": { - "properties": { - "properties": { - "title": "Missing profile type" - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "zosmf" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "z/OSMF Profile", - "description": "z/OSMF Profile", - "properties": { - "host": { - "type": "string", - "description": "The z/OSMF server host name." - }, - "port": { - "type": "number", - "description": "The z/OSMF server port.", - "default": 443 - }, - "user": { - "type": "string", - "description": "Mainframe (z/OSMF) user name, which can be the same as your TSO login." - }, - "password": { - "type": "string", - "description": "Mainframe (z/OSMF) password, which can be the same as your TSO password." - }, - "rejectUnauthorized": { - "type": "boolean", - "description": "Reject self-signed certificates.", - "default": true - }, - "certFile": { - "type": "string", - "description": "The file path to a certificate file to use for authentication" - }, - "certKeyFile": { - "type": "string", - "description": "The file path to a certificate key file to use for authentication" - }, - "basePath": { - "type": "string", - "description": "The base path for your API mediation layer instance. Specify this option to prepend the base path to all z/OSMF resources when making REST requests. Do not specify this option if you are not using an API mediation layer." - }, - "protocol": { - "type": "string", - "description": "The protocol used (HTTP or HTTPS)", - "default": "https", - "enum": [ - "http", - "https" - ] - }, - "encoding": { - "type": "string", - "description": "The encoding for download and upload of z/OS data set and USS files. The default encoding if not specified is IBM-1047." - }, - "responseTimeout": { - "type": "number", - "description": "The maximum amount of time in seconds the z/OSMF Files TSO servlet should run before returning a response. Any request exceeding this amount of time will be terminated and return an error. Allowed values: 5 - 600" - } - }, - "required": [] - }, - "secure": { - "items": { - "enum": [ - "user", - "password" - ] - } - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "tso" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "TSO Profile", - "description": "z/OS TSO/E User Profile", - "properties": { - "account": { - "type": "string", - "description": "Your z/OS TSO/E accounting information." - }, - "characterSet": { - "type": "string", - "description": "Character set for address space to convert messages and responses from UTF-8 to EBCDIC.", - "default": "697" - }, - "codePage": { - "type": "string", - "description": "Codepage value for TSO/E address space to convert messages and responses from UTF-8 to EBCDIC.", - "default": "1047" - }, - "columns": { - "type": "number", - "description": "The number of columns on a screen.", - "default": 80 - }, - "logonProcedure": { - "type": "string", - "description": "The logon procedure to use when creating TSO procedures on your behalf.", - "default": "IZUFPROC" - }, - "regionSize": { - "type": "number", - "description": "Region size for the TSO/E address space.", - "default": 4096 - }, - "rows": { - "type": "number", - "description": "The number of rows on a screen.", - "default": 24 - } - }, - "required": [] - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "ssh" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "z/OS SSH Profile", - "description": "z/OS SSH Profile", - "properties": { - "host": { - "type": "string", - "description": "The z/OS SSH server host name." - }, - "port": { - "type": "number", - "description": "The z/OS SSH server port.", - "default": 22 - }, - "user": { - "type": "string", - "description": "Mainframe user name, which can be the same as your TSO login." - }, - "password": { - "type": "string", - "description": "Mainframe password, which can be the same as your TSO password." - }, - "privateKey": { - "type": "string", - "description": "Path to a file containing your private key, that must match a public key stored in the server for authentication" - }, - "keyPassphrase": { - "type": "string", - "description": "Private key passphrase, which unlocks the private key." - }, - "handshakeTimeout": { - "type": "number", - "description": "How long in milliseconds to wait for the SSH handshake to complete." - } - }, - "required": [] - }, - "secure": { - "items": { - "enum": [ - "user", - "password", - "keyPassphrase" - ] - } - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "zftp" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "Configuration profile for z/OS FTP", - "description": "Configuration profile for z/OS FTP", - "properties": { - "host": { - "type": "string", - "description": "The hostname or IP address of the z/OS server to connect to." - }, - "port": { - "type": "number", - "description": "The port of the z/OS FTP server.", - "default": 21 - }, - "user": { - "type": "string", - "description": "Username for authentication on z/OS" - }, - "password": { - "type": "string", - "description": "Password to authenticate to FTP." - }, - "secureFtp": { - "type": [ - "boolean", - "null" - ], - "description": "Set to true for both control and data connection encryption, 'control' for control connection encryption only, or 'implicit' for implicitly encrypted control connection (this mode is deprecated in modern times, but usually uses port 990). Note: Unfortunately, this plugin's functionality only works with FTP and FTPS, not 'SFTP' which is FTP over SSH.", - "default": true - }, - "rejectUnauthorized": { - "type": [ - "boolean", - "null" - ], - "description": "Reject self-signed certificates. Only specify this if you are connecting to a secure FTP instance." - }, - "servername": { - "type": [ - "string", - "null" - ], - "description": "Server name for the SNI (Server Name Indication) TLS extension. Only specify if you are connecting securely" - }, - "connectionTimeout": { - "type": "number", - "description": "How long (in milliseconds) to wait for the control connection to be established.", - "default": 10000 - } - } - }, - "secure": { - "items": { - "enum": [ - "user", - "password" - ] - } - } - } - } - }, - { - "if": { - "properties": { - "type": { - "const": "base" - } - } - }, - "then": { - "properties": { - "properties": { - "type": "object", - "title": "Base Profile", - "description": "Base profile that stores values shared by multiple service profiles", - "properties": { - "host": { - "type": "string", - "description": "Host name of service on the mainframe." - }, - "port": { - "type": "number", - "description": "Port number of service on the mainframe." - }, - "user": { - "type": "string", - "description": "User name to authenticate to service on the mainframe." - }, - "password": { - "type": "string", - "description": "Password to authenticate to service on the mainframe." - }, - "rejectUnauthorized": { - "type": "boolean", - "description": "Reject self-signed certificates.", - "default": true - }, - "tokenType": { - "type": "string", - "description": "The type of token to get and use for the API. Omit this option to use the default token type, which is provided by 'zowe auth login'." - }, - "tokenValue": { - "type": "string", - "description": "The value of the token to pass to the API." - }, - "certFile": { - "type": "string", - "description": "The file path to a certificate file to use for authentication" - }, - "certKeyFile": { - "type": "string", - "description": "The file path to a certificate key file to use for authentication" - } - }, - "required": [] - }, - "secure": { - "items": { - "enum": [ - "user", - "password", - "tokenValue" - ] - } - } - } - } - } - ] - } - } - }, - "defaults": { - "type": "object", - "description": "Mapping of profile types to default profile names", - "properties": { - "zosmf": { - "description": "Default zosmf profile", - "type": "string" - }, - "tso": { - "description": "Default tso profile", - "type": "string" - }, - "ssh": { - "description": "Default ssh profile", - "type": "string" - }, - "zftp": { - "description": "Default zftp profile", - "type": "string" - }, - "base": { - "description": "Default base profile", - "type": "string" - } - } - }, - "autoStore": { - "type": "boolean", - "description": "If true, values you enter when prompted are stored for future use" - } - } -} \ No newline at end of file diff --git a/tests/unit/invalid.zowe.config.json b/tests/unit/invalid.zowe.config.json new file mode 100644 index 00000000..fce51b65 --- /dev/null +++ b/tests/unit/invalid.zowe.config.json @@ -0,0 +1 @@ +{"$schema": "invalid.zowe.schema.json", "profiles": {"zosmf": {"type": "zosmf", "properties": {"port": "10443"}, "secure": ["user", "password"]}, "tso": {"type": "tso", "properties": {"account": "", "codePage": "1047", "logonProcedure": "IZUFPROC"}, "secure": []}, "ssh": {"type": "ssh", "properties": {"port": 22}, "secure": ["user"]}, "zftp": {"type": "zftp", "properties": {"port": 21, "secureFtp": true}, "secure": []}, "base": {"type": "base", "properties": {"host": "zowe.test.cloud", "rejectUnauthorized": false}, "secure": ["user", "password"]}}, "defaults": {"zosmf": "zosmf", "tso": "tso", "ssh": "ssh", "zftp": "zftp", "base": "base"}, "autoStore": true} \ No newline at end of file diff --git a/tests/unit/invalid.zowe.schema.json b/tests/unit/invalid.zowe.schema.json new file mode 100644 index 00000000..492aa00c --- /dev/null +++ b/tests/unit/invalid.zowe.schema.json @@ -0,0 +1 @@ +{"$schema": "https://json-schema.org/draft/2020-12/schema", "$version": "1.0", "type": "object", "description": "Zowe configuration", "properties": {"profiles": {"type": "object", "description": "Mapping of profile names to profile configurations", "patternProperties": {"^\\S*$": {"type": "object", "description": "Profile configuration object", "properties": {"type": {"description": "Profile type", "type": "string", "enum": ["zosmf", "tso", "ssh", "zftp", "base"]}, "properties": {"description": "Profile properties object", "type": "object"}, "profiles": {"description": "Optional subprofile configurations", "type": "object", "$ref": "#/properties/profiles"}, "secure": {"description": "Secure property names", "type": "array", "items": {"type": "string"}, "uniqueItems": true}}, "allOf": [{"if": {"properties": {"type": false}}, "then": {"properties": {"properties": {"title": "Missing profile type"}}}}, {"if": {"properties": {"type": {"const": "zosmf"}}}, "then": {"properties": {"properties": {"type": "object", "title": "z/OSMF Profile", "description": "z/OSMF Profile", "properties": {"host": {"type": "string", "description": "The z/OSMF server host name."}, "port": {"type": "number", "description": "The z/OSMF server port.", "default": 443}, "user": {"type": "string", "description": "Mainframe (z/OSMF) user name, which can be the same as your TSO login."}, "password": {"type": "string", "description": "Mainframe (z/OSMF) password, which can be the same as your TSO password."}, "rejectUnauthorized": {"type": "boolean", "description": "Reject self-signed certificates.", "default": true}, "certFile": {"type": "string", "description": "The file path to a certificate file to use for authentication"}, "certKeyFile": {"type": "string", "description": "The file path to a certificate key file to use for authentication"}, "basePath": {"type": "string", "description": "The base path for your API mediation layer instance. Specify this option to prepend the base path to all z/OSMF resources when making REST requests. Do not specify this option if you are not using an API mediation layer."}, "protocol": {"type": "string", "description": "The protocol used (HTTP or HTTPS)", "default": "https", "enum": ["http", "https"]}, "encoding": {"type": "string", "description": "The encoding for download and upload of z/OS data set and USS files. The default encoding if not specified is IBM-1047."}, "responseTimeout": {"type": "number", "description": "The maximum amount of time in seconds the z/OSMF Files TSO servlet should run before returning a response. Any request exceeding this amount of time will be terminated and return an error. Allowed values: 5 - 600"}}, "required": []}, "secure": {"items": {"enum": ["user", "password"]}}}}}, {"if": {"properties": {"type": {"const": "tso"}}}, "then": {"properties": {"properties": {"type": "object", "title": "TSO Profile", "description": "z/OS TSO/E User Profile", "properties": {"account": {"type": "string", "description": "Your z/OS TSO/E accounting information."}, "characterSet": {"type": "string", "description": "Character set for address space to convert messages and responses from UTF-8 to EBCDIC.", "default": "697"}, "codePage": {"type": "string", "description": "Codepage value for TSO/E address space to convert messages and responses from UTF-8 to EBCDIC.", "default": "1047"}, "columns": {"type": "number", "description": "The number of columns on a screen.", "default": 80}, "logonProcedure": {"type": "string", "description": "The logon procedure to use when creating TSO procedures on your behalf.", "default": "IZUFPROC"}, "regionSize": {"type": "number", "description": "Region size for the TSO/E address space.", "default": 4096}, "rows": {"type": "number", "description": "The number of rows on a screen.", "default": 24}}, "required": []}}}}, {"if": {"properties": {"type": {"const": "ssh"}}}, "then": {"properties": {"properties": {"type": "object", "title": "z/OS SSH Profile", "description": "z/OS SSH Profile", "properties": {"host": {"type": "string", "description": "The z/OS SSH server host name."}, "port": {"type": "number", "description": "The z/OS SSH server port.", "default": 22}, "user": {"type": "string", "description": "Mainframe user name, which can be the same as your TSO login."}, "password": {"type": "string", "description": "Mainframe password, which can be the same as your TSO password."}, "privateKey": {"type": "string", "description": "Path to a file containing your private key, that must match a public key stored in the server for authentication"}, "keyPassphrase": {"type": "string", "description": "Private key passphrase, which unlocks the private key."}, "handshakeTimeout": {"type": "number", "description": "How long in milliseconds to wait for the SSH handshake to complete."}}, "required": []}, "secure": {"items": {"enum": ["user", "password", "keyPassphrase"]}}}}}, {"if": {"properties": {"type": {"const": "zftp"}}}, "then": {"properties": {"properties": {"type": "object", "title": "Configuration profile for z/OS FTP", "description": "Configuration profile for z/OS FTP", "properties": {"host": {"type": "string", "description": "The hostname or IP address of the z/OS server to connect to."}, "port": {"type": "number", "description": "The port of the z/OS FTP server.", "default": 21}, "user": {"type": "string", "description": "Username for authentication on z/OS"}, "password": {"type": "string", "description": "Password to authenticate to FTP."}, "secureFtp": {"type": ["boolean", "null"], "description": "Set to true for both control and data connection encryption, 'control' for control connection encryption only, or 'implicit' for implicitly encrypted control connection (this mode is deprecated in modern times, but usually uses port 990). Note: Unfortunately, this plugin's functionality only works with FTP and FTPS, not 'SFTP' which is FTP over SSH.", "default": true}, "rejectUnauthorized": {"type": ["boolean", "null"], "description": "Reject self-signed certificates. Only specify this if you are connecting to a secure FTP instance."}, "servername": {"type": ["string", "null"], "description": "Server name for the SNI (Server Name Indication) TLS extension. Only specify if you are connecting securely"}, "connectionTimeout": {"type": "number", "description": "How long (in milliseconds) to wait for the control connection to be established.", "default": 10000}}}, "secure": {"items": {"enum": ["user", "password"]}}}}}, {"if": {"properties": {"type": {"const": "base"}}}, "then": {"properties": {"properties": {"type": "object", "title": "Base Profile", "description": "Base profile that stores values shared by multiple service profiles", "properties": {"host": {"type": "string", "description": "Host name of service on the mainframe."}, "port": {"type": "number", "description": "Port number of service on the mainframe."}, "user": {"type": "string", "description": "User name to authenticate to service on the mainframe."}, "password": {"type": "string", "description": "Password to authenticate to service on the mainframe."}, "rejectUnauthorized": {"type": "boolean", "description": "Reject self-signed certificates.", "default": true}, "tokenType": {"type": "string", "description": "The type of token to get and use for the API. Omit this option to use the default token type, which is provided by 'zowe auth login'."}, "tokenValue": {"type": "string", "description": "The value of the token to pass to the API."}, "certFile": {"type": "string", "description": "The file path to a certificate file to use for authentication"}, "certKeyFile": {"type": "string", "description": "The file path to a certificate key file to use for authentication"}}, "required": []}, "secure": {"items": {"enum": ["user", "password", "tokenValue"]}}}}}]}}}, "defaults": {"type": "object", "description": "Mapping of profile types to default profile names", "properties": {"zosmf": {"description": "Default zosmf profile", "type": "string"}, "tso": {"description": "Default tso profile", "type": "string"}, "ssh": {"description": "Default ssh profile", "type": "string"}, "zftp": {"description": "Default zftp profile", "type": "string"}, "base": {"description": "Default base profile", "type": "string"}}}, "autoStore": {"type": "boolean", "description": "If true, values you enter when prompted are stored for future use"}}} \ No newline at end of file diff --git a/tests/unit/test_zowe_core.py b/tests/unit/test_zowe_core.py index 0781e195..32a373ad 100644 --- a/tests/unit/test_zowe_core.py +++ b/tests/unit/test_zowe_core.py @@ -183,11 +183,8 @@ def setUp(self): self.setUpPyfakefs() self.original_file_path = os.path.join(FIXTURES_PATH, "zowe.config.json") self.original_user_file_path = os.path.join(FIXTURES_PATH, "zowe.config.user.json") - self.original_invalid_file_path = os.path.join(FIXTURES_PATH, "invalid.zowe.config.json") self.original_nested_file_path = os.path.join(FIXTURES_PATH, "nested.zowe.config.json") self.original_schema_file_path = os.path.join(FIXTURES_PATH, "zowe.schema.json") - self.original_invalid_schema_file_path = os.path.join(FIXTURES_PATH, "invalid.zowe.schema.json") - self.original_invalidUri_file_path = os.path.join(FIXTURES_PATH, "invalidUri.zowe.config.json") self.original_invalidUri_schema_file_path = os.path.join(FIXTURES_PATH, "invalidUri.zowe.schema.json") loader = importlib.util.find_spec("jsonschema") @@ -198,8 +195,6 @@ def setUp(self): self.fs.add_real_file(self.original_user_file_path) self.fs.add_real_file(self.original_nested_file_path) self.fs.add_real_file(self.original_schema_file_path) - self.fs.add_real_file(self.original_invalid_schema_file_path) - self.fs.add_real_file(self.original_invalidUri_schema_file_path) self.custom_dir = os.path.dirname(FIXTURES_PATH) self.custom_appname = "zowe_abcd" self.custom_filename = f"{self.custom_appname}.config.json" @@ -611,10 +606,14 @@ def test_profile_loading_with_invalid_schema(self, get_pass_func): os.chdir(self.custom_dir) with open(self.original_file_path, "r") as f: original_config = commentjson.load(f) - original_config["$schema"] = "fixtures/invalid.zowe.schema.json" + original_config["$schema"] = "invalid.zowe.schema.json" + original_config["profiles"]["zosmf"]["properties"]["port"] = "10443" with open(os.path.join(self.custom_dir, "invalid.zowe.config.json"), "w") as f: commentjson.dump(original_config, f) - + with open(self.original_schema_file_path, "r") as f: + original_schema = commentjson.load(f) + with open(os.path.join(self.custom_dir, "invalid.zowe.schema.json"), "w") as f: + commentjson.dump(original_schema, f) self.setUpCreds( custom_file_path, { @@ -639,9 +638,14 @@ def test_profile_loading_with_invalid_schema_internet_URI(self, get_pass_func): os.chdir(self.custom_dir) with open(self.original_file_path, "r") as f: original_config = commentjson.load(f) - original_config["$schema"] = "fixtures/invalidUri.zowe.schema.json" + original_config["$schema"] = "invalidUri.zowe.schema.json" with open(os.path.join(self.custom_dir, "invalidUri.zowe.config.json"), "w") as f: commentjson.dump(original_config, f) + with open(self.original_schema_file_path, "r") as f: + original_schema = commentjson.load(f) + original_schema["type"] = "invalid" + with open(os.path.join(self.custom_dir, "invalidUri.zowe.schema.json"), "w") as f: + commentjson.dump(original_schema, f) self.setUpCreds( custom_file_path, @@ -925,9 +929,24 @@ def test_validate_config_json_valid(self): def test_validate_config_json_invalid(self): """Test validate_config_json with invalid config.json that does not match schema.json""" - path_to_invalid_config = FIXTURES_PATH + "/invalid.zowe.config.json" - path_to_invalid_schema = FIXTURES_PATH + "/invalid.zowe.schema.json" - + path_to_config = FIXTURES_PATH + "/zowe.config.json" + path_to_schema = FIXTURES_PATH + "/zowe.schema.json" + path_to_invalid_config = "invalid.zowe.config.json" + path_to_invalid_schema = "invalid.zowe.schema.json" + + custom_dir = os.path.dirname(FIXTURES_PATH) + custom_file_path = os.path.join(custom_dir, "zowe.config.json") + os.chdir(custom_dir) + with open(path_to_config, "r") as f: + original_config = commentjson.load(f) + original_config["$schema"] = "invalid.zowe.schema.json" + original_config["profiles"]["zosmf"]["properties"]["port"] = "10443" + with open(os.path.join(custom_dir, "invalid.zowe.config.json"), "w") as f: + commentjson.dump(original_config, f) + with open(path_to_schema, "r") as f: + original_schema = commentjson.load(f) + with open(os.path.join(custom_dir, "invalid.zowe.schema.json"), "w") as f: + commentjson.dump(original_schema, f) invalid_config_json = commentjson.load(open(path_to_invalid_config)) invalid_schema_json = commentjson.load(open(path_to_invalid_schema)) From 8b14be9e38f29c8a0b828dac3bf1e3a3e2d82692 Mon Sep 17 00:00:00 2001 From: aadityasinha-dotcom Date: Wed, 22 Nov 2023 17:28:27 +0530 Subject: [PATCH 5/5] few changes accidentaly run the code which writes the file Signed-off-by: aadityasinha-dotcom --- tests/unit/invalid.zowe.config.json | 1 - tests/unit/invalid.zowe.schema.json | 1 - 2 files changed, 2 deletions(-) delete mode 100644 tests/unit/invalid.zowe.config.json delete mode 100644 tests/unit/invalid.zowe.schema.json diff --git a/tests/unit/invalid.zowe.config.json b/tests/unit/invalid.zowe.config.json deleted file mode 100644 index fce51b65..00000000 --- a/tests/unit/invalid.zowe.config.json +++ /dev/null @@ -1 +0,0 @@ -{"$schema": "invalid.zowe.schema.json", "profiles": {"zosmf": {"type": "zosmf", "properties": {"port": "10443"}, "secure": ["user", "password"]}, "tso": {"type": "tso", "properties": {"account": "", "codePage": "1047", "logonProcedure": "IZUFPROC"}, "secure": []}, "ssh": {"type": "ssh", "properties": {"port": 22}, "secure": ["user"]}, "zftp": {"type": "zftp", "properties": {"port": 21, "secureFtp": true}, "secure": []}, "base": {"type": "base", "properties": {"host": "zowe.test.cloud", "rejectUnauthorized": false}, "secure": ["user", "password"]}}, "defaults": {"zosmf": "zosmf", "tso": "tso", "ssh": "ssh", "zftp": "zftp", "base": "base"}, "autoStore": true} \ No newline at end of file diff --git a/tests/unit/invalid.zowe.schema.json b/tests/unit/invalid.zowe.schema.json deleted file mode 100644 index 492aa00c..00000000 --- a/tests/unit/invalid.zowe.schema.json +++ /dev/null @@ -1 +0,0 @@ -{"$schema": "https://json-schema.org/draft/2020-12/schema", "$version": "1.0", "type": "object", "description": "Zowe configuration", "properties": {"profiles": {"type": "object", "description": "Mapping of profile names to profile configurations", "patternProperties": {"^\\S*$": {"type": "object", "description": "Profile configuration object", "properties": {"type": {"description": "Profile type", "type": "string", "enum": ["zosmf", "tso", "ssh", "zftp", "base"]}, "properties": {"description": "Profile properties object", "type": "object"}, "profiles": {"description": "Optional subprofile configurations", "type": "object", "$ref": "#/properties/profiles"}, "secure": {"description": "Secure property names", "type": "array", "items": {"type": "string"}, "uniqueItems": true}}, "allOf": [{"if": {"properties": {"type": false}}, "then": {"properties": {"properties": {"title": "Missing profile type"}}}}, {"if": {"properties": {"type": {"const": "zosmf"}}}, "then": {"properties": {"properties": {"type": "object", "title": "z/OSMF Profile", "description": "z/OSMF Profile", "properties": {"host": {"type": "string", "description": "The z/OSMF server host name."}, "port": {"type": "number", "description": "The z/OSMF server port.", "default": 443}, "user": {"type": "string", "description": "Mainframe (z/OSMF) user name, which can be the same as your TSO login."}, "password": {"type": "string", "description": "Mainframe (z/OSMF) password, which can be the same as your TSO password."}, "rejectUnauthorized": {"type": "boolean", "description": "Reject self-signed certificates.", "default": true}, "certFile": {"type": "string", "description": "The file path to a certificate file to use for authentication"}, "certKeyFile": {"type": "string", "description": "The file path to a certificate key file to use for authentication"}, "basePath": {"type": "string", "description": "The base path for your API mediation layer instance. Specify this option to prepend the base path to all z/OSMF resources when making REST requests. Do not specify this option if you are not using an API mediation layer."}, "protocol": {"type": "string", "description": "The protocol used (HTTP or HTTPS)", "default": "https", "enum": ["http", "https"]}, "encoding": {"type": "string", "description": "The encoding for download and upload of z/OS data set and USS files. The default encoding if not specified is IBM-1047."}, "responseTimeout": {"type": "number", "description": "The maximum amount of time in seconds the z/OSMF Files TSO servlet should run before returning a response. Any request exceeding this amount of time will be terminated and return an error. Allowed values: 5 - 600"}}, "required": []}, "secure": {"items": {"enum": ["user", "password"]}}}}}, {"if": {"properties": {"type": {"const": "tso"}}}, "then": {"properties": {"properties": {"type": "object", "title": "TSO Profile", "description": "z/OS TSO/E User Profile", "properties": {"account": {"type": "string", "description": "Your z/OS TSO/E accounting information."}, "characterSet": {"type": "string", "description": "Character set for address space to convert messages and responses from UTF-8 to EBCDIC.", "default": "697"}, "codePage": {"type": "string", "description": "Codepage value for TSO/E address space to convert messages and responses from UTF-8 to EBCDIC.", "default": "1047"}, "columns": {"type": "number", "description": "The number of columns on a screen.", "default": 80}, "logonProcedure": {"type": "string", "description": "The logon procedure to use when creating TSO procedures on your behalf.", "default": "IZUFPROC"}, "regionSize": {"type": "number", "description": "Region size for the TSO/E address space.", "default": 4096}, "rows": {"type": "number", "description": "The number of rows on a screen.", "default": 24}}, "required": []}}}}, {"if": {"properties": {"type": {"const": "ssh"}}}, "then": {"properties": {"properties": {"type": "object", "title": "z/OS SSH Profile", "description": "z/OS SSH Profile", "properties": {"host": {"type": "string", "description": "The z/OS SSH server host name."}, "port": {"type": "number", "description": "The z/OS SSH server port.", "default": 22}, "user": {"type": "string", "description": "Mainframe user name, which can be the same as your TSO login."}, "password": {"type": "string", "description": "Mainframe password, which can be the same as your TSO password."}, "privateKey": {"type": "string", "description": "Path to a file containing your private key, that must match a public key stored in the server for authentication"}, "keyPassphrase": {"type": "string", "description": "Private key passphrase, which unlocks the private key."}, "handshakeTimeout": {"type": "number", "description": "How long in milliseconds to wait for the SSH handshake to complete."}}, "required": []}, "secure": {"items": {"enum": ["user", "password", "keyPassphrase"]}}}}}, {"if": {"properties": {"type": {"const": "zftp"}}}, "then": {"properties": {"properties": {"type": "object", "title": "Configuration profile for z/OS FTP", "description": "Configuration profile for z/OS FTP", "properties": {"host": {"type": "string", "description": "The hostname or IP address of the z/OS server to connect to."}, "port": {"type": "number", "description": "The port of the z/OS FTP server.", "default": 21}, "user": {"type": "string", "description": "Username for authentication on z/OS"}, "password": {"type": "string", "description": "Password to authenticate to FTP."}, "secureFtp": {"type": ["boolean", "null"], "description": "Set to true for both control and data connection encryption, 'control' for control connection encryption only, or 'implicit' for implicitly encrypted control connection (this mode is deprecated in modern times, but usually uses port 990). Note: Unfortunately, this plugin's functionality only works with FTP and FTPS, not 'SFTP' which is FTP over SSH.", "default": true}, "rejectUnauthorized": {"type": ["boolean", "null"], "description": "Reject self-signed certificates. Only specify this if you are connecting to a secure FTP instance."}, "servername": {"type": ["string", "null"], "description": "Server name for the SNI (Server Name Indication) TLS extension. Only specify if you are connecting securely"}, "connectionTimeout": {"type": "number", "description": "How long (in milliseconds) to wait for the control connection to be established.", "default": 10000}}}, "secure": {"items": {"enum": ["user", "password"]}}}}}, {"if": {"properties": {"type": {"const": "base"}}}, "then": {"properties": {"properties": {"type": "object", "title": "Base Profile", "description": "Base profile that stores values shared by multiple service profiles", "properties": {"host": {"type": "string", "description": "Host name of service on the mainframe."}, "port": {"type": "number", "description": "Port number of service on the mainframe."}, "user": {"type": "string", "description": "User name to authenticate to service on the mainframe."}, "password": {"type": "string", "description": "Password to authenticate to service on the mainframe."}, "rejectUnauthorized": {"type": "boolean", "description": "Reject self-signed certificates.", "default": true}, "tokenType": {"type": "string", "description": "The type of token to get and use for the API. Omit this option to use the default token type, which is provided by 'zowe auth login'."}, "tokenValue": {"type": "string", "description": "The value of the token to pass to the API."}, "certFile": {"type": "string", "description": "The file path to a certificate file to use for authentication"}, "certKeyFile": {"type": "string", "description": "The file path to a certificate key file to use for authentication"}}, "required": []}, "secure": {"items": {"enum": ["user", "password", "tokenValue"]}}}}}]}}}, "defaults": {"type": "object", "description": "Mapping of profile types to default profile names", "properties": {"zosmf": {"description": "Default zosmf profile", "type": "string"}, "tso": {"description": "Default tso profile", "type": "string"}, "ssh": {"description": "Default ssh profile", "type": "string"}, "zftp": {"description": "Default zftp profile", "type": "string"}, "base": {"description": "Default base profile", "type": "string"}}}, "autoStore": {"type": "boolean", "description": "If true, values you enter when prompted are stored for future use"}}} \ No newline at end of file