From 5982441e1fae875f8fbd2b3279632166024db977 Mon Sep 17 00:00:00 2001 From: Artem Rys Date: Thu, 16 Feb 2023 15:29:54 +0100 Subject: [PATCH 1/3] ci: update agreements CLA to 1.3 (#650) --- .github/workflows/agreements.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/agreements.yaml b/.github/workflows/agreements.yaml index 59132464a..4e10b4d00 100644 --- a/.github/workflows/agreements.yaml +++ b/.github/workflows/agreements.yaml @@ -7,7 +7,7 @@ on: jobs: call-workflow-agreements: - uses: splunk/addonfactory-github-workflows/.github/workflows/reusable-agreements.yaml@v1.2 + uses: splunk/addonfactory-github-workflows/.github/workflows/reusable-agreements.yaml@v1.3 secrets: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PERSONAL_ACCESS_TOKEN: ${{ secrets.PAT_CLATOOL }} From 29f171c083ea87174a6c50febcfaf6fb03c21f23 Mon Sep 17 00:00:00 2001 From: Tushar Balar Date: Mon, 20 Feb 2023 06:25:13 +0000 Subject: [PATCH 2/3] test: ADDON-59948 Added test cases for multilevel menu --- .../global_config_validator.py | 37 + tests/unit/test_global_config_validator.py | 15 + ...puts_multilevel_menu_duplicate_groups.json | 1076 +++++++++++++++++ ..._menu_invalid_groupname_or_grouptitle.json | 1075 ++++++++++++++++ ...multilevel_menu_invalid_groupservices.json | 1071 ++++++++++++++++ 5 files changed, 3274 insertions(+) create mode 100644 tests/unit/testdata/invalid_config_inputs_multilevel_menu_duplicate_groups.json create mode 100644 tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json create mode 100644 tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupservices.json diff --git a/splunk_add_on_ucc_framework/global_config_validator.py b/splunk_add_on_ucc_framework/global_config_validator.py index f3e89e765..9564fce85 100644 --- a/splunk_add_on_ucc_framework/global_config_validator.py +++ b/splunk_add_on_ucc_framework/global_config_validator.py @@ -268,6 +268,42 @@ def _validate_autoCompleteFields_duplicates( f"Duplicates found for autoCompleteFields: '{entity_label}'" ) + def _validate_multilevel_menu(self) -> None: + inputs = self._config.get("pages").get("inputs") + if inputs: + groups_menu = inputs.get("groupsMenu") + if groups_menu: + names, titles = [], [] + for group in groups_menu: + names.append(group.get("groupName").lower()) + titles.append(group.get("groupTitle").lower()) + groupservices = group.get("groupServices") + if groupservices: + for serviceName in groupservices: + if not any( + serviceName == service.get("name") + for service in inputs.get("services") + ): + raise GlobalConfigValidatorException( + f"{serviceName} ServiceName in the multi-level menu does not match any services name." + ) + else: + if not any( + group.get("groupName") == service.get("name") + and group.get("groupTitle") == service.get("title") + for service in inputs.get("services") + ): + raise GlobalConfigValidatorException( + f'{group.get("groupName")} groupName or {group.get("groupTitle")} groupTitle in the multi-level menu does not match any services name or title.' + ) + + if self._find_duplicates_in_list( + names + ) or self._find_duplicates_in_list(titles): + raise GlobalConfigValidatorException( + "Duplicates found for multi-level menu groups' names or titles." + ) + def _validate_entity_duplicates(self, entity: list) -> None: """ Validates duplicates in entity keys @@ -348,4 +384,5 @@ def validate(self) -> None: self._validate_custom_rest_handlers() self._validate_file_type_entity() self._validate_validators() + self._validate_multilevel_menu() self._validate_duplicates() diff --git a/tests/unit/test_global_config_validator.py b/tests/unit/test_global_config_validator.py index d7f574099..e066b3381 100644 --- a/tests/unit/test_global_config_validator.py +++ b/tests/unit/test_global_config_validator.py @@ -237,6 +237,21 @@ def test_config_validation_when_valid(filename): pytest.raises(GlobalConfigValidatorException), "Duplicates found for autoCompleteFields: 'Single Select'", ), + ( + "invalid_config_inputs_multilevel_menu_duplicate_groups.json", + pytest.raises(GlobalConfigValidatorException), + "Duplicates found for multi-level menu groups' names or titles.", + ), + ( + "invalid_config_inputs_multilevel_menu_invalid_groupservices.json", + pytest.raises(GlobalConfigValidatorException), + "example_input_three ServiceName in the multi-level menu does not match any services name.", + ), + ( + "invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json", + pytest.raises(GlobalConfigValidatorException), + "example_input_three groupName or Example Input Three groupTitle in the multi-level menu does not match any services name or title.", + ), ], ) def test_config_validation_when_error(filename, expectation, exception_message): diff --git a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_duplicate_groups.json b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_duplicate_groups.json new file mode 100644 index 000000000..f934123ab --- /dev/null +++ b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_duplicate_groups.json @@ -0,0 +1,1076 @@ +{ + "pages": { + "configuration": { + "tabs": [ + { + "name": "account", + "table": { + "actions": [ + "edit", + "delete", + "clone" + ], + "header": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Auth Type", + "field": "auth_type" + } + ] + }, + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "string", + "errorMsg": "Length of ID should be between 1 and 50", + "minLength": 1, + "maxLength": 50 + }, + { + "type": "regex", + "errorMsg": "Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + } + ], + "options": { + "placeholder": "Required" + }, + "field": "name", + "help": "Enter a unique name for this account.", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Environment", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "login.example.com", + "label": "Value1" + }, + { + "value": "test.example.com", + "label": "Value2" + }, + { + "value": "other", + "label": "Other" + } + ], + "display": true + }, + "help": "", + "field": "custom_endpoint", + "defaultValue": "login.example.com", + "required": true + }, + { + "type": "text", + "label": "Endpoint URL", + "help": "Enter the endpoint URL.", + "field": "endpoint", + "options": { + "display": false + } + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "account_checkbox", + "help": "This is an example checkbox for the account entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "account_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the account entity", + "required": true, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "type": "multipleSelect", + "label": "Example Multiple Select", + "field": "account_multiple_select", + "help": "This is an example multipleSelect for account entity", + "required": true, + "options": { + "items": [{ + "value": "one", + "label": "Option One" + }, + { + "value": "two", + "label": "Option Two" + } + ] + } + }, + { + "type": "text", + "label": "State", + "help": "This is a boolean field for developers to decide whether state parameter will be passed in the OAuth flow. Value: true|false", + "field": "oauth_state_enabled", + "options": { + "display": false + } + }, + { + "type": "oauth", + "field": "oauth", + "label": "Not used", + "options": { + "auth_type": [ + "basic", + "oauth" + ], + "basic": [ + { + "oauth_field": "username", + "label": "Username", + "help": "Enter the username for this account.", + "field": "username" + }, + { + "oauth_field": "password", + "label": "Password", + "encrypted": true, + "help": "Enter the password for this account.", + "field": "password" + }, + { + "oauth_field": "security_token", + "label": "Security Token", + "encrypted": true, + "help": "Enter the security token.", + "field": "token" + } + ], + "oauth": [ + { + "oauth_field": "client_id", + "label": "Client Id", + "field": "client_id", + "help": "Enter the Client Id for this account." + }, + { + "oauth_field": "client_secret", + "label": "Client Secret", + "field": "client_secret", + "encrypted": true, + "help": "Enter the Client Secret key for this account." + }, + { + "oauth_field": "redirect_url", + "label": "Redirect url", + "field": "redirect_url", + "help": "Copy and paste this URL into your app." + } + ], + "auth_code_endpoint": "/services/oauth2/authorize", + "access_token_endpoint": "/services/oauth2/token", + "oauth_timeout": 30 + } + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + }, + { + "type": "textarea", + "label": "Textarea Field", + "field": "textarea_field", + "help": "Help message", + "options": { + "rowsMin": 3, + "rowsMax": 15 + }, + "required": true + }, + { + "type": "file", + "label": "Upload File", + "help": "Upload service account's certificate", + "field": "service_account", + "options": { + "fileSupportMessage": "Here is the support message" + }, + "validators": [ + { + "type": "file", + "supportedFileTypes": ["json"] + } + ], + "encrypted": true, + "required": true + } + ], + "title": "Account" + }, + { + "name": "proxy", + "entity": [ + { + "type": "checkbox", + "label": "Enable", + "field": "proxy_enabled" + }, + { + "type": "singleSelect", + "label": "Proxy Type", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "http", + "label": "http" + }, + { + "value": "socks4", + "label": "socks4" + }, + { + "value": "socks5", + "label": "socks5" + } + ] + }, + "defaultValue": "http", + "field": "proxy_type" + }, + { + "type": "text", + "label": "Host", + "validators": [ + { + "type": "string", + "errorMsg": "Max host length is 4096", + "minLength": 0, + "maxLength": 4096 + } + ], + "field": "proxy_url" + }, + { + "type": "text", + "label": "Port", + "validators": [ + { + "type": "number", + "range": [ + 1, + 65535 + ] + } + ], + "field": "proxy_port" + }, + { + "type": "text", + "label": "Username", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of username is 50", + "minLength": 0, + "maxLength": 50 + } + ], + "field": "proxy_username" + }, + { + "type": "text", + "label": "Password", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of password is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "encrypted": true, + "field": "proxy_password" + }, + { + "type": "checkbox", + "label": "Reverse DNS resolution", + "field": "proxy_rdns" + } + ], + "options": { + "saveValidator": "function(formData) { if(!formData.proxy_enabled || formData.proxy_enabled === '0') {return true; } if(!formData.proxy_url) { return 'Proxy Host can not be empty'; } if(!formData.proxy_port) { return 'Proxy Port can not be empty'; } return true; }" + }, + "title": "Proxy" + }, + { + "name": "logging", + "entity": [ + { + "type": "singleSelect", + "label": "Log level", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "DEBUG", + "label": "DEBUG" + }, + { + "value": "INFO", + "label": "INFO" + }, + { + "value": "WARNING", + "label": "WARNING" + }, + { + "value": "ERROR", + "label": "ERROR" + }, + { + "value": "CRITICAL", + "label": "CRITICAL" + } + ] + }, + "defaultValue": "INFO", + "field": "loglevel" + } + ], + "title": "Logging" + }, + { + "name": "custom_abc", + "title": "Customized tab", + "entity": [ + { + "field": "testString", + "label": "Test String", + "type": "text", + "validators": [ + { + "type": "string", + "maxLength": 10, + "minLength": 5 + } + ] + }, + { + "field": "testNumber", + "label": "Test number", + "type": "text", + "validators": [ + { + "type": "number", + "range": [ + 1, + 10 + ] + } + ] + }, + { + "field": "testRegex", + "label": "Test regex", + "type": "text", + "validators": [ + { + "type": "regex", + "pattern": "^\\w+$", + "errorMsg": "Characters of Name should match regex ^\\w+$ ." + } + ] + }, + { + "field": "testEmail", + "label": "Test Email", + "type": "text", + "validators": [ + { + "type": "email" + } + ] + }, + { + "field": "testIpv4", + "label": "Test ipv4", + "type": "text", + "validators": [ + { + "type": "ipv4" + } + ] + }, + { + "field": "testDate", + "label": "Test date", + "type": "text", + "validators": [ + { + "type": "date" + } + ] + }, + { + "field": "testUrl", + "label": "Test url", + "type": "text", + "validators": [ + { + "type": "url" + } + ] + } + ] + } + ], + "title": "Configuration", + "description": "Set up your add-on" + }, + "inputs": { + "services": [ + { + "hook": { + "src": "Hook" + }, + "name": "example_input_one", + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "regex", + "errorMsg": "Input Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + }, + { + "type": "string", + "errorMsg": "Length of input name should be between 1 and 100", + "minLength": 1, + "maxLength": 100 + } + ], + "field": "name", + "help": "A unique name for the data input.", + "required": true + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "input_one_checkbox", + "help": "This is an example checkbox for the input one entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "input_one_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the input one entity", + "required": false, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "field": "singleSelectTest", + "label": "Single Select Group Test", + "type": "singleSelect", + "options": { + "createSearchChoice": true, + "autoCompleteFields": [ + { + "label": "Group1", + "children": [ + { + "value": "one", + "label": "One" + }, + { + "value": "two", + "label": "Two" + } + ] + }, + { + "label": "Group2", + "children": [ + { + "value": "three", + "label": "Three" + }, + { + "value": "four", + "label": "Four" + } + ] + } + ] + } + }, + { + "field": "multipleSelectTest", + "label": "Multiple Select Test", + "type": "multipleSelect", + "options": { + "delimiter": "|", + "items": [ + { + "value": "a", + "label": "A" + }, + { + "value": "b", + "label": "B" + } + ] + } + }, + { + "type": "text", + "label": "Interval", + "validators": [ + { + "type": "regex", + "errorMsg": "Interval must be an integer.", + "pattern": "^\\-[1-9]\\d*$|^\\d*$" + } + ], + "field": "interval", + "help": "Time interval of the data input, in seconds.", + "required": true + }, + { + "type": "singleSelect", + "label": "Index", + "validators": [ + { + "type": "string", + "errorMsg": "Length of index name should be between 1 and 80.", + "minLength": 1, + "maxLength": 80 + } + ], + "defaultValue": "default", + "options": { + "endpointUrl": "data/indexes", + "denyList": "^_.*$", + "createSearchChoice": true + }, + "field": "index", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Account", + "options": { + "referenceName": "account" + }, + "help": "", + "field": "account", + "required": true + }, + { + "type": "text", + "label": "Object", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "field": "object", + "help": "The name of the object to query for.", + "required": true + }, + { + "type": "text", + "label": "Object Fields", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "field": "object_fields", + "help": "Object fields from which to collect data. Delimit multiple fields using a comma.", + "required": true + }, + { + "type": "text", + "label": "Order By", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "defaultValue": "LastModifiedDate", + "field": "order_by", + "help": "The datetime field by which to query results in ascending order for indexing.", + "required": true + }, + { + "type": "radio", + "label": "Use existing data input?", + "field": "use_existing_checkpoint", + "defaultValue": "yes", + "help": "Data input already exists. Select `No` if you want to reset the data collection.", + "required": false, + "options": { + "items": [ + { + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": false + } + }, + { + "type": "text", + "label": "Query Start Date", + "validators": [ + { + "type": "regex", + "errorMsg": "Invalid date and time format", + "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" + } + ], + "field": "start_date", + "help": "The datetime after which to query and index records, in this format: \"YYYY-MM-DDThh:mm:ss.000z\".\nDefaults to 90 days earlier from now.", + "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", + "required": false + }, + { + "type": "text", + "label": "Limit", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "defaultValue": "1000", + "field": "limit", + "help": "The maximum number of results returned by the query.", + "required": false + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + } + ], + "title": "Example Input One" + }, + { + "name": "example_input_two", + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "regex", + "errorMsg": "Input Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + }, + { + "type": "string", + "errorMsg": "Length of input name should be between 1 and 100", + "minLength": 1, + "maxLength": 100 + } + ], + "field": "name", + "help": "A unique name for the data input.", + "required": true + }, + { + "type": "text", + "label": "Interval", + "validators": [ + { + "type": "regex", + "errorMsg": "Interval must be an integer.", + "pattern": "^\\-[1-9]\\d*$|^\\d*$" + } + ], + "field": "interval", + "help": "Time interval of the data input, in seconds .", + "required": true + }, + { + "type": "singleSelect", + "label": "Index", + "validators": [ + { + "type": "string", + "errorMsg": "Length of index name should be between 1 and 80.", + "minLength": 1, + "maxLength": 80 + } + ], + "defaultValue": "default", + "options": { + "endpointUrl": "data/indexes", + "denyList": "^_.*$", + "createSearchChoice": true + }, + "field": "index", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Account", + "options": { + "referenceName": "account" + }, + "help": "", + "field": "account", + "required": true + }, + { + "type": "multipleSelect", + "label": "Example Multiple Select", + "field": "input_two_multiple_select", + "help": "This is an example multipleSelect for input two entity", + "required": true, + "options": { + "items": [{ + "value": "one", + "label": "Option One" + }, + { + "value": "two", + "label": "Option Two" + } + ] + } + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "input_two_checkbox", + "help": "This is an example checkbox for the input two entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "input_two_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the input two entity", + "required": false, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "type": "radio", + "label": "Use existing data input?", + "field": "use_existing_checkpoint", + "defaultValue": "yes", + "help": "Data input already exists. Select `No` if you want to reset the data collection.", + "required": false, + "options": { + "items": [ + { + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": false + } + }, + { + "type": "text", + "label": "Query Start Date", + "validators": [ + { + "type": "regex", + "errorMsg": "Invalid date and time format", + "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" + } + ], + "field": "start_date", + "help": "The date and time, in \"YYYY-MM-DDThh:mm:ss.000z\" format, after which to query and index records. \nThe default is 90 days before today.", + "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", + "required": false + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + } + ], + "title": "Example Input Two" + } + ], + "title": "Inputs", + "description": "Manage your data inputs", + "table": { + "actions": [ + "edit", + "enable", + "delete", + "clone" + ], + "header": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Account Name", + "field": "account" + }, + { + "label": "Interval", + "field": "interval" + }, + { + "label": "Index", + "field": "index" + }, + { + "label": "Status", + "field": "disabled" + } + ], + "moreInfo": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Interval", + "field": "interval" + }, + { + "label": "Index", + "field": "index" + }, + { + "label": "Status", + "field": "disabled", + "mapping": { + "true": "Disabled", + "false": "Enabled" + } + }, + { + "label": "Example Account", + "field": "account" + }, + { + "label": "Object", + "field": "object" + }, + { + "label": "Object Fields", + "field": "object_fields" + }, + { + "label": "Order By", + "field": "order_by" + }, + { + "label": "Query Start Date", + "field": "start_date" + }, + { + "label": "Limit", + "field": "limit" + } + ] + }, + "groupsMenu": [ + { + "groupName": "group_one", + "groupTitle": "Group One", + "groupServices": ["example_input_one", "example_input_two"] + }, + { + "groupName": "group_one", + "groupTitle": "Group One", + "groupServices": ["example_input_one", "example_input_two"] + } + ] + + } + }, + "alerts": [ + { + "name": "test_alert", + "label": "Test Alert", + "description": "Description for test Alert Action", + "activeResponse": { + "task": [ + "Create", + "Update" + ], + "supportsAdhoc": true, + "subject": [ + "endpoint" + ], + "category": [ + "Information Conveyance", + "Information Portrayal" + ], + "technology": [ + { + "version": [ + "1.0.0" + ], + "product": "Test Incident Update", + "vendor": "Splunk" + } + ], + "drilldownUri": "search?q=search%20index%3D\"_internal\"&earliest=0&latest=", + "sourcetype": "test:incident" + }, + "entity": [ + { + "type": "text", + "label": "Name", + "field": "name", + "defaultValue": "xyz", + "required": true, + "help": "Please enter your name" + }, + { + "type": "checkbox", + "label": "All Incidents", + "field": "all_incidents", + "defaultValue": 0, + "required": false, + "help": "Tick if you want to update all incidents/problems" + }, + { + "type": "singleSelect", + "label": "Table List", + "field": "table_list", + "options": { + "items": [ + { + "value": "Incident", + "label": "incident" + }, + { + "value": "Problem", + "label": "problem" + } + ] + }, + "help": "Please select the table", + "required": false, + "defaultValue": "problem" + }, + { + "type": "radio", + "label": "Action:", + "field": "action", + "options": { + "items": [ + { + "value": "Update", + "label": "update" + }, + { + "value": "Delete", + "label": "delete" + } + ] + }, + "help": "Select the action you want to perform", + "required": true, + "defaultValue": "two" + }, + { + "type": "singleSelectSplunkSearch", + "label": "Select Account", + "field": "account", + "search": "| rest /servicesNS/nobody/TA-SNOW/admin/TA_SNOW_account | dedup title", + "valueField": "title", + "labelField": "title", + "help": "Select the account from the dropdown", + "required": true + } + ] + } + ], + "meta": { + "apiVersion": "3.2.0", + "name": "Splunk_TA_UCCExample", + "restRoot": "splunk_ta_uccexample", + "version": "1.0.0", + "displayName": "Splunk UCC test Add-on" + } +} diff --git a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json new file mode 100644 index 000000000..232bdb1c0 --- /dev/null +++ b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json @@ -0,0 +1,1075 @@ +{ + "pages": { + "configuration": { + "tabs": [ + { + "name": "account", + "table": { + "actions": [ + "edit", + "delete", + "clone" + ], + "header": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Auth Type", + "field": "auth_type" + } + ] + }, + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "string", + "errorMsg": "Length of ID should be between 1 and 50", + "minLength": 1, + "maxLength": 50 + }, + { + "type": "regex", + "errorMsg": "Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + } + ], + "options": { + "placeholder": "Required" + }, + "field": "name", + "help": "Enter a unique name for this account.", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Environment", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "login.example.com", + "label": "Value1" + }, + { + "value": "test.example.com", + "label": "Value2" + }, + { + "value": "other", + "label": "Other" + } + ], + "display": true + }, + "help": "", + "field": "custom_endpoint", + "defaultValue": "login.example.com", + "required": true + }, + { + "type": "text", + "label": "Endpoint URL", + "help": "Enter the endpoint URL.", + "field": "endpoint", + "options": { + "display": false + } + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "account_checkbox", + "help": "This is an example checkbox for the account entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "account_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the account entity", + "required": true, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "type": "multipleSelect", + "label": "Example Multiple Select", + "field": "account_multiple_select", + "help": "This is an example multipleSelect for account entity", + "required": true, + "options": { + "items": [{ + "value": "one", + "label": "Option One" + }, + { + "value": "two", + "label": "Option Two" + } + ] + } + }, + { + "type": "text", + "label": "State", + "help": "This is a boolean field for developers to decide whether state parameter will be passed in the OAuth flow. Value: true|false", + "field": "oauth_state_enabled", + "options": { + "display": false + } + }, + { + "type": "oauth", + "field": "oauth", + "label": "Not used", + "options": { + "auth_type": [ + "basic", + "oauth" + ], + "basic": [ + { + "oauth_field": "username", + "label": "Username", + "help": "Enter the username for this account.", + "field": "username" + }, + { + "oauth_field": "password", + "label": "Password", + "encrypted": true, + "help": "Enter the password for this account.", + "field": "password" + }, + { + "oauth_field": "security_token", + "label": "Security Token", + "encrypted": true, + "help": "Enter the security token.", + "field": "token" + } + ], + "oauth": [ + { + "oauth_field": "client_id", + "label": "Client Id", + "field": "client_id", + "help": "Enter the Client Id for this account." + }, + { + "oauth_field": "client_secret", + "label": "Client Secret", + "field": "client_secret", + "encrypted": true, + "help": "Enter the Client Secret key for this account." + }, + { + "oauth_field": "redirect_url", + "label": "Redirect url", + "field": "redirect_url", + "help": "Copy and paste this URL into your app." + } + ], + "auth_code_endpoint": "/services/oauth2/authorize", + "access_token_endpoint": "/services/oauth2/token", + "oauth_timeout": 30 + } + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + }, + { + "type": "textarea", + "label": "Textarea Field", + "field": "textarea_field", + "help": "Help message", + "options": { + "rowsMin": 3, + "rowsMax": 15 + }, + "required": true + }, + { + "type": "file", + "label": "Upload File", + "help": "Upload service account's certificate", + "field": "service_account", + "options": { + "fileSupportMessage": "Here is the support message" + }, + "validators": [ + { + "type": "file", + "supportedFileTypes": ["json"] + } + ], + "encrypted": true, + "required": true + } + ], + "title": "Account" + }, + { + "name": "proxy", + "entity": [ + { + "type": "checkbox", + "label": "Enable", + "field": "proxy_enabled" + }, + { + "type": "singleSelect", + "label": "Proxy Type", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "http", + "label": "http" + }, + { + "value": "socks4", + "label": "socks4" + }, + { + "value": "socks5", + "label": "socks5" + } + ] + }, + "defaultValue": "http", + "field": "proxy_type" + }, + { + "type": "text", + "label": "Host", + "validators": [ + { + "type": "string", + "errorMsg": "Max host length is 4096", + "minLength": 0, + "maxLength": 4096 + } + ], + "field": "proxy_url" + }, + { + "type": "text", + "label": "Port", + "validators": [ + { + "type": "number", + "range": [ + 1, + 65535 + ] + } + ], + "field": "proxy_port" + }, + { + "type": "text", + "label": "Username", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of username is 50", + "minLength": 0, + "maxLength": 50 + } + ], + "field": "proxy_username" + }, + { + "type": "text", + "label": "Password", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of password is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "encrypted": true, + "field": "proxy_password" + }, + { + "type": "checkbox", + "label": "Reverse DNS resolution", + "field": "proxy_rdns" + } + ], + "options": { + "saveValidator": "function(formData) { if(!formData.proxy_enabled || formData.proxy_enabled === '0') {return true; } if(!formData.proxy_url) { return 'Proxy Host can not be empty'; } if(!formData.proxy_port) { return 'Proxy Port can not be empty'; } return true; }" + }, + "title": "Proxy" + }, + { + "name": "logging", + "entity": [ + { + "type": "singleSelect", + "label": "Log level", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "DEBUG", + "label": "DEBUG" + }, + { + "value": "INFO", + "label": "INFO" + }, + { + "value": "WARNING", + "label": "WARNING" + }, + { + "value": "ERROR", + "label": "ERROR" + }, + { + "value": "CRITICAL", + "label": "CRITICAL" + } + ] + }, + "defaultValue": "INFO", + "field": "loglevel" + } + ], + "title": "Logging" + }, + { + "name": "custom_abc", + "title": "Customized tab", + "entity": [ + { + "field": "testString", + "label": "Test String", + "type": "text", + "validators": [ + { + "type": "string", + "maxLength": 10, + "minLength": 5 + } + ] + }, + { + "field": "testNumber", + "label": "Test number", + "type": "text", + "validators": [ + { + "type": "number", + "range": [ + 1, + 10 + ] + } + ] + }, + { + "field": "testRegex", + "label": "Test regex", + "type": "text", + "validators": [ + { + "type": "regex", + "pattern": "^\\w+$", + "errorMsg": "Characters of Name should match regex ^\\w+$ ." + } + ] + }, + { + "field": "testEmail", + "label": "Test Email", + "type": "text", + "validators": [ + { + "type": "email" + } + ] + }, + { + "field": "testIpv4", + "label": "Test ipv4", + "type": "text", + "validators": [ + { + "type": "ipv4" + } + ] + }, + { + "field": "testDate", + "label": "Test date", + "type": "text", + "validators": [ + { + "type": "date" + } + ] + }, + { + "field": "testUrl", + "label": "Test url", + "type": "text", + "validators": [ + { + "type": "url" + } + ] + } + ] + } + ], + "title": "Configuration", + "description": "Set up your add-on" + }, + "inputs": { + "services": [ + { + "hook": { + "src": "Hook" + }, + "name": "example_input_one", + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "regex", + "errorMsg": "Input Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + }, + { + "type": "string", + "errorMsg": "Length of input name should be between 1 and 100", + "minLength": 1, + "maxLength": 100 + } + ], + "field": "name", + "help": "A unique name for the data input.", + "required": true + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "input_one_checkbox", + "help": "This is an example checkbox for the input one entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "input_one_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the input one entity", + "required": false, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "field": "singleSelectTest", + "label": "Single Select Group Test", + "type": "singleSelect", + "options": { + "createSearchChoice": true, + "autoCompleteFields": [ + { + "label": "Group1", + "children": [ + { + "value": "one", + "label": "One" + }, + { + "value": "two", + "label": "Two" + } + ] + }, + { + "label": "Group2", + "children": [ + { + "value": "three", + "label": "Three" + }, + { + "value": "four", + "label": "Four" + } + ] + } + ] + } + }, + { + "field": "multipleSelectTest", + "label": "Multiple Select Test", + "type": "multipleSelect", + "options": { + "delimiter": "|", + "items": [ + { + "value": "a", + "label": "A" + }, + { + "value": "b", + "label": "B" + } + ] + } + }, + { + "type": "text", + "label": "Interval", + "validators": [ + { + "type": "regex", + "errorMsg": "Interval must be an integer.", + "pattern": "^\\-[1-9]\\d*$|^\\d*$" + } + ], + "field": "interval", + "help": "Time interval of the data input, in seconds.", + "required": true + }, + { + "type": "singleSelect", + "label": "Index", + "validators": [ + { + "type": "string", + "errorMsg": "Length of index name should be between 1 and 80.", + "minLength": 1, + "maxLength": 80 + } + ], + "defaultValue": "default", + "options": { + "endpointUrl": "data/indexes", + "denyList": "^_.*$", + "createSearchChoice": true + }, + "field": "index", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Account", + "options": { + "referenceName": "account" + }, + "help": "", + "field": "account", + "required": true + }, + { + "type": "text", + "label": "Object", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "field": "object", + "help": "The name of the object to query for.", + "required": true + }, + { + "type": "text", + "label": "Object Fields", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "field": "object_fields", + "help": "Object fields from which to collect data. Delimit multiple fields using a comma.", + "required": true + }, + { + "type": "text", + "label": "Order By", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "defaultValue": "LastModifiedDate", + "field": "order_by", + "help": "The datetime field by which to query results in ascending order for indexing.", + "required": true + }, + { + "type": "radio", + "label": "Use existing data input?", + "field": "use_existing_checkpoint", + "defaultValue": "yes", + "help": "Data input already exists. Select `No` if you want to reset the data collection.", + "required": false, + "options": { + "items": [ + { + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": false + } + }, + { + "type": "text", + "label": "Query Start Date", + "validators": [ + { + "type": "regex", + "errorMsg": "Invalid date and time format", + "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" + } + ], + "field": "start_date", + "help": "The datetime after which to query and index records, in this format: \"YYYY-MM-DDThh:mm:ss.000z\".\nDefaults to 90 days earlier from now.", + "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", + "required": false + }, + { + "type": "text", + "label": "Limit", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "defaultValue": "1000", + "field": "limit", + "help": "The maximum number of results returned by the query.", + "required": false + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + } + ], + "title": "Example Input One" + }, + { + "name": "example_input_two", + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "regex", + "errorMsg": "Input Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + }, + { + "type": "string", + "errorMsg": "Length of input name should be between 1 and 100", + "minLength": 1, + "maxLength": 100 + } + ], + "field": "name", + "help": "A unique name for the data input.", + "required": true + }, + { + "type": "text", + "label": "Interval", + "validators": [ + { + "type": "regex", + "errorMsg": "Interval must be an integer.", + "pattern": "^\\-[1-9]\\d*$|^\\d*$" + } + ], + "field": "interval", + "help": "Time interval of the data input, in seconds .", + "required": true + }, + { + "type": "singleSelect", + "label": "Index", + "validators": [ + { + "type": "string", + "errorMsg": "Length of index name should be between 1 and 80.", + "minLength": 1, + "maxLength": 80 + } + ], + "defaultValue": "default", + "options": { + "endpointUrl": "data/indexes", + "denyList": "^_.*$", + "createSearchChoice": true + }, + "field": "index", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Account", + "options": { + "referenceName": "account" + }, + "help": "", + "field": "account", + "required": true + }, + { + "type": "multipleSelect", + "label": "Example Multiple Select", + "field": "input_two_multiple_select", + "help": "This is an example multipleSelect for input two entity", + "required": true, + "options": { + "items": [{ + "value": "one", + "label": "Option One" + }, + { + "value": "two", + "label": "Option Two" + } + ] + } + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "input_two_checkbox", + "help": "This is an example checkbox for the input two entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "input_two_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the input two entity", + "required": false, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "type": "radio", + "label": "Use existing data input?", + "field": "use_existing_checkpoint", + "defaultValue": "yes", + "help": "Data input already exists. Select `No` if you want to reset the data collection.", + "required": false, + "options": { + "items": [ + { + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": false + } + }, + { + "type": "text", + "label": "Query Start Date", + "validators": [ + { + "type": "regex", + "errorMsg": "Invalid date and time format", + "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" + } + ], + "field": "start_date", + "help": "The date and time, in \"YYYY-MM-DDThh:mm:ss.000z\" format, after which to query and index records. \nThe default is 90 days before today.", + "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", + "required": false + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + } + ], + "title": "Example Input Two" + } + ], + "title": "Inputs", + "description": "Manage your data inputs", + "table": { + "actions": [ + "edit", + "enable", + "delete", + "clone" + ], + "header": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Account Name", + "field": "account" + }, + { + "label": "Interval", + "field": "interval" + }, + { + "label": "Index", + "field": "index" + }, + { + "label": "Status", + "field": "disabled" + } + ], + "moreInfo": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Interval", + "field": "interval" + }, + { + "label": "Index", + "field": "index" + }, + { + "label": "Status", + "field": "disabled", + "mapping": { + "true": "Disabled", + "false": "Enabled" + } + }, + { + "label": "Example Account", + "field": "account" + }, + { + "label": "Object", + "field": "object" + }, + { + "label": "Object Fields", + "field": "object_fields" + }, + { + "label": "Order By", + "field": "order_by" + }, + { + "label": "Query Start Date", + "field": "start_date" + }, + { + "label": "Limit", + "field": "limit" + } + ] + }, + "groupsMenu": [ + { + "groupName": "group_one", + "groupTitle": "Group One", + "groupServices": ["example_input_one", "example_input_two"] + }, + { + "groupName": "example_input_three", + "groupTitle": "Example Input Three" + } + ] + + } + }, + "alerts": [ + { + "name": "test_alert", + "label": "Test Alert", + "description": "Description for test Alert Action", + "activeResponse": { + "task": [ + "Create", + "Update" + ], + "supportsAdhoc": true, + "subject": [ + "endpoint" + ], + "category": [ + "Information Conveyance", + "Information Portrayal" + ], + "technology": [ + { + "version": [ + "1.0.0" + ], + "product": "Test Incident Update", + "vendor": "Splunk" + } + ], + "drilldownUri": "search?q=search%20index%3D\"_internal\"&earliest=0&latest=", + "sourcetype": "test:incident" + }, + "entity": [ + { + "type": "text", + "label": "Name", + "field": "name", + "defaultValue": "xyz", + "required": true, + "help": "Please enter your name" + }, + { + "type": "checkbox", + "label": "All Incidents", + "field": "all_incidents", + "defaultValue": 0, + "required": false, + "help": "Tick if you want to update all incidents/problems" + }, + { + "type": "singleSelect", + "label": "Table List", + "field": "table_list", + "options": { + "items": [ + { + "value": "Incident", + "label": "incident" + }, + { + "value": "Problem", + "label": "problem" + } + ] + }, + "help": "Please select the table", + "required": false, + "defaultValue": "problem" + }, + { + "type": "radio", + "label": "Action:", + "field": "action", + "options": { + "items": [ + { + "value": "Update", + "label": "update" + }, + { + "value": "Delete", + "label": "delete" + } + ] + }, + "help": "Select the action you want to perform", + "required": true, + "defaultValue": "two" + }, + { + "type": "singleSelectSplunkSearch", + "label": "Select Account", + "field": "account", + "search": "| rest /servicesNS/nobody/TA-SNOW/admin/TA_SNOW_account | dedup title", + "valueField": "title", + "labelField": "title", + "help": "Select the account from the dropdown", + "required": true + } + ] + } + ], + "meta": { + "apiVersion": "3.2.0", + "name": "Splunk_TA_UCCExample", + "restRoot": "splunk_ta_uccexample", + "version": "1.0.0", + "displayName": "Splunk UCC test Add-on" + } +} diff --git a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupservices.json b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupservices.json new file mode 100644 index 000000000..ad344b035 --- /dev/null +++ b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupservices.json @@ -0,0 +1,1071 @@ +{ + "pages": { + "configuration": { + "tabs": [ + { + "name": "account", + "table": { + "actions": [ + "edit", + "delete", + "clone" + ], + "header": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Auth Type", + "field": "auth_type" + } + ] + }, + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "string", + "errorMsg": "Length of ID should be between 1 and 50", + "minLength": 1, + "maxLength": 50 + }, + { + "type": "regex", + "errorMsg": "Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + } + ], + "options": { + "placeholder": "Required" + }, + "field": "name", + "help": "Enter a unique name for this account.", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Environment", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "login.example.com", + "label": "Value1" + }, + { + "value": "test.example.com", + "label": "Value2" + }, + { + "value": "other", + "label": "Other" + } + ], + "display": true + }, + "help": "", + "field": "custom_endpoint", + "defaultValue": "login.example.com", + "required": true + }, + { + "type": "text", + "label": "Endpoint URL", + "help": "Enter the endpoint URL.", + "field": "endpoint", + "options": { + "display": false + } + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "account_checkbox", + "help": "This is an example checkbox for the account entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "account_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the account entity", + "required": true, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "type": "multipleSelect", + "label": "Example Multiple Select", + "field": "account_multiple_select", + "help": "This is an example multipleSelect for account entity", + "required": true, + "options": { + "items": [{ + "value": "one", + "label": "Option One" + }, + { + "value": "two", + "label": "Option Two" + } + ] + } + }, + { + "type": "text", + "label": "State", + "help": "This is a boolean field for developers to decide whether state parameter will be passed in the OAuth flow. Value: true|false", + "field": "oauth_state_enabled", + "options": { + "display": false + } + }, + { + "type": "oauth", + "field": "oauth", + "label": "Not used", + "options": { + "auth_type": [ + "basic", + "oauth" + ], + "basic": [ + { + "oauth_field": "username", + "label": "Username", + "help": "Enter the username for this account.", + "field": "username" + }, + { + "oauth_field": "password", + "label": "Password", + "encrypted": true, + "help": "Enter the password for this account.", + "field": "password" + }, + { + "oauth_field": "security_token", + "label": "Security Token", + "encrypted": true, + "help": "Enter the security token.", + "field": "token" + } + ], + "oauth": [ + { + "oauth_field": "client_id", + "label": "Client Id", + "field": "client_id", + "help": "Enter the Client Id for this account." + }, + { + "oauth_field": "client_secret", + "label": "Client Secret", + "field": "client_secret", + "encrypted": true, + "help": "Enter the Client Secret key for this account." + }, + { + "oauth_field": "redirect_url", + "label": "Redirect url", + "field": "redirect_url", + "help": "Copy and paste this URL into your app." + } + ], + "auth_code_endpoint": "/services/oauth2/authorize", + "access_token_endpoint": "/services/oauth2/token", + "oauth_timeout": 30 + } + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + }, + { + "type": "textarea", + "label": "Textarea Field", + "field": "textarea_field", + "help": "Help message", + "options": { + "rowsMin": 3, + "rowsMax": 15 + }, + "required": true + }, + { + "type": "file", + "label": "Upload File", + "help": "Upload service account's certificate", + "field": "service_account", + "options": { + "fileSupportMessage": "Here is the support message" + }, + "validators": [ + { + "type": "file", + "supportedFileTypes": ["json"] + } + ], + "encrypted": true, + "required": true + } + ], + "title": "Account" + }, + { + "name": "proxy", + "entity": [ + { + "type": "checkbox", + "label": "Enable", + "field": "proxy_enabled" + }, + { + "type": "singleSelect", + "label": "Proxy Type", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "http", + "label": "http" + }, + { + "value": "socks4", + "label": "socks4" + }, + { + "value": "socks5", + "label": "socks5" + } + ] + }, + "defaultValue": "http", + "field": "proxy_type" + }, + { + "type": "text", + "label": "Host", + "validators": [ + { + "type": "string", + "errorMsg": "Max host length is 4096", + "minLength": 0, + "maxLength": 4096 + } + ], + "field": "proxy_url" + }, + { + "type": "text", + "label": "Port", + "validators": [ + { + "type": "number", + "range": [ + 1, + 65535 + ] + } + ], + "field": "proxy_port" + }, + { + "type": "text", + "label": "Username", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of username is 50", + "minLength": 0, + "maxLength": 50 + } + ], + "field": "proxy_username" + }, + { + "type": "text", + "label": "Password", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of password is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "encrypted": true, + "field": "proxy_password" + }, + { + "type": "checkbox", + "label": "Reverse DNS resolution", + "field": "proxy_rdns" + } + ], + "options": { + "saveValidator": "function(formData) { if(!formData.proxy_enabled || formData.proxy_enabled === '0') {return true; } if(!formData.proxy_url) { return 'Proxy Host can not be empty'; } if(!formData.proxy_port) { return 'Proxy Port can not be empty'; } return true; }" + }, + "title": "Proxy" + }, + { + "name": "logging", + "entity": [ + { + "type": "singleSelect", + "label": "Log level", + "options": { + "disableSearch": true, + "autoCompleteFields": [ + { + "value": "DEBUG", + "label": "DEBUG" + }, + { + "value": "INFO", + "label": "INFO" + }, + { + "value": "WARNING", + "label": "WARNING" + }, + { + "value": "ERROR", + "label": "ERROR" + }, + { + "value": "CRITICAL", + "label": "CRITICAL" + } + ] + }, + "defaultValue": "INFO", + "field": "loglevel" + } + ], + "title": "Logging" + }, + { + "name": "custom_abc", + "title": "Customized tab", + "entity": [ + { + "field": "testString", + "label": "Test String", + "type": "text", + "validators": [ + { + "type": "string", + "maxLength": 10, + "minLength": 5 + } + ] + }, + { + "field": "testNumber", + "label": "Test number", + "type": "text", + "validators": [ + { + "type": "number", + "range": [ + 1, + 10 + ] + } + ] + }, + { + "field": "testRegex", + "label": "Test regex", + "type": "text", + "validators": [ + { + "type": "regex", + "pattern": "^\\w+$", + "errorMsg": "Characters of Name should match regex ^\\w+$ ." + } + ] + }, + { + "field": "testEmail", + "label": "Test Email", + "type": "text", + "validators": [ + { + "type": "email" + } + ] + }, + { + "field": "testIpv4", + "label": "Test ipv4", + "type": "text", + "validators": [ + { + "type": "ipv4" + } + ] + }, + { + "field": "testDate", + "label": "Test date", + "type": "text", + "validators": [ + { + "type": "date" + } + ] + }, + { + "field": "testUrl", + "label": "Test url", + "type": "text", + "validators": [ + { + "type": "url" + } + ] + } + ] + } + ], + "title": "Configuration", + "description": "Set up your add-on" + }, + "inputs": { + "services": [ + { + "hook": { + "src": "Hook" + }, + "name": "example_input_one", + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "regex", + "errorMsg": "Input Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + }, + { + "type": "string", + "errorMsg": "Length of input name should be between 1 and 100", + "minLength": 1, + "maxLength": 100 + } + ], + "field": "name", + "help": "A unique name for the data input.", + "required": true + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "input_one_checkbox", + "help": "This is an example checkbox for the input one entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "input_one_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the input one entity", + "required": false, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "field": "singleSelectTest", + "label": "Single Select Group Test", + "type": "singleSelect", + "options": { + "createSearchChoice": true, + "autoCompleteFields": [ + { + "label": "Group1", + "children": [ + { + "value": "one", + "label": "One" + }, + { + "value": "two", + "label": "Two" + } + ] + }, + { + "label": "Group2", + "children": [ + { + "value": "three", + "label": "Three" + }, + { + "value": "four", + "label": "Four" + } + ] + } + ] + } + }, + { + "field": "multipleSelectTest", + "label": "Multiple Select Test", + "type": "multipleSelect", + "options": { + "delimiter": "|", + "items": [ + { + "value": "a", + "label": "A" + }, + { + "value": "b", + "label": "B" + } + ] + } + }, + { + "type": "text", + "label": "Interval", + "validators": [ + { + "type": "regex", + "errorMsg": "Interval must be an integer.", + "pattern": "^\\-[1-9]\\d*$|^\\d*$" + } + ], + "field": "interval", + "help": "Time interval of the data input, in seconds.", + "required": true + }, + { + "type": "singleSelect", + "label": "Index", + "validators": [ + { + "type": "string", + "errorMsg": "Length of index name should be between 1 and 80.", + "minLength": 1, + "maxLength": 80 + } + ], + "defaultValue": "default", + "options": { + "endpointUrl": "data/indexes", + "denyList": "^_.*$", + "createSearchChoice": true + }, + "field": "index", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Account", + "options": { + "referenceName": "account" + }, + "help": "", + "field": "account", + "required": true + }, + { + "type": "text", + "label": "Object", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "field": "object", + "help": "The name of the object to query for.", + "required": true + }, + { + "type": "text", + "label": "Object Fields", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "field": "object_fields", + "help": "Object fields from which to collect data. Delimit multiple fields using a comma.", + "required": true + }, + { + "type": "text", + "label": "Order By", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "defaultValue": "LastModifiedDate", + "field": "order_by", + "help": "The datetime field by which to query results in ascending order for indexing.", + "required": true + }, + { + "type": "radio", + "label": "Use existing data input?", + "field": "use_existing_checkpoint", + "defaultValue": "yes", + "help": "Data input already exists. Select `No` if you want to reset the data collection.", + "required": false, + "options": { + "items": [ + { + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": false + } + }, + { + "type": "text", + "label": "Query Start Date", + "validators": [ + { + "type": "regex", + "errorMsg": "Invalid date and time format", + "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" + } + ], + "field": "start_date", + "help": "The datetime after which to query and index records, in this format: \"YYYY-MM-DDThh:mm:ss.000z\".\nDefaults to 90 days earlier from now.", + "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", + "required": false + }, + { + "type": "text", + "label": "Limit", + "validators": [ + { + "type": "string", + "errorMsg": "Max length of text input is 8192", + "minLength": 0, + "maxLength": 8192 + } + ], + "defaultValue": "1000", + "field": "limit", + "help": "The maximum number of results returned by the query.", + "required": false + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + } + ], + "title": "Example Input One" + }, + { + "name": "example_input_two", + "entity": [ + { + "type": "text", + "label": "Name", + "validators": [ + { + "type": "regex", + "errorMsg": "Input Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", + "pattern": "^[a-zA-Z]\\w*$" + }, + { + "type": "string", + "errorMsg": "Length of input name should be between 1 and 100", + "minLength": 1, + "maxLength": 100 + } + ], + "field": "name", + "help": "A unique name for the data input.", + "required": true + }, + { + "type": "text", + "label": "Interval", + "validators": [ + { + "type": "regex", + "errorMsg": "Interval must be an integer.", + "pattern": "^\\-[1-9]\\d*$|^\\d*$" + } + ], + "field": "interval", + "help": "Time interval of the data input, in seconds .", + "required": true + }, + { + "type": "singleSelect", + "label": "Index", + "validators": [ + { + "type": "string", + "errorMsg": "Length of index name should be between 1 and 80.", + "minLength": 1, + "maxLength": 80 + } + ], + "defaultValue": "default", + "options": { + "endpointUrl": "data/indexes", + "denyList": "^_.*$", + "createSearchChoice": true + }, + "field": "index", + "required": true + }, + { + "type": "singleSelect", + "label": "Example Account", + "options": { + "referenceName": "account" + }, + "help": "", + "field": "account", + "required": true + }, + { + "type": "multipleSelect", + "label": "Example Multiple Select", + "field": "input_two_multiple_select", + "help": "This is an example multipleSelect for input two entity", + "required": true, + "options": { + "items": [{ + "value": "one", + "label": "Option One" + }, + { + "value": "two", + "label": "Option Two" + } + ] + } + }, + { + "type": "checkbox", + "label": "Example Checkbox", + "field": "input_two_checkbox", + "help": "This is an example checkbox for the input two entity" + }, + { + "type": "radio", + "label": "Example Radio", + "field": "input_two_radio", + "defaultValue": "yes", + "help": "This is an example radio button for the input two entity", + "required": false, + "options": { + "items": [{ + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": true + } + }, + { + "type": "radio", + "label": "Use existing data input?", + "field": "use_existing_checkpoint", + "defaultValue": "yes", + "help": "Data input already exists. Select `No` if you want to reset the data collection.", + "required": false, + "options": { + "items": [ + { + "value": "yes", + "label": "Yes" + }, + { + "value": "no", + "label": "No" + } + ], + "display": false + } + }, + { + "type": "text", + "label": "Query Start Date", + "validators": [ + { + "type": "regex", + "errorMsg": "Invalid date and time format", + "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" + } + ], + "field": "start_date", + "help": "The date and time, in \"YYYY-MM-DDThh:mm:ss.000z\" format, after which to query and index records. \nThe default is 90 days before today.", + "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", + "required": false + }, + { + "field": "example_help_link", + "label": "", + "type": "helpLink", + "options": { + "text": "Help Link", + "link": "https://docs.splunk.com/Documentation" + } + } + ], + "title": "Example Input Two" + } + ], + "title": "Inputs", + "description": "Manage your data inputs", + "table": { + "actions": [ + "edit", + "enable", + "delete", + "clone" + ], + "header": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Account Name", + "field": "account" + }, + { + "label": "Interval", + "field": "interval" + }, + { + "label": "Index", + "field": "index" + }, + { + "label": "Status", + "field": "disabled" + } + ], + "moreInfo": [ + { + "label": "Name", + "field": "name" + }, + { + "label": "Interval", + "field": "interval" + }, + { + "label": "Index", + "field": "index" + }, + { + "label": "Status", + "field": "disabled", + "mapping": { + "true": "Disabled", + "false": "Enabled" + } + }, + { + "label": "Example Account", + "field": "account" + }, + { + "label": "Object", + "field": "object" + }, + { + "label": "Object Fields", + "field": "object_fields" + }, + { + "label": "Order By", + "field": "order_by" + }, + { + "label": "Query Start Date", + "field": "start_date" + }, + { + "label": "Limit", + "field": "limit" + } + ] + }, + "groupsMenu": [ + { + "groupName": "group_one", + "groupTitle": "Group One", + "groupServices": ["example_input_one", "example_input_two", "example_input_three"] + } + ] + + } + }, + "alerts": [ + { + "name": "test_alert", + "label": "Test Alert", + "description": "Description for test Alert Action", + "activeResponse": { + "task": [ + "Create", + "Update" + ], + "supportsAdhoc": true, + "subject": [ + "endpoint" + ], + "category": [ + "Information Conveyance", + "Information Portrayal" + ], + "technology": [ + { + "version": [ + "1.0.0" + ], + "product": "Test Incident Update", + "vendor": "Splunk" + } + ], + "drilldownUri": "search?q=search%20index%3D\"_internal\"&earliest=0&latest=", + "sourcetype": "test:incident" + }, + "entity": [ + { + "type": "text", + "label": "Name", + "field": "name", + "defaultValue": "xyz", + "required": true, + "help": "Please enter your name" + }, + { + "type": "checkbox", + "label": "All Incidents", + "field": "all_incidents", + "defaultValue": 0, + "required": false, + "help": "Tick if you want to update all incidents/problems" + }, + { + "type": "singleSelect", + "label": "Table List", + "field": "table_list", + "options": { + "items": [ + { + "value": "Incident", + "label": "incident" + }, + { + "value": "Problem", + "label": "problem" + } + ] + }, + "help": "Please select the table", + "required": false, + "defaultValue": "problem" + }, + { + "type": "radio", + "label": "Action:", + "field": "action", + "options": { + "items": [ + { + "value": "Update", + "label": "update" + }, + { + "value": "Delete", + "label": "delete" + } + ] + }, + "help": "Select the action you want to perform", + "required": true, + "defaultValue": "two" + }, + { + "type": "singleSelectSplunkSearch", + "label": "Select Account", + "field": "account", + "search": "| rest /servicesNS/nobody/TA-SNOW/admin/TA_SNOW_account | dedup title", + "valueField": "title", + "labelField": "title", + "help": "Select the account from the dropdown", + "required": true + } + ] + } + ], + "meta": { + "apiVersion": "3.2.0", + "name": "Splunk_TA_UCCExample", + "restRoot": "splunk_ta_uccexample", + "version": "1.0.0", + "displayName": "Splunk UCC test Add-on" + } +} From f85446689e53de360a2f2a725160afdde56d3f39 Mon Sep 17 00:00:00 2001 From: Artem Rys Date: Mon, 20 Feb 2023 17:01:48 +0100 Subject: [PATCH 3/3] test: simplify test samples --- .../global_config_validator.py | 6 +- ...puts_multilevel_menu_duplicate_groups.json | 872 ------------------ ..._menu_invalid_groupname_or_grouptitle.json | 872 ------------------ ...multilevel_menu_invalid_groupservices.json | 872 ------------------ 4 files changed, 3 insertions(+), 2619 deletions(-) diff --git a/splunk_add_on_ucc_framework/global_config_validator.py b/splunk_add_on_ucc_framework/global_config_validator.py index ddd452ac1..8c1169652 100644 --- a/splunk_add_on_ucc_framework/global_config_validator.py +++ b/splunk_add_on_ucc_framework/global_config_validator.py @@ -279,9 +279,9 @@ def _validate_multilevel_menu(self) -> None: for group in groups_menu: names.append(group.get("groupName").lower()) titles.append(group.get("groupTitle").lower()) - groupservices = group.get("groupServices") - if groupservices: - for serviceName in groupservices: + group_services = group.get("groupServices") + if group_services: + for serviceName in group_services: if not any( serviceName == service.get("name") for service in inputs.get("services") diff --git a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_duplicate_groups.json b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_duplicate_groups.json index f934123ab..6e8ecf2aa 100644 --- a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_duplicate_groups.json +++ b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_duplicate_groups.json @@ -2,330 +2,6 @@ "pages": { "configuration": { "tabs": [ - { - "name": "account", - "table": { - "actions": [ - "edit", - "delete", - "clone" - ], - "header": [ - { - "label": "Name", - "field": "name" - }, - { - "label": "Auth Type", - "field": "auth_type" - } - ] - }, - "entity": [ - { - "type": "text", - "label": "Name", - "validators": [ - { - "type": "string", - "errorMsg": "Length of ID should be between 1 and 50", - "minLength": 1, - "maxLength": 50 - }, - { - "type": "regex", - "errorMsg": "Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", - "pattern": "^[a-zA-Z]\\w*$" - } - ], - "options": { - "placeholder": "Required" - }, - "field": "name", - "help": "Enter a unique name for this account.", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Environment", - "options": { - "disableSearch": true, - "autoCompleteFields": [ - { - "value": "login.example.com", - "label": "Value1" - }, - { - "value": "test.example.com", - "label": "Value2" - }, - { - "value": "other", - "label": "Other" - } - ], - "display": true - }, - "help": "", - "field": "custom_endpoint", - "defaultValue": "login.example.com", - "required": true - }, - { - "type": "text", - "label": "Endpoint URL", - "help": "Enter the endpoint URL.", - "field": "endpoint", - "options": { - "display": false - } - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "account_checkbox", - "help": "This is an example checkbox for the account entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "account_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the account entity", - "required": true, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "type": "multipleSelect", - "label": "Example Multiple Select", - "field": "account_multiple_select", - "help": "This is an example multipleSelect for account entity", - "required": true, - "options": { - "items": [{ - "value": "one", - "label": "Option One" - }, - { - "value": "two", - "label": "Option Two" - } - ] - } - }, - { - "type": "text", - "label": "State", - "help": "This is a boolean field for developers to decide whether state parameter will be passed in the OAuth flow. Value: true|false", - "field": "oauth_state_enabled", - "options": { - "display": false - } - }, - { - "type": "oauth", - "field": "oauth", - "label": "Not used", - "options": { - "auth_type": [ - "basic", - "oauth" - ], - "basic": [ - { - "oauth_field": "username", - "label": "Username", - "help": "Enter the username for this account.", - "field": "username" - }, - { - "oauth_field": "password", - "label": "Password", - "encrypted": true, - "help": "Enter the password for this account.", - "field": "password" - }, - { - "oauth_field": "security_token", - "label": "Security Token", - "encrypted": true, - "help": "Enter the security token.", - "field": "token" - } - ], - "oauth": [ - { - "oauth_field": "client_id", - "label": "Client Id", - "field": "client_id", - "help": "Enter the Client Id for this account." - }, - { - "oauth_field": "client_secret", - "label": "Client Secret", - "field": "client_secret", - "encrypted": true, - "help": "Enter the Client Secret key for this account." - }, - { - "oauth_field": "redirect_url", - "label": "Redirect url", - "field": "redirect_url", - "help": "Copy and paste this URL into your app." - } - ], - "auth_code_endpoint": "/services/oauth2/authorize", - "access_token_endpoint": "/services/oauth2/token", - "oauth_timeout": 30 - } - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } - }, - { - "type": "textarea", - "label": "Textarea Field", - "field": "textarea_field", - "help": "Help message", - "options": { - "rowsMin": 3, - "rowsMax": 15 - }, - "required": true - }, - { - "type": "file", - "label": "Upload File", - "help": "Upload service account's certificate", - "field": "service_account", - "options": { - "fileSupportMessage": "Here is the support message" - }, - "validators": [ - { - "type": "file", - "supportedFileTypes": ["json"] - } - ], - "encrypted": true, - "required": true - } - ], - "title": "Account" - }, - { - "name": "proxy", - "entity": [ - { - "type": "checkbox", - "label": "Enable", - "field": "proxy_enabled" - }, - { - "type": "singleSelect", - "label": "Proxy Type", - "options": { - "disableSearch": true, - "autoCompleteFields": [ - { - "value": "http", - "label": "http" - }, - { - "value": "socks4", - "label": "socks4" - }, - { - "value": "socks5", - "label": "socks5" - } - ] - }, - "defaultValue": "http", - "field": "proxy_type" - }, - { - "type": "text", - "label": "Host", - "validators": [ - { - "type": "string", - "errorMsg": "Max host length is 4096", - "minLength": 0, - "maxLength": 4096 - } - ], - "field": "proxy_url" - }, - { - "type": "text", - "label": "Port", - "validators": [ - { - "type": "number", - "range": [ - 1, - 65535 - ] - } - ], - "field": "proxy_port" - }, - { - "type": "text", - "label": "Username", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of username is 50", - "minLength": 0, - "maxLength": 50 - } - ], - "field": "proxy_username" - }, - { - "type": "text", - "label": "Password", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of password is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "encrypted": true, - "field": "proxy_password" - }, - { - "type": "checkbox", - "label": "Reverse DNS resolution", - "field": "proxy_rdns" - } - ], - "options": { - "saveValidator": "function(formData) { if(!formData.proxy_enabled || formData.proxy_enabled === '0') {return true; } if(!formData.proxy_url) { return 'Proxy Host can not be empty'; } if(!formData.proxy_port) { return 'Proxy Port can not be empty'; } return true; }" - }, - "title": "Proxy" - }, { "name": "logging", "entity": [ @@ -362,90 +38,6 @@ } ], "title": "Logging" - }, - { - "name": "custom_abc", - "title": "Customized tab", - "entity": [ - { - "field": "testString", - "label": "Test String", - "type": "text", - "validators": [ - { - "type": "string", - "maxLength": 10, - "minLength": 5 - } - ] - }, - { - "field": "testNumber", - "label": "Test number", - "type": "text", - "validators": [ - { - "type": "number", - "range": [ - 1, - 10 - ] - } - ] - }, - { - "field": "testRegex", - "label": "Test regex", - "type": "text", - "validators": [ - { - "type": "regex", - "pattern": "^\\w+$", - "errorMsg": "Characters of Name should match regex ^\\w+$ ." - } - ] - }, - { - "field": "testEmail", - "label": "Test Email", - "type": "text", - "validators": [ - { - "type": "email" - } - ] - }, - { - "field": "testIpv4", - "label": "Test ipv4", - "type": "text", - "validators": [ - { - "type": "ipv4" - } - ] - }, - { - "field": "testDate", - "label": "Test date", - "type": "text", - "validators": [ - { - "type": "date" - } - ] - }, - { - "field": "testUrl", - "label": "Test url", - "type": "text", - "validators": [ - { - "type": "url" - } - ] - } - ] } ], "title": "Configuration", @@ -478,237 +70,6 @@ "field": "name", "help": "A unique name for the data input.", "required": true - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "input_one_checkbox", - "help": "This is an example checkbox for the input one entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "input_one_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the input one entity", - "required": false, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "field": "singleSelectTest", - "label": "Single Select Group Test", - "type": "singleSelect", - "options": { - "createSearchChoice": true, - "autoCompleteFields": [ - { - "label": "Group1", - "children": [ - { - "value": "one", - "label": "One" - }, - { - "value": "two", - "label": "Two" - } - ] - }, - { - "label": "Group2", - "children": [ - { - "value": "three", - "label": "Three" - }, - { - "value": "four", - "label": "Four" - } - ] - } - ] - } - }, - { - "field": "multipleSelectTest", - "label": "Multiple Select Test", - "type": "multipleSelect", - "options": { - "delimiter": "|", - "items": [ - { - "value": "a", - "label": "A" - }, - { - "value": "b", - "label": "B" - } - ] - } - }, - { - "type": "text", - "label": "Interval", - "validators": [ - { - "type": "regex", - "errorMsg": "Interval must be an integer.", - "pattern": "^\\-[1-9]\\d*$|^\\d*$" - } - ], - "field": "interval", - "help": "Time interval of the data input, in seconds.", - "required": true - }, - { - "type": "singleSelect", - "label": "Index", - "validators": [ - { - "type": "string", - "errorMsg": "Length of index name should be between 1 and 80.", - "minLength": 1, - "maxLength": 80 - } - ], - "defaultValue": "default", - "options": { - "endpointUrl": "data/indexes", - "denyList": "^_.*$", - "createSearchChoice": true - }, - "field": "index", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Account", - "options": { - "referenceName": "account" - }, - "help": "", - "field": "account", - "required": true - }, - { - "type": "text", - "label": "Object", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "field": "object", - "help": "The name of the object to query for.", - "required": true - }, - { - "type": "text", - "label": "Object Fields", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "field": "object_fields", - "help": "Object fields from which to collect data. Delimit multiple fields using a comma.", - "required": true - }, - { - "type": "text", - "label": "Order By", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "defaultValue": "LastModifiedDate", - "field": "order_by", - "help": "The datetime field by which to query results in ascending order for indexing.", - "required": true - }, - { - "type": "radio", - "label": "Use existing data input?", - "field": "use_existing_checkpoint", - "defaultValue": "yes", - "help": "Data input already exists. Select `No` if you want to reset the data collection.", - "required": false, - "options": { - "items": [ - { - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": false - } - }, - { - "type": "text", - "label": "Query Start Date", - "validators": [ - { - "type": "regex", - "errorMsg": "Invalid date and time format", - "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" - } - ], - "field": "start_date", - "help": "The datetime after which to query and index records, in this format: \"YYYY-MM-DDThh:mm:ss.000z\".\nDefaults to 90 days earlier from now.", - "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", - "required": false - }, - { - "type": "text", - "label": "Limit", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "defaultValue": "1000", - "field": "limit", - "help": "The maximum number of results returned by the query.", - "required": false - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } } ], "title": "Example Input One" @@ -735,139 +96,6 @@ "field": "name", "help": "A unique name for the data input.", "required": true - }, - { - "type": "text", - "label": "Interval", - "validators": [ - { - "type": "regex", - "errorMsg": "Interval must be an integer.", - "pattern": "^\\-[1-9]\\d*$|^\\d*$" - } - ], - "field": "interval", - "help": "Time interval of the data input, in seconds .", - "required": true - }, - { - "type": "singleSelect", - "label": "Index", - "validators": [ - { - "type": "string", - "errorMsg": "Length of index name should be between 1 and 80.", - "minLength": 1, - "maxLength": 80 - } - ], - "defaultValue": "default", - "options": { - "endpointUrl": "data/indexes", - "denyList": "^_.*$", - "createSearchChoice": true - }, - "field": "index", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Account", - "options": { - "referenceName": "account" - }, - "help": "", - "field": "account", - "required": true - }, - { - "type": "multipleSelect", - "label": "Example Multiple Select", - "field": "input_two_multiple_select", - "help": "This is an example multipleSelect for input two entity", - "required": true, - "options": { - "items": [{ - "value": "one", - "label": "Option One" - }, - { - "value": "two", - "label": "Option Two" - } - ] - } - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "input_two_checkbox", - "help": "This is an example checkbox for the input two entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "input_two_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the input two entity", - "required": false, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "type": "radio", - "label": "Use existing data input?", - "field": "use_existing_checkpoint", - "defaultValue": "yes", - "help": "Data input already exists. Select `No` if you want to reset the data collection.", - "required": false, - "options": { - "items": [ - { - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": false - } - }, - { - "type": "text", - "label": "Query Start Date", - "validators": [ - { - "type": "regex", - "errorMsg": "Invalid date and time format", - "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" - } - ], - "field": "start_date", - "help": "The date and time, in \"YYYY-MM-DDThh:mm:ss.000z\" format, after which to query and index records. \nThe default is 90 days before today.", - "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", - "required": false - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } } ], "title": "Example Input Two" @@ -966,106 +194,6 @@ } }, - "alerts": [ - { - "name": "test_alert", - "label": "Test Alert", - "description": "Description for test Alert Action", - "activeResponse": { - "task": [ - "Create", - "Update" - ], - "supportsAdhoc": true, - "subject": [ - "endpoint" - ], - "category": [ - "Information Conveyance", - "Information Portrayal" - ], - "technology": [ - { - "version": [ - "1.0.0" - ], - "product": "Test Incident Update", - "vendor": "Splunk" - } - ], - "drilldownUri": "search?q=search%20index%3D\"_internal\"&earliest=0&latest=", - "sourcetype": "test:incident" - }, - "entity": [ - { - "type": "text", - "label": "Name", - "field": "name", - "defaultValue": "xyz", - "required": true, - "help": "Please enter your name" - }, - { - "type": "checkbox", - "label": "All Incidents", - "field": "all_incidents", - "defaultValue": 0, - "required": false, - "help": "Tick if you want to update all incidents/problems" - }, - { - "type": "singleSelect", - "label": "Table List", - "field": "table_list", - "options": { - "items": [ - { - "value": "Incident", - "label": "incident" - }, - { - "value": "Problem", - "label": "problem" - } - ] - }, - "help": "Please select the table", - "required": false, - "defaultValue": "problem" - }, - { - "type": "radio", - "label": "Action:", - "field": "action", - "options": { - "items": [ - { - "value": "Update", - "label": "update" - }, - { - "value": "Delete", - "label": "delete" - } - ] - }, - "help": "Select the action you want to perform", - "required": true, - "defaultValue": "two" - }, - { - "type": "singleSelectSplunkSearch", - "label": "Select Account", - "field": "account", - "search": "| rest /servicesNS/nobody/TA-SNOW/admin/TA_SNOW_account | dedup title", - "valueField": "title", - "labelField": "title", - "help": "Select the account from the dropdown", - "required": true - } - ] - } - ], "meta": { "apiVersion": "3.2.0", "name": "Splunk_TA_UCCExample", diff --git a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json index 232bdb1c0..ab324c6c5 100644 --- a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json +++ b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupname_or_grouptitle.json @@ -2,330 +2,6 @@ "pages": { "configuration": { "tabs": [ - { - "name": "account", - "table": { - "actions": [ - "edit", - "delete", - "clone" - ], - "header": [ - { - "label": "Name", - "field": "name" - }, - { - "label": "Auth Type", - "field": "auth_type" - } - ] - }, - "entity": [ - { - "type": "text", - "label": "Name", - "validators": [ - { - "type": "string", - "errorMsg": "Length of ID should be between 1 and 50", - "minLength": 1, - "maxLength": 50 - }, - { - "type": "regex", - "errorMsg": "Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", - "pattern": "^[a-zA-Z]\\w*$" - } - ], - "options": { - "placeholder": "Required" - }, - "field": "name", - "help": "Enter a unique name for this account.", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Environment", - "options": { - "disableSearch": true, - "autoCompleteFields": [ - { - "value": "login.example.com", - "label": "Value1" - }, - { - "value": "test.example.com", - "label": "Value2" - }, - { - "value": "other", - "label": "Other" - } - ], - "display": true - }, - "help": "", - "field": "custom_endpoint", - "defaultValue": "login.example.com", - "required": true - }, - { - "type": "text", - "label": "Endpoint URL", - "help": "Enter the endpoint URL.", - "field": "endpoint", - "options": { - "display": false - } - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "account_checkbox", - "help": "This is an example checkbox for the account entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "account_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the account entity", - "required": true, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "type": "multipleSelect", - "label": "Example Multiple Select", - "field": "account_multiple_select", - "help": "This is an example multipleSelect for account entity", - "required": true, - "options": { - "items": [{ - "value": "one", - "label": "Option One" - }, - { - "value": "two", - "label": "Option Two" - } - ] - } - }, - { - "type": "text", - "label": "State", - "help": "This is a boolean field for developers to decide whether state parameter will be passed in the OAuth flow. Value: true|false", - "field": "oauth_state_enabled", - "options": { - "display": false - } - }, - { - "type": "oauth", - "field": "oauth", - "label": "Not used", - "options": { - "auth_type": [ - "basic", - "oauth" - ], - "basic": [ - { - "oauth_field": "username", - "label": "Username", - "help": "Enter the username for this account.", - "field": "username" - }, - { - "oauth_field": "password", - "label": "Password", - "encrypted": true, - "help": "Enter the password for this account.", - "field": "password" - }, - { - "oauth_field": "security_token", - "label": "Security Token", - "encrypted": true, - "help": "Enter the security token.", - "field": "token" - } - ], - "oauth": [ - { - "oauth_field": "client_id", - "label": "Client Id", - "field": "client_id", - "help": "Enter the Client Id for this account." - }, - { - "oauth_field": "client_secret", - "label": "Client Secret", - "field": "client_secret", - "encrypted": true, - "help": "Enter the Client Secret key for this account." - }, - { - "oauth_field": "redirect_url", - "label": "Redirect url", - "field": "redirect_url", - "help": "Copy and paste this URL into your app." - } - ], - "auth_code_endpoint": "/services/oauth2/authorize", - "access_token_endpoint": "/services/oauth2/token", - "oauth_timeout": 30 - } - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } - }, - { - "type": "textarea", - "label": "Textarea Field", - "field": "textarea_field", - "help": "Help message", - "options": { - "rowsMin": 3, - "rowsMax": 15 - }, - "required": true - }, - { - "type": "file", - "label": "Upload File", - "help": "Upload service account's certificate", - "field": "service_account", - "options": { - "fileSupportMessage": "Here is the support message" - }, - "validators": [ - { - "type": "file", - "supportedFileTypes": ["json"] - } - ], - "encrypted": true, - "required": true - } - ], - "title": "Account" - }, - { - "name": "proxy", - "entity": [ - { - "type": "checkbox", - "label": "Enable", - "field": "proxy_enabled" - }, - { - "type": "singleSelect", - "label": "Proxy Type", - "options": { - "disableSearch": true, - "autoCompleteFields": [ - { - "value": "http", - "label": "http" - }, - { - "value": "socks4", - "label": "socks4" - }, - { - "value": "socks5", - "label": "socks5" - } - ] - }, - "defaultValue": "http", - "field": "proxy_type" - }, - { - "type": "text", - "label": "Host", - "validators": [ - { - "type": "string", - "errorMsg": "Max host length is 4096", - "minLength": 0, - "maxLength": 4096 - } - ], - "field": "proxy_url" - }, - { - "type": "text", - "label": "Port", - "validators": [ - { - "type": "number", - "range": [ - 1, - 65535 - ] - } - ], - "field": "proxy_port" - }, - { - "type": "text", - "label": "Username", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of username is 50", - "minLength": 0, - "maxLength": 50 - } - ], - "field": "proxy_username" - }, - { - "type": "text", - "label": "Password", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of password is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "encrypted": true, - "field": "proxy_password" - }, - { - "type": "checkbox", - "label": "Reverse DNS resolution", - "field": "proxy_rdns" - } - ], - "options": { - "saveValidator": "function(formData) { if(!formData.proxy_enabled || formData.proxy_enabled === '0') {return true; } if(!formData.proxy_url) { return 'Proxy Host can not be empty'; } if(!formData.proxy_port) { return 'Proxy Port can not be empty'; } return true; }" - }, - "title": "Proxy" - }, { "name": "logging", "entity": [ @@ -362,90 +38,6 @@ } ], "title": "Logging" - }, - { - "name": "custom_abc", - "title": "Customized tab", - "entity": [ - { - "field": "testString", - "label": "Test String", - "type": "text", - "validators": [ - { - "type": "string", - "maxLength": 10, - "minLength": 5 - } - ] - }, - { - "field": "testNumber", - "label": "Test number", - "type": "text", - "validators": [ - { - "type": "number", - "range": [ - 1, - 10 - ] - } - ] - }, - { - "field": "testRegex", - "label": "Test regex", - "type": "text", - "validators": [ - { - "type": "regex", - "pattern": "^\\w+$", - "errorMsg": "Characters of Name should match regex ^\\w+$ ." - } - ] - }, - { - "field": "testEmail", - "label": "Test Email", - "type": "text", - "validators": [ - { - "type": "email" - } - ] - }, - { - "field": "testIpv4", - "label": "Test ipv4", - "type": "text", - "validators": [ - { - "type": "ipv4" - } - ] - }, - { - "field": "testDate", - "label": "Test date", - "type": "text", - "validators": [ - { - "type": "date" - } - ] - }, - { - "field": "testUrl", - "label": "Test url", - "type": "text", - "validators": [ - { - "type": "url" - } - ] - } - ] } ], "title": "Configuration", @@ -478,237 +70,6 @@ "field": "name", "help": "A unique name for the data input.", "required": true - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "input_one_checkbox", - "help": "This is an example checkbox for the input one entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "input_one_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the input one entity", - "required": false, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "field": "singleSelectTest", - "label": "Single Select Group Test", - "type": "singleSelect", - "options": { - "createSearchChoice": true, - "autoCompleteFields": [ - { - "label": "Group1", - "children": [ - { - "value": "one", - "label": "One" - }, - { - "value": "two", - "label": "Two" - } - ] - }, - { - "label": "Group2", - "children": [ - { - "value": "three", - "label": "Three" - }, - { - "value": "four", - "label": "Four" - } - ] - } - ] - } - }, - { - "field": "multipleSelectTest", - "label": "Multiple Select Test", - "type": "multipleSelect", - "options": { - "delimiter": "|", - "items": [ - { - "value": "a", - "label": "A" - }, - { - "value": "b", - "label": "B" - } - ] - } - }, - { - "type": "text", - "label": "Interval", - "validators": [ - { - "type": "regex", - "errorMsg": "Interval must be an integer.", - "pattern": "^\\-[1-9]\\d*$|^\\d*$" - } - ], - "field": "interval", - "help": "Time interval of the data input, in seconds.", - "required": true - }, - { - "type": "singleSelect", - "label": "Index", - "validators": [ - { - "type": "string", - "errorMsg": "Length of index name should be between 1 and 80.", - "minLength": 1, - "maxLength": 80 - } - ], - "defaultValue": "default", - "options": { - "endpointUrl": "data/indexes", - "denyList": "^_.*$", - "createSearchChoice": true - }, - "field": "index", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Account", - "options": { - "referenceName": "account" - }, - "help": "", - "field": "account", - "required": true - }, - { - "type": "text", - "label": "Object", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "field": "object", - "help": "The name of the object to query for.", - "required": true - }, - { - "type": "text", - "label": "Object Fields", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "field": "object_fields", - "help": "Object fields from which to collect data. Delimit multiple fields using a comma.", - "required": true - }, - { - "type": "text", - "label": "Order By", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "defaultValue": "LastModifiedDate", - "field": "order_by", - "help": "The datetime field by which to query results in ascending order for indexing.", - "required": true - }, - { - "type": "radio", - "label": "Use existing data input?", - "field": "use_existing_checkpoint", - "defaultValue": "yes", - "help": "Data input already exists. Select `No` if you want to reset the data collection.", - "required": false, - "options": { - "items": [ - { - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": false - } - }, - { - "type": "text", - "label": "Query Start Date", - "validators": [ - { - "type": "regex", - "errorMsg": "Invalid date and time format", - "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" - } - ], - "field": "start_date", - "help": "The datetime after which to query and index records, in this format: \"YYYY-MM-DDThh:mm:ss.000z\".\nDefaults to 90 days earlier from now.", - "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", - "required": false - }, - { - "type": "text", - "label": "Limit", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "defaultValue": "1000", - "field": "limit", - "help": "The maximum number of results returned by the query.", - "required": false - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } } ], "title": "Example Input One" @@ -735,139 +96,6 @@ "field": "name", "help": "A unique name for the data input.", "required": true - }, - { - "type": "text", - "label": "Interval", - "validators": [ - { - "type": "regex", - "errorMsg": "Interval must be an integer.", - "pattern": "^\\-[1-9]\\d*$|^\\d*$" - } - ], - "field": "interval", - "help": "Time interval of the data input, in seconds .", - "required": true - }, - { - "type": "singleSelect", - "label": "Index", - "validators": [ - { - "type": "string", - "errorMsg": "Length of index name should be between 1 and 80.", - "minLength": 1, - "maxLength": 80 - } - ], - "defaultValue": "default", - "options": { - "endpointUrl": "data/indexes", - "denyList": "^_.*$", - "createSearchChoice": true - }, - "field": "index", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Account", - "options": { - "referenceName": "account" - }, - "help": "", - "field": "account", - "required": true - }, - { - "type": "multipleSelect", - "label": "Example Multiple Select", - "field": "input_two_multiple_select", - "help": "This is an example multipleSelect for input two entity", - "required": true, - "options": { - "items": [{ - "value": "one", - "label": "Option One" - }, - { - "value": "two", - "label": "Option Two" - } - ] - } - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "input_two_checkbox", - "help": "This is an example checkbox for the input two entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "input_two_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the input two entity", - "required": false, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "type": "radio", - "label": "Use existing data input?", - "field": "use_existing_checkpoint", - "defaultValue": "yes", - "help": "Data input already exists. Select `No` if you want to reset the data collection.", - "required": false, - "options": { - "items": [ - { - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": false - } - }, - { - "type": "text", - "label": "Query Start Date", - "validators": [ - { - "type": "regex", - "errorMsg": "Invalid date and time format", - "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" - } - ], - "field": "start_date", - "help": "The date and time, in \"YYYY-MM-DDThh:mm:ss.000z\" format, after which to query and index records. \nThe default is 90 days before today.", - "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", - "required": false - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } } ], "title": "Example Input Two" @@ -965,106 +193,6 @@ } }, - "alerts": [ - { - "name": "test_alert", - "label": "Test Alert", - "description": "Description for test Alert Action", - "activeResponse": { - "task": [ - "Create", - "Update" - ], - "supportsAdhoc": true, - "subject": [ - "endpoint" - ], - "category": [ - "Information Conveyance", - "Information Portrayal" - ], - "technology": [ - { - "version": [ - "1.0.0" - ], - "product": "Test Incident Update", - "vendor": "Splunk" - } - ], - "drilldownUri": "search?q=search%20index%3D\"_internal\"&earliest=0&latest=", - "sourcetype": "test:incident" - }, - "entity": [ - { - "type": "text", - "label": "Name", - "field": "name", - "defaultValue": "xyz", - "required": true, - "help": "Please enter your name" - }, - { - "type": "checkbox", - "label": "All Incidents", - "field": "all_incidents", - "defaultValue": 0, - "required": false, - "help": "Tick if you want to update all incidents/problems" - }, - { - "type": "singleSelect", - "label": "Table List", - "field": "table_list", - "options": { - "items": [ - { - "value": "Incident", - "label": "incident" - }, - { - "value": "Problem", - "label": "problem" - } - ] - }, - "help": "Please select the table", - "required": false, - "defaultValue": "problem" - }, - { - "type": "radio", - "label": "Action:", - "field": "action", - "options": { - "items": [ - { - "value": "Update", - "label": "update" - }, - { - "value": "Delete", - "label": "delete" - } - ] - }, - "help": "Select the action you want to perform", - "required": true, - "defaultValue": "two" - }, - { - "type": "singleSelectSplunkSearch", - "label": "Select Account", - "field": "account", - "search": "| rest /servicesNS/nobody/TA-SNOW/admin/TA_SNOW_account | dedup title", - "valueField": "title", - "labelField": "title", - "help": "Select the account from the dropdown", - "required": true - } - ] - } - ], "meta": { "apiVersion": "3.2.0", "name": "Splunk_TA_UCCExample", diff --git a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupservices.json b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupservices.json index ad344b035..d0a662902 100644 --- a/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupservices.json +++ b/tests/unit/testdata/invalid_config_inputs_multilevel_menu_invalid_groupservices.json @@ -2,330 +2,6 @@ "pages": { "configuration": { "tabs": [ - { - "name": "account", - "table": { - "actions": [ - "edit", - "delete", - "clone" - ], - "header": [ - { - "label": "Name", - "field": "name" - }, - { - "label": "Auth Type", - "field": "auth_type" - } - ] - }, - "entity": [ - { - "type": "text", - "label": "Name", - "validators": [ - { - "type": "string", - "errorMsg": "Length of ID should be between 1 and 50", - "minLength": 1, - "maxLength": 50 - }, - { - "type": "regex", - "errorMsg": "Name must begin with a letter and consist exclusively of alphanumeric characters and underscores.", - "pattern": "^[a-zA-Z]\\w*$" - } - ], - "options": { - "placeholder": "Required" - }, - "field": "name", - "help": "Enter a unique name for this account.", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Environment", - "options": { - "disableSearch": true, - "autoCompleteFields": [ - { - "value": "login.example.com", - "label": "Value1" - }, - { - "value": "test.example.com", - "label": "Value2" - }, - { - "value": "other", - "label": "Other" - } - ], - "display": true - }, - "help": "", - "field": "custom_endpoint", - "defaultValue": "login.example.com", - "required": true - }, - { - "type": "text", - "label": "Endpoint URL", - "help": "Enter the endpoint URL.", - "field": "endpoint", - "options": { - "display": false - } - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "account_checkbox", - "help": "This is an example checkbox for the account entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "account_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the account entity", - "required": true, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "type": "multipleSelect", - "label": "Example Multiple Select", - "field": "account_multiple_select", - "help": "This is an example multipleSelect for account entity", - "required": true, - "options": { - "items": [{ - "value": "one", - "label": "Option One" - }, - { - "value": "two", - "label": "Option Two" - } - ] - } - }, - { - "type": "text", - "label": "State", - "help": "This is a boolean field for developers to decide whether state parameter will be passed in the OAuth flow. Value: true|false", - "field": "oauth_state_enabled", - "options": { - "display": false - } - }, - { - "type": "oauth", - "field": "oauth", - "label": "Not used", - "options": { - "auth_type": [ - "basic", - "oauth" - ], - "basic": [ - { - "oauth_field": "username", - "label": "Username", - "help": "Enter the username for this account.", - "field": "username" - }, - { - "oauth_field": "password", - "label": "Password", - "encrypted": true, - "help": "Enter the password for this account.", - "field": "password" - }, - { - "oauth_field": "security_token", - "label": "Security Token", - "encrypted": true, - "help": "Enter the security token.", - "field": "token" - } - ], - "oauth": [ - { - "oauth_field": "client_id", - "label": "Client Id", - "field": "client_id", - "help": "Enter the Client Id for this account." - }, - { - "oauth_field": "client_secret", - "label": "Client Secret", - "field": "client_secret", - "encrypted": true, - "help": "Enter the Client Secret key for this account." - }, - { - "oauth_field": "redirect_url", - "label": "Redirect url", - "field": "redirect_url", - "help": "Copy and paste this URL into your app." - } - ], - "auth_code_endpoint": "/services/oauth2/authorize", - "access_token_endpoint": "/services/oauth2/token", - "oauth_timeout": 30 - } - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } - }, - { - "type": "textarea", - "label": "Textarea Field", - "field": "textarea_field", - "help": "Help message", - "options": { - "rowsMin": 3, - "rowsMax": 15 - }, - "required": true - }, - { - "type": "file", - "label": "Upload File", - "help": "Upload service account's certificate", - "field": "service_account", - "options": { - "fileSupportMessage": "Here is the support message" - }, - "validators": [ - { - "type": "file", - "supportedFileTypes": ["json"] - } - ], - "encrypted": true, - "required": true - } - ], - "title": "Account" - }, - { - "name": "proxy", - "entity": [ - { - "type": "checkbox", - "label": "Enable", - "field": "proxy_enabled" - }, - { - "type": "singleSelect", - "label": "Proxy Type", - "options": { - "disableSearch": true, - "autoCompleteFields": [ - { - "value": "http", - "label": "http" - }, - { - "value": "socks4", - "label": "socks4" - }, - { - "value": "socks5", - "label": "socks5" - } - ] - }, - "defaultValue": "http", - "field": "proxy_type" - }, - { - "type": "text", - "label": "Host", - "validators": [ - { - "type": "string", - "errorMsg": "Max host length is 4096", - "minLength": 0, - "maxLength": 4096 - } - ], - "field": "proxy_url" - }, - { - "type": "text", - "label": "Port", - "validators": [ - { - "type": "number", - "range": [ - 1, - 65535 - ] - } - ], - "field": "proxy_port" - }, - { - "type": "text", - "label": "Username", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of username is 50", - "minLength": 0, - "maxLength": 50 - } - ], - "field": "proxy_username" - }, - { - "type": "text", - "label": "Password", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of password is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "encrypted": true, - "field": "proxy_password" - }, - { - "type": "checkbox", - "label": "Reverse DNS resolution", - "field": "proxy_rdns" - } - ], - "options": { - "saveValidator": "function(formData) { if(!formData.proxy_enabled || formData.proxy_enabled === '0') {return true; } if(!formData.proxy_url) { return 'Proxy Host can not be empty'; } if(!formData.proxy_port) { return 'Proxy Port can not be empty'; } return true; }" - }, - "title": "Proxy" - }, { "name": "logging", "entity": [ @@ -362,90 +38,6 @@ } ], "title": "Logging" - }, - { - "name": "custom_abc", - "title": "Customized tab", - "entity": [ - { - "field": "testString", - "label": "Test String", - "type": "text", - "validators": [ - { - "type": "string", - "maxLength": 10, - "minLength": 5 - } - ] - }, - { - "field": "testNumber", - "label": "Test number", - "type": "text", - "validators": [ - { - "type": "number", - "range": [ - 1, - 10 - ] - } - ] - }, - { - "field": "testRegex", - "label": "Test regex", - "type": "text", - "validators": [ - { - "type": "regex", - "pattern": "^\\w+$", - "errorMsg": "Characters of Name should match regex ^\\w+$ ." - } - ] - }, - { - "field": "testEmail", - "label": "Test Email", - "type": "text", - "validators": [ - { - "type": "email" - } - ] - }, - { - "field": "testIpv4", - "label": "Test ipv4", - "type": "text", - "validators": [ - { - "type": "ipv4" - } - ] - }, - { - "field": "testDate", - "label": "Test date", - "type": "text", - "validators": [ - { - "type": "date" - } - ] - }, - { - "field": "testUrl", - "label": "Test url", - "type": "text", - "validators": [ - { - "type": "url" - } - ] - } - ] } ], "title": "Configuration", @@ -478,237 +70,6 @@ "field": "name", "help": "A unique name for the data input.", "required": true - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "input_one_checkbox", - "help": "This is an example checkbox for the input one entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "input_one_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the input one entity", - "required": false, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "field": "singleSelectTest", - "label": "Single Select Group Test", - "type": "singleSelect", - "options": { - "createSearchChoice": true, - "autoCompleteFields": [ - { - "label": "Group1", - "children": [ - { - "value": "one", - "label": "One" - }, - { - "value": "two", - "label": "Two" - } - ] - }, - { - "label": "Group2", - "children": [ - { - "value": "three", - "label": "Three" - }, - { - "value": "four", - "label": "Four" - } - ] - } - ] - } - }, - { - "field": "multipleSelectTest", - "label": "Multiple Select Test", - "type": "multipleSelect", - "options": { - "delimiter": "|", - "items": [ - { - "value": "a", - "label": "A" - }, - { - "value": "b", - "label": "B" - } - ] - } - }, - { - "type": "text", - "label": "Interval", - "validators": [ - { - "type": "regex", - "errorMsg": "Interval must be an integer.", - "pattern": "^\\-[1-9]\\d*$|^\\d*$" - } - ], - "field": "interval", - "help": "Time interval of the data input, in seconds.", - "required": true - }, - { - "type": "singleSelect", - "label": "Index", - "validators": [ - { - "type": "string", - "errorMsg": "Length of index name should be between 1 and 80.", - "minLength": 1, - "maxLength": 80 - } - ], - "defaultValue": "default", - "options": { - "endpointUrl": "data/indexes", - "denyList": "^_.*$", - "createSearchChoice": true - }, - "field": "index", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Account", - "options": { - "referenceName": "account" - }, - "help": "", - "field": "account", - "required": true - }, - { - "type": "text", - "label": "Object", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "field": "object", - "help": "The name of the object to query for.", - "required": true - }, - { - "type": "text", - "label": "Object Fields", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "field": "object_fields", - "help": "Object fields from which to collect data. Delimit multiple fields using a comma.", - "required": true - }, - { - "type": "text", - "label": "Order By", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "defaultValue": "LastModifiedDate", - "field": "order_by", - "help": "The datetime field by which to query results in ascending order for indexing.", - "required": true - }, - { - "type": "radio", - "label": "Use existing data input?", - "field": "use_existing_checkpoint", - "defaultValue": "yes", - "help": "Data input already exists. Select `No` if you want to reset the data collection.", - "required": false, - "options": { - "items": [ - { - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": false - } - }, - { - "type": "text", - "label": "Query Start Date", - "validators": [ - { - "type": "regex", - "errorMsg": "Invalid date and time format", - "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" - } - ], - "field": "start_date", - "help": "The datetime after which to query and index records, in this format: \"YYYY-MM-DDThh:mm:ss.000z\".\nDefaults to 90 days earlier from now.", - "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", - "required": false - }, - { - "type": "text", - "label": "Limit", - "validators": [ - { - "type": "string", - "errorMsg": "Max length of text input is 8192", - "minLength": 0, - "maxLength": 8192 - } - ], - "defaultValue": "1000", - "field": "limit", - "help": "The maximum number of results returned by the query.", - "required": false - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } } ], "title": "Example Input One" @@ -735,139 +96,6 @@ "field": "name", "help": "A unique name for the data input.", "required": true - }, - { - "type": "text", - "label": "Interval", - "validators": [ - { - "type": "regex", - "errorMsg": "Interval must be an integer.", - "pattern": "^\\-[1-9]\\d*$|^\\d*$" - } - ], - "field": "interval", - "help": "Time interval of the data input, in seconds .", - "required": true - }, - { - "type": "singleSelect", - "label": "Index", - "validators": [ - { - "type": "string", - "errorMsg": "Length of index name should be between 1 and 80.", - "minLength": 1, - "maxLength": 80 - } - ], - "defaultValue": "default", - "options": { - "endpointUrl": "data/indexes", - "denyList": "^_.*$", - "createSearchChoice": true - }, - "field": "index", - "required": true - }, - { - "type": "singleSelect", - "label": "Example Account", - "options": { - "referenceName": "account" - }, - "help": "", - "field": "account", - "required": true - }, - { - "type": "multipleSelect", - "label": "Example Multiple Select", - "field": "input_two_multiple_select", - "help": "This is an example multipleSelect for input two entity", - "required": true, - "options": { - "items": [{ - "value": "one", - "label": "Option One" - }, - { - "value": "two", - "label": "Option Two" - } - ] - } - }, - { - "type": "checkbox", - "label": "Example Checkbox", - "field": "input_two_checkbox", - "help": "This is an example checkbox for the input two entity" - }, - { - "type": "radio", - "label": "Example Radio", - "field": "input_two_radio", - "defaultValue": "yes", - "help": "This is an example radio button for the input two entity", - "required": false, - "options": { - "items": [{ - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": true - } - }, - { - "type": "radio", - "label": "Use existing data input?", - "field": "use_existing_checkpoint", - "defaultValue": "yes", - "help": "Data input already exists. Select `No` if you want to reset the data collection.", - "required": false, - "options": { - "items": [ - { - "value": "yes", - "label": "Yes" - }, - { - "value": "no", - "label": "No" - } - ], - "display": false - } - }, - { - "type": "text", - "label": "Query Start Date", - "validators": [ - { - "type": "regex", - "errorMsg": "Invalid date and time format", - "pattern": "^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}z)?$" - } - ], - "field": "start_date", - "help": "The date and time, in \"YYYY-MM-DDThh:mm:ss.000z\" format, after which to query and index records. \nThe default is 90 days before today.", - "tooltip": "Changing this parameter may result in gaps or duplication in data collection.", - "required": false - }, - { - "field": "example_help_link", - "label": "", - "type": "helpLink", - "options": { - "text": "Help Link", - "link": "https://docs.splunk.com/Documentation" - } } ], "title": "Example Input Two" @@ -961,106 +189,6 @@ } }, - "alerts": [ - { - "name": "test_alert", - "label": "Test Alert", - "description": "Description for test Alert Action", - "activeResponse": { - "task": [ - "Create", - "Update" - ], - "supportsAdhoc": true, - "subject": [ - "endpoint" - ], - "category": [ - "Information Conveyance", - "Information Portrayal" - ], - "technology": [ - { - "version": [ - "1.0.0" - ], - "product": "Test Incident Update", - "vendor": "Splunk" - } - ], - "drilldownUri": "search?q=search%20index%3D\"_internal\"&earliest=0&latest=", - "sourcetype": "test:incident" - }, - "entity": [ - { - "type": "text", - "label": "Name", - "field": "name", - "defaultValue": "xyz", - "required": true, - "help": "Please enter your name" - }, - { - "type": "checkbox", - "label": "All Incidents", - "field": "all_incidents", - "defaultValue": 0, - "required": false, - "help": "Tick if you want to update all incidents/problems" - }, - { - "type": "singleSelect", - "label": "Table List", - "field": "table_list", - "options": { - "items": [ - { - "value": "Incident", - "label": "incident" - }, - { - "value": "Problem", - "label": "problem" - } - ] - }, - "help": "Please select the table", - "required": false, - "defaultValue": "problem" - }, - { - "type": "radio", - "label": "Action:", - "field": "action", - "options": { - "items": [ - { - "value": "Update", - "label": "update" - }, - { - "value": "Delete", - "label": "delete" - } - ] - }, - "help": "Select the action you want to perform", - "required": true, - "defaultValue": "two" - }, - { - "type": "singleSelectSplunkSearch", - "label": "Select Account", - "field": "account", - "search": "| rest /servicesNS/nobody/TA-SNOW/admin/TA_SNOW_account | dedup title", - "valueField": "title", - "labelField": "title", - "help": "Select the account from the dropdown", - "required": true - } - ] - } - ], "meta": { "apiVersion": "3.2.0", "name": "Splunk_TA_UCCExample",