diff --git a/plugins/salesforce/.CHECKSUM b/plugins/salesforce/.CHECKSUM index 695e4ba091..614ec3e38b 100644 --- a/plugins/salesforce/.CHECKSUM +++ b/plugins/salesforce/.CHECKSUM @@ -1,47 +1,47 @@ { - "spec": "c8b766efd557c851a9c3181dcaf54464", - "manifest": "555eb92acfda71ed1d255cd0b932e285", - "setup": "229c1c37adbe823c79a2718d4d34b481", + "spec": "39961b8237f24bf66810ef73d84a0b13", + "manifest": "1bf1a6ea3128f9c4c152ba785f0ba17a", + "setup": "adf7f461ad84d7bf7f5c3e81fc9c5b13", "schemas": [ { "identifier": "advanced_search/schema.py", - "hash": "179de4c019e98944cea79f1fe7276309" + "hash": "23a8e957376939193be68f4bbbadd396" }, { "identifier": "create_record/schema.py", - "hash": "d1c0647714d2723555f2328824b2d112" + "hash": "b34c4a7c225c9290d9b7049abc0623d7" }, { "identifier": "delete_record/schema.py", - "hash": "5a5bc6bbb5ed0739dafe19a683c407a0" + "hash": "47c1d595eab0adbcc18dfb8b693b3a56" }, { "identifier": "get_blob_data/schema.py", - "hash": "bc9a431b42e6e2b976dfc594209080f9" + "hash": "e61b59c746f208401eef920787f6ff40" }, { "identifier": "get_fields/schema.py", - "hash": "054b3e335478d44b28872638b1a3dee9" + "hash": "18f1510eb72bee75f79d07d30ac59458" }, { "identifier": "get_record/schema.py", - "hash": "9cfaddf95d8fae04906dac92eb096fda" + "hash": "03fd7c641d78ceb3401fda85ca6a082f" }, { "identifier": "simple_search/schema.py", - "hash": "b06060466013f1d3ded8233351e9e9bb" + "hash": "62b22126f4d16f72d58645bb794e53b6" }, { "identifier": "update_record/schema.py", - "hash": "e8f054c382b238b4bb809400462ce445" + "hash": "abd8db6f4ed253a25ab63262ef04a734" }, { "identifier": "connection/schema.py", - "hash": "fcf31f95b9a83aef05fdbe215a0115de" + "hash": "1656ec1e43c8581104c369faa18c177e" }, { "identifier": "monitor_users/schema.py", - "hash": "8b9d82e8786f1601d6c8006551deb227" + "hash": "5f655ee0326da8b7586009e58f28e162" } ] } \ No newline at end of file diff --git a/plugins/salesforce/Dockerfile b/plugins/salesforce/Dockerfile index 3458a8da39..348437807a 100755 --- a/plugins/salesforce/Dockerfile +++ b/plugins/salesforce/Dockerfile @@ -3,20 +3,15 @@ FROM rapid7/insightconnect-python-3-plugin:5 LABEL organization=rapid7 LABEL sdk=python -# Add any custom package dependencies here -# NOTE: Add pip packages to requirements.txt - -# End package dependencies - -# Add source code WORKDIR /python/src + ADD ./plugin.spec.yaml /plugin.spec.yaml -ADD . /python/src +ADD ./requirements.txt /python/src/requirements.txt -# Install pip dependencies RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi -# Install plugin +ADD . /python/src + RUN python setup.py build && python setup.py install # User to run plugin code. The two supported users are: root, nobody diff --git a/plugins/salesforce/bin/komand_salesforce b/plugins/salesforce/bin/komand_salesforce index 3da2bc8960..a617de6c16 100755 --- a/plugins/salesforce/bin/komand_salesforce +++ b/plugins/salesforce/bin/komand_salesforce @@ -1,12 +1,12 @@ #!/usr/bin/env python -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import os import json from sys import argv Name = "Salesforce" Vendor = "rapid7" -Version = "2.1.4" +Version = "2.1.5" Description = "The Salesforce plugin allows you to search, update, and manage salesforce records" @@ -34,24 +34,24 @@ def main(): description=Description, connection=connection.Connection() ) + self.add_action(actions.SimpleSearch()) + self.add_action(actions.AdvancedSearch()) - + self.add_action(actions.CreateRecord()) - + + self.add_action(actions.UpdateRecord()) + + self.add_action(actions.GetRecord()) + self.add_action(actions.DeleteRecord()) - - self.add_action(actions.GetBlobData()) - + self.add_action(actions.GetFields()) - - self.add_action(actions.GetRecord()) - - self.add_action(actions.SimpleSearch()) - - self.add_action(actions.UpdateRecord()) - + + self.add_action(actions.GetBlobData()) + self.add_task(tasks.MonitorUsers()) - + """Run plugin""" cli = insightconnect_plugin_runtime.CLI(ICONSalesforce()) diff --git a/plugins/salesforce/help.md b/plugins/salesforce/help.md index 3cc622e0b9..06fb78d7a7 100644 --- a/plugins/salesforce/help.md +++ b/plugins/salesforce/help.md @@ -21,22 +21,22 @@ This plugin utilizes the [Salesforce API](https://developer.salesforce.com/docs/ * Consumer Key and Secret of the connected app # Supported Product Versions - + * Salesforce API v58 2023-06-30 # Documentation ## Setup - -The connection configuration accepts the following parameters: + +The connection configuration accepts the following parameters: |Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | |clientId|string|None|True|Consumer Key of the connected app|None|1234567890aBcdEFRoeRxDE1234567890abCDef6Etz7VLwwLQZn19jyW3U_1234567890AbcdEF4VkuMS4ze| -|clientSecret|credential_secret_key|None|True|Consumer Secret of the connected app|None|30f800f97aeaa8d62bdf3a6fb2b0681179a360c12e127f07038f8521461e5050| +|clientSecret|credential_secret_key|None|True|Consumer Secret of the connected app|None|1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF| |salesforceAccountUsernameAndPassword|credential_username_password|None|True|Name and password of the Salesforce user|None|{"username": "user@example.com", "password": "password"}| |securityToken|credential_secret_key|None|True|Security token of the Salesforce user|None|Ier6YY78KxJwKtHy7HeK0oPc| - + Example input: ``` @@ -44,8 +44,8 @@ Example input: "clientId": "1234567890aBcdEFRoeRxDE1234567890abCDef6Etz7VLwwLQZn19jyW3U_1234567890AbcdEF4VkuMS4ze", "clientSecret": "1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF1234567890ABCDEF", "salesforceAccountUsernameAndPassword": { - "username": "user@example.com", - "password": "password" + "password": "password", + "username": "user@example.com" }, "securityToken": "Ier6YY78KxJwKtHy7HeK0oPc" } @@ -55,16 +55,17 @@ Example input: ### Actions -#### Advanced Search +#### Advanced Search + This action is used to execute a SOQL (Salesforce Object Query Language) query. ##### Input |Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | |query|string|None|True|SOQL query|None|SELECT FIELDS(STANDARD) FROM Account WHERE Name='Example Account'| - + Example input: ``` @@ -76,42 +77,75 @@ Example input: ##### Output |Name|Type|Required|Description|Example| -|----|----|--------|-----------|-------| -|searchResults|[]searchResult|False|List of search results|[]| - +| :--- | :--- | :--- | :--- | :--- | +|searchResults|[]searchResult|False|List of search results|[{"type":"Account","url":"/services/data/v58.0/sobjects/Account/001Hn00001uLl12aBC","name":"Example Account","id":"001Hn00001uLl12aBC"}]| + Example output: ``` { - "search_results": [ + "searchResults": [ { - "type": "Account", - "url": "/services/data/v58.0/sobjects/Account/001Hn00001uLl12aBC", + "id": "001Hn00001uLl12aBC", "name": "Example Account", - "id": "001Hn00001uLl12aBC" + "type": "Account", + "url": "/services/data/v58.0/sobjects/Account/001Hn00001uLl12aBC" } ] } ``` -#### Update Record - -This action is used to update a record. +#### Create Record + +This action is used to create a new SObject record. ##### Input |Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| -|objectData|object|None|True|Updated SObject information|None|{"name": "example-name"}| -|objectName|string|Account|True|The name of the object (e.g. 'Account')|None|Account| -|recordId|string|None|True|The ID of an existing record|None|000AA000000aa0aAAA| - +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +|objectData|object|None|True|SObject information for the newly created record|None|{"name": "example-name"}| +|objectName|string|None|True|The name of the object (e.g. 'Account')|None|Account| + Example input: + ``` { "objectData": { "name": "example-name" }, + "objectName": "Account" +} +``` + +##### Output + +|Name|Type|Required|Description|Example| +| :--- | :--- | :--- | :--- | :--- | +|id|string|False|ID of the newly created record|000AA000000aa0aAAA| + +Example output: + +``` +{ + "id": "000AA000000aa0aAAA" +} +``` + +#### Delete Record + +This action is used to delete a record + +##### Input + +|Name|Type|Default|Required|Description|Enum|Example| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +|objectName|string|Account|True|The name of the object (e.g. 'Account')|None|Account| +|recordId|string|None|True|The ID of an existing record|None|000AA000000aa0aAAA| + +Example input: + +``` +{ "objectName": "Account", "recordId": "000AA000000aa0aAAA" } @@ -120,9 +154,9 @@ Example input: ##### Output |Name|Type|Required|Description|Example| -|----|----|--------|-----------|-------| +| :--- | :--- | :--- | :--- | :--- | |success|boolean|False|Was the operation successful|True| - + Example output: ``` @@ -131,18 +165,54 @@ Example output: } ``` -#### Get Fields +#### Get Blob Data + +This action is used to retrieve blob data for a given record. -This action is used to retrieve field values from a record. +##### Input + +|Name|Type|Default|Required|Description|Enum|Example| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +|fieldName|string|body|True|Blob field name|None|body| +|objectName|string|Attachment|True|The name of the object (e.g. 'Attachment')|None|Attachment| +|recordId|string|None|True|The ID of an existing record|None|001Hn00001uAJRtaB3| + +Example input: + +``` +{ + "fieldName": "body", + "objectName": "Attachment", + "recordId": "001Hn00001uAJRtaB3" +} +``` + +##### Output + +|Name|Type|Required|Description|Example| +| :--- | :--- | :--- | :--- | :--- | +|data|bytes|False|The value of the selected blob field|dGVzdA==| + +Example output: + +``` +{ + "data": "dGVzdA==" +} +``` + +#### Get Fields + +This action is used to retrieve field values from the record of the given object. ##### Input |Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | |fields|[]string|None|True|The fields which values should be retrieved|None|["Id", "Name", "Description"]| |objectName|string|Account|True|The name of the object (e.g. 'Account')|None|Account| |recordId|string|None|True|The ID of an existing record|None|001Hn00001uAJRtaB3| - + Example input: ``` @@ -160,39 +230,39 @@ Example input: ##### Output |Name|Type|Required|Description|Example| -|----|----|--------|-----------|-------| -|fields|object|False|An object with field names as keys, each with the corresponding value|{}| - +| :--- | :--- | :--- | :--- | :--- | +|fields|object|False|An object with field names as keys, each with the corresponding value|{"id":"001Hn00001uAJRtaB3","name":"Example Account","description":"Example description"}| + Example output: ``` { "fields": { + "description": "Example description", "id": "001Hn00001uAJRtaB3", - "name": "Example Account", - "description": "Example description" + "name": "Example Account" } } ``` #### Get Record - + This action is used to retrieve a record. ##### Input |Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| -|externalIdFieldName|string||False|The name of the external ID field that should be matched with record_id. If empty, the 'Id' field of the record is used|None|ExampleExtID__c| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +|externalIdFieldName|string|None|False|The name of the external ID field that should be matched with record_id. If empty, the 'Id' field of the record is used|None|ExampleExtID__c| |objectName|string|Account|True|The name of the object|None|Folder| |recordId|string|None|True|The ID of an existing record|None|999Hn99999uM8mnBBB| - + Example input: ``` { "externalIdFieldName": "ExampleExtID__c", - "objectName": "Folder", + "objectName": "Account", "recordId": "999Hn99999uM8mnBBB" } ``` @@ -200,80 +270,44 @@ Example input: ##### Output |Name|Type|Required|Description|Example| -|----|----|--------|-----------|-------| -|record|object|False|Matched record|{}| - +| :--- | :--- | :--- | :--- | :--- | +|record|object|False|Matched record|{"attributes":{"type":"Folder","url":"/services/data/v58.0/sobjects/Folder/00lHn000002nFolder"},"id":"00lHn000002nFolder","name":"Example Folder","developerName":"Bot_v5","accessType":"Hidden","isReadonly":true,"type":"Report","namespacePrefix":null,"createdDate":"2022-06-20T01:51:22.000+0000","createdById":"005Hn00000HExample","lastModifiedDate":"2022-06-20T01:51:22.000+0000","lastModifiedById":"005Hn00000HExample","systemModstamp":"2022-06-20T01:51:22.000+0000"}| + Example output: ``` { "record": { + "accessType": "Hidden", "attributes": { "type": "Folder", "url": "/services/data/v58.0/sobjects/Folder/00lHn000002nFolder" }, - "id": "00lHn000002nFolder", - "name": "Example Folder", + "createdById": "005Hn00000HExample", + "createdDate": "2022-06-20T01:51:22.000+0000", "developerName": "Bot_v5", - "accessType": "Hidden", + "id": "00lHn000002nFolder", "isReadonly": true, - "type": "Report", - "namespacePrefix": null, - "createdDate": "2022-06-20T01:51:22.000+0000", - "createdById": "005Hn00000HExample", - "lastModifiedDate": "2022-06-20T01:51:22.000+0000", "lastModifiedById": "005Hn00000HExample", - "systemModstamp": "2022-06-20T01:51:22.000+0000" + "lastModifiedDate": "2022-06-20T01:51:22.000+0000", + "name": "Example Folder", + "namespacePrefix": null, + "systemModstamp": "2022-06-20T01:51:22.000+0000", + "type": "Report" } } ``` -#### Get Blob Data - -This action is used to retrieve blob data for a given record. - -##### Input - -|Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| -|fieldName|string|body|True|Blob field name|None|body| -|objectName|string|Attachment|True|The name of the object (e.g. 'Attachment')|None|Attachment| -|recordId|string|None|True|The ID of an existing record|None|001Hn00001uAJRtaB3| - -Example input: - -``` -{ - "fieldName": "body", - "objectName": "Attachment", - "recordId": "001Hn00001uAJRtaB3" -} -``` - -##### Output - -|Name|Type|Required|Description|Example| -|----|----|--------|-----------|------| -|data|bytes|False|The value of the selected blob field|dGVzdA==| - -Example output: - -``` -{ - "data": "dGVzdA==" -} -``` - #### Simple Search - + This action is used to execute a simple search for a text. ##### Input |Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | |text|string|None|True|Text to search for|None|test| - + Example input: ``` @@ -285,98 +319,67 @@ Example input: ##### Output |Name|Type|Required|Description|Example| -|----|----|--------|-----------|-------| -|searchResults|[]searchResult|False|List of search results|[]| - +| :--- | :--- | :--- | :--- | :--- | +|searchResults|[]searchResult|False|List of search results|[{"type":"Account","url":"/services/data/v58.0/sobjects/Account/001Hn00001uAccount","id":"001Hn00001uAccount"},{"type":"ExternalObject__c","url":"/services/data/v58.0/sobjects/ExternalObject__c/a00Hn00000External","id":"a00Hn00000External"},{"type":"Customer","url":"/services/data/v58.0/sobjects/Customer/0o6Hn00000Customer","id":"0o6Hn00000Customer"},{"type":"Topic","url":"/services/data/v58.0/sobjects/Topic/0TOHn000000I1Topic","id":"0TOHn000000I1Topic"},{"type":"CollaborationGroup","url":"/services/data/v58.0/sobjects/CollaborationGroup/0F9Hn000000PCollab","id":"0F9Hn000000PCollab"},{"type":"Note","url":"/services/data/v58.0/sobjects/Note/002Hn00000n5KANote","id":"002Hn00000n5KANote"}]| + Example output: ``` { "searchResults": [ { + "id": "001Hn00001uAccount", "type": "Account", - "url": "/services/data/v58.0/sobjects/Account/001Hn00001uAccount", - "id": "001Hn00001uAccount" + "url": "/services/data/v58.0/sobjects/Account/001Hn00001uAccount" }, { + "id": "a00Hn00000External", "type": "ExternalObject__c", - "url": "/services/data/v58.0/sobjects/ExternalObject__c/a00Hn00000External", - "id": "a00Hn00000External" + "url": "/services/data/v58.0/sobjects/ExternalObject__c/a00Hn00000External" }, { + "id": "0o6Hn00000Customer", "type": "Customer", - "url": "/services/data/v58.0/sobjects/Customer/0o6Hn00000Customer", - "id": "0o6Hn00000Customer" + "url": "/services/data/v58.0/sobjects/Customer/0o6Hn00000Customer" }, { + "id": "0TOHn000000I1Topic", "type": "Topic", - "url": "/services/data/v58.0/sobjects/Topic/0TOHn000000I1Topic", - "id": "0TOHn000000I1Topic" + "url": "/services/data/v58.0/sobjects/Topic/0TOHn000000I1Topic" }, { + "id": "0F9Hn000000PCollab", "type": "CollaborationGroup", - "url": "/services/data/v58.0/sobjects/CollaborationGroup/0F9Hn000000PCollab", - "id": "0F9Hn000000PCollab" + "url": "/services/data/v58.0/sobjects/CollaborationGroup/0F9Hn000000PCollab" }, { + "id": "002Hn00000n5KANote", "type": "Note", - "url": "/services/data/v58.0/sobjects/Note/002Hn00000n5KANote", - "id": "002Hn00000n5KANote" + "url": "/services/data/v58.0/sobjects/Note/002Hn00000n5KANote" } ] } ``` -#### Create Record - -This action is used to create a new SObject record. - -##### Input - -|Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| -|objectData|object|None|True|SObject information for the newly created record|None|{"name": "example-name"}| -|objectName|string|None|True|The name of the object (e.g. 'Account')|None|Account| - -Example input: -``` -{ - "objectData": { - "name": "example-name" - }, - "objectName": "Account" -} -``` - -##### Output - -|Name|Type|Required|Description|Example| -|----|----|--------|-----------|-------| -|id|string|False|ID of the newly created record|000AA000000aa0aAAA| - -Example output: - -``` -{ - "id": "000AA000000aa0aAAA" -} -``` - -#### Delete Record - -This action is used to delete a record. +#### Update Record + +This action is used to update a record. ##### Input |Name|Type|Default|Required|Description|Enum|Example| -|----|----|-------|--------|-----------|----|-------| +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | +|objectData|object|None|True|Updated SObject information|None|{"name": "example-name"}| |objectName|string|Account|True|The name of the object (e.g. 'Account')|None|Account| |recordId|string|None|True|The ID of an existing record|None|000AA000000aa0aAAA| - + Example input: ``` { + "objectData": { + "name": "example-name" + }, "objectName": "Account", "recordId": "000AA000000aa0aAAA" } @@ -385,9 +388,9 @@ Example input: ##### Output |Name|Type|Required|Description|Example| -|----|----|--------|-----------|-------| +| :--- | :--- | :--- | :--- | :--- | |success|boolean|False|Was the operation successful|True| - + Example output: ``` @@ -395,142 +398,143 @@ Example output: "success": true } ``` - ### Triggers - -_This plugin does not contain any triggers._ - + +*This plugin does not contain any triggers.* ### Tasks -#### Monitor Users +#### Monitor Users + This task is used to get information about users, their login history and which users have been updated. ##### Input - -_This task does not contain any inputs._ + +*This task does not contain any inputs.* ##### Output |Name|Type|Required|Description|Example| -|----|----|--------|-----------|-------| -|users|[]userData|True|Information about users, their login history and which users have been updated|[]| - +| :--- | :--- | :--- | :--- | :--- | +|users|[]object|True|Information about users, their login history and which users have been updated|[{"attributes":{"type":"User","url":"/services/data/v58.0/sobjects/User/005Hn00000HVWwxIAH"},"id":"005Hn00000HVWwxIAH","firstName":"Security","lastName":"User","email":"user@example.com","alias":"sec","isActive":true,"dataType":"User Update"},{"attributes":{"type":"User","url":"/services/data/v58.0/sobjects/User/005Hn00000H35JtIAJ"},"id":"005Hn00000H35JtIAJ","firstName":"Example","lastName":"User","email":"user2@example.com","alias":"exam","isActive":true,"dataType":"User"},{"attributes":{"type":"User","url":"/services/data/v58.0/sobjects/User/005Hn00000HVWwxIAH"},"id":"005Hn00000HVWwxIAH","firstName":"Security","lastName":"User","email":"user@example.com","alias":"sec","isActive":true,"dataType":"User"},{"attributes":{"type":"LoginHistory","url":"/services/data/v58.0/sobjects/LoginHistory/0YaHn0000EUyGdHKQV"},"loginTime":"2023-07-23T16:18:23.000+0000","userId":"005Hn00000H35JtIAJ","loginType":"Remote Access 2.0","loginUrl":"login.salesforce.com","sourceIp":"198.51.100.1","status":"Success","application":"New Connected App","browser":"Unknown","dataType":"User Login"},{"attributes":{"type":"LoginHistory","url":"/services/data/v58.0/sobjects/LoginHistory/0YaHn0000EUyGkcKQF"},"loginTime":"2023-07-23T16:20:13.000+0000","userId":"005Hn00000H35JtIAJ","loginType":"Application","loginUrl":"example.salesforce.com","sourceIp":"198.51.100.1","status":"Success","application":"Browser","browser":"Chrome 115","dataType":"User Login"}]| + Example output: ``` { "users": [ { + "alias": "sec", "attributes": { "type": "User", "url": "/services/data/v58.0/sobjects/User/005Hn00000HVWwxIAH" }, - "id": "005Hn00000HVWwxIAH", - "firstName": "Security", - "lastName": "User", + "dataType": "User Update", "email": "user@example.com", - "alias": "sec", + "firstName": "Security", + "id": "005Hn00000HVWwxIAH", "isActive": true, - "dataType": "User Update" + "lastName": "User" }, { + "alias": "exam", "attributes": { "type": "User", "url": "/services/data/v58.0/sobjects/User/005Hn00000H35JtIAJ" }, - "id": "005Hn00000H35JtIAJ", - "firstName": "Example", - "lastName": "User", + "dataType": "User", "email": "user2@example.com", - "alias": "exam", + "firstName": "Example", + "id": "005Hn00000H35JtIAJ", "isActive": true, - "dataType": "User" + "lastName": "User" }, { + "alias": "sec", "attributes": { "type": "User", "url": "/services/data/v58.0/sobjects/User/005Hn00000HVWwxIAH" }, - "id": "005Hn00000HVWwxIAH", - "firstName": "Security", - "lastName": "User", + "dataType": "User", "email": "user@example.com", - "alias": "sec", + "firstName": "Security", + "id": "005Hn00000HVWwxIAH", "isActive": true, - "dataType": "User" + "lastName": "User" }, { + "application": "New Connected App", "attributes": { "type": "LoginHistory", "url": "/services/data/v58.0/sobjects/LoginHistory/0YaHn0000EUyGdHKQV" }, + "browser": "Unknown", + "dataType": "User Login", "loginTime": "2023-07-23T16:18:23.000+0000", - "userId": "005Hn00000H35JtIAJ", "loginType": "Remote Access 2.0", "loginUrl": "login.salesforce.com", "sourceIp": "198.51.100.1", "status": "Success", - "application": "New Connected App", - "browser": "Unknown", - "dataType": "User Login" + "userId": "005Hn00000H35JtIAJ" }, { + "application": "Browser", "attributes": { "type": "LoginHistory", "url": "/services/data/v58.0/sobjects/LoginHistory/0YaHn0000EUyGkcKQF" }, + "browser": "Chrome 115", + "dataType": "User Login", "loginTime": "2023-07-23T16:20:13.000+0000", - "userId": "005Hn00000H35JtIAJ", "loginType": "Application", "loginUrl": "example.salesforce.com", "sourceIp": "198.51.100.1", "status": "Success", - "application": "Browser", - "browser": "Chrome 115", - "dataType": "User Login" + "userId": "005Hn00000H35JtIAJ" } ] } ``` -### Custom Output Types - -#### searchResult - -|Name|Type|Required|Description| -|----|----|--------|-----------| -|ID|string|False|ID of the record| -|Name|string|False|Name of the record| -|Type|string|False|Type of the record| -|URL|string|False|URL of the record| - -#### userData - -|Name|Type|Required|Description| -|----|----|--------|-----------| -|Alias|string|False|The user's alias| -|Application|string|False|The application used to access the organization| -|Browser|string|False|The current browser version| -|Data Type|string|False|Type of the data| -|Email|string|False|The user's email address| -|First Name|string|False|The user's first name| -|ID|string|False|The ID of the user| -|Is Active|boolean|False|Indicates whether the user has access to log in (true) or not (false)| -|Last Name|string|False|The user's last name| -|Login Time|string|False|The time of user login. Time zone is based on GMT| -|Login Type|string|False|The type of login used to access the session| -|Login URL|string|False|URL from which the login request is coming| -|Source IP|string|False|IP address of the machine from which the login request is coming. The address can be an IPv4 or IPv6 address| -|Status|string|False|Displays the status of the attempted login. Status is either success or a reason for failure| -|User ID|string|False|ID of the user logging in| +### Custom Types + +**searchResult** + +|Name|Type|Default|Required|Description|Example| +| :--- | :--- | :--- | :--- | :--- | :--- | +|ID|string|None|False|ID of the record|001Hn00001uAJRtaB3| +|Name|string|None|None|Name of the record|Example Account| +|Type|string|None|False|Type of the record|Account| +|URL|string|None|False|URL of the record|/services/data/v58.0/sobjects/Account/001Hn00001uAJRtaB3| + +**userData** + +|Name|Type|Default|Required|Description|Example| +| :--- | :--- | :--- | :--- | :--- | :--- | +|Alias|string|None|False|The user's alias|jsmith| +|Application|string|None|False|The application used to access the organization|Browser| +|Browser|string|None|False|The current browser version|Chrome 114| +|Data Type|string|None|False|Type of the data|User Login| +|Email|string|None|False|The user's email address|user@example.com| +|First Name|string|None|False|The user's first name|John| +|ID|string|None|False|The ID of the user|005Hn00000HVWwsIAH| +|Is Active|boolean|None|False|Indicates whether the user has access to log in (true) or not (false)|True| +|Last Name|string|None|False|The user's last name|Smith| +|Login Time|string|None|False|The time of user login. Time zone is based on GMT|2023-06-28T09:15:32.000+0000| +|Login Type|string|None|False|The type of login used to access the session|Application| +|Login URL|string|None|False|URL from which the login request is coming|https://example.com| +|Source IP|string|None|False|IP address of the machine from which the login request is coming. The address can be an IPv4 or IPv6 address|198.51.100.1| +|Status|string|None|False|Displays the status of the attempted login. Status is either success or a reason for failure|Success| +|User ID|string|None|False|ID of the user logging in|005Hn00000HVWwsIAH| -## Troubleshooting -_This plugin does not contain any troubleshooting information._ +## Troubleshooting + +*There is no troubleshooting for this plugin.* # Version History +* 2.1.5 - Task Monitor Users: Improved logging * 2.1.4 - Connection: Remove unnecessary logging * 2.1.3 - Task Monitor Users: improve deduplication logic on user login history * 2.1.2 - Task Monitor Users: normalisation for date in state, handle backwards compatibility diff --git a/plugins/salesforce/komand_salesforce/actions/__init__.py b/plugins/salesforce/komand_salesforce/actions/__init__.py index b86a900392..98c6912ccd 100755 --- a/plugins/salesforce/komand_salesforce/actions/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/__init__.py @@ -1,9 +1,18 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT + +from .simple_search.action import SimpleSearch + from .advanced_search.action import AdvancedSearch + from .create_record.action import CreateRecord + +from .update_record.action import UpdateRecord + +from .get_record.action import GetRecord + from .delete_record.action import DeleteRecord -from .get_blob_data.action import GetBlobData + from .get_fields.action import GetFields -from .get_record.action import GetRecord -from .simple_search.action import SimpleSearch -from .update_record.action import UpdateRecord + +from .get_blob_data.action import GetBlobData + diff --git a/plugins/salesforce/komand_salesforce/actions/advanced_search/__init__.py b/plugins/salesforce/komand_salesforce/actions/advanced_search/__init__.py index 032bae73c1..ec79d2d3da 100755 --- a/plugins/salesforce/komand_salesforce/actions/advanced_search/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/advanced_search/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import AdvancedSearch diff --git a/plugins/salesforce/komand_salesforce/actions/advanced_search/schema.py b/plugins/salesforce/komand_salesforce/actions/advanced_search/schema.py index f5bb7a7756..ee699b2223 100755 --- a/plugins/salesforce/komand_salesforce/actions/advanced_search/schema.py +++ b/plugins/salesforce/komand_salesforce/actions/advanced_search/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -9,14 +9,14 @@ class Component: class Input: QUERY = "query" - + class Output: SEARCHRESULTS = "searchResults" - + class AdvancedSearchInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -30,7 +30,8 @@ class AdvancedSearchInput(insightconnect_plugin_runtime.Input): }, "required": [ "query" - ] + ], + "definitions": {} } """) @@ -39,7 +40,7 @@ def __init__(self): class AdvancedSearchOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -59,18 +60,6 @@ class AdvancedSearchOutput(insightconnect_plugin_runtime.Output): "type": "object", "title": "searchResult", "properties": { - "id": { - "type": "string", - "title": "ID", - "description": "ID of the record", - "order": 4 - }, - "name": { - "type": "string", - "title": "Name", - "description": "Name of the record", - "order": 3 - }, "type": { "type": "string", "title": "Type", @@ -82,6 +71,18 @@ class AdvancedSearchOutput(insightconnect_plugin_runtime.Output): "title": "URL", "description": "URL of the record", "order": 2 + }, + "name": { + "type": "string", + "title": "Name", + "description": "Name of the record", + "order": 3 + }, + "id": { + "type": "string", + "title": "ID", + "description": "ID of the record", + "order": 4 } } } diff --git a/plugins/salesforce/komand_salesforce/actions/create_record/__init__.py b/plugins/salesforce/komand_salesforce/actions/create_record/__init__.py index d93dfd28ad..ab772528be 100755 --- a/plugins/salesforce/komand_salesforce/actions/create_record/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/create_record/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import CreateRecord diff --git a/plugins/salesforce/komand_salesforce/actions/create_record/schema.py b/plugins/salesforce/komand_salesforce/actions/create_record/schema.py index 124adf58e1..6f14268b56 100755 --- a/plugins/salesforce/komand_salesforce/actions/create_record/schema.py +++ b/plugins/salesforce/komand_salesforce/actions/create_record/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -10,14 +10,14 @@ class Component: class Input: OBJECTDATA = "objectData" OBJECTNAME = "objectName" - + class Output: ID = "id" - + class CreateRecordInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -38,7 +38,8 @@ class CreateRecordInput(insightconnect_plugin_runtime.Input): "required": [ "objectData", "objectName" - ] + ], + "definitions": {} } """) @@ -47,7 +48,7 @@ def __init__(self): class CreateRecordOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -58,7 +59,8 @@ class CreateRecordOutput(insightconnect_plugin_runtime.Output): "description": "ID of the newly created record", "order": 1 } - } + }, + "definitions": {} } """) diff --git a/plugins/salesforce/komand_salesforce/actions/delete_record/__init__.py b/plugins/salesforce/komand_salesforce/actions/delete_record/__init__.py index 39b41703cd..c9501c5d5b 100755 --- a/plugins/salesforce/komand_salesforce/actions/delete_record/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/delete_record/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import DeleteRecord diff --git a/plugins/salesforce/komand_salesforce/actions/delete_record/schema.py b/plugins/salesforce/komand_salesforce/actions/delete_record/schema.py index 10c3bf6fde..a3b9f9d949 100755 --- a/plugins/salesforce/komand_salesforce/actions/delete_record/schema.py +++ b/plugins/salesforce/komand_salesforce/actions/delete_record/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -10,14 +10,14 @@ class Component: class Input: OBJECTNAME = "objectName" RECORDID = "recordId" - + class Output: SUCCESS = "success" - + class DeleteRecordInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -39,7 +39,8 @@ class DeleteRecordInput(insightconnect_plugin_runtime.Input): "required": [ "objectName", "recordId" - ] + ], + "definitions": {} } """) @@ -48,7 +49,7 @@ def __init__(self): class DeleteRecordOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -59,7 +60,8 @@ class DeleteRecordOutput(insightconnect_plugin_runtime.Output): "description": "Was the operation successful", "order": 1 } - } + }, + "definitions": {} } """) diff --git a/plugins/salesforce/komand_salesforce/actions/get_blob_data/__init__.py b/plugins/salesforce/komand_salesforce/actions/get_blob_data/__init__.py index 7c9dd11d85..1e7df30882 100755 --- a/plugins/salesforce/komand_salesforce/actions/get_blob_data/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/get_blob_data/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import GetBlobData diff --git a/plugins/salesforce/komand_salesforce/actions/get_blob_data/schema.py b/plugins/salesforce/komand_salesforce/actions/get_blob_data/schema.py index 4a3e856f16..a0d70cd3e4 100755 --- a/plugins/salesforce/komand_salesforce/actions/get_blob_data/schema.py +++ b/plugins/salesforce/komand_salesforce/actions/get_blob_data/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -11,14 +11,14 @@ class Input: FIELDNAME = "fieldName" OBJECTNAME = "objectName" RECORDID = "recordId" - + class Output: DATA = "data" - + class GetBlobDataInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -48,7 +48,8 @@ class GetBlobDataInput(insightconnect_plugin_runtime.Input): "fieldName", "objectName", "recordId" - ] + ], + "definitions": {} } """) @@ -57,20 +58,21 @@ def __init__(self): class GetBlobDataOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", "properties": { "data": { "type": "string", - "title": "Data", + "format": "bytes", "displayType": "bytes", + "title": "Data", "description": "The value of the selected blob field", - "format": "bytes", "order": 1 } - } + }, + "definitions": {} } """) diff --git a/plugins/salesforce/komand_salesforce/actions/get_fields/__init__.py b/plugins/salesforce/komand_salesforce/actions/get_fields/__init__.py index d4377fea4a..93c91c5aac 100755 --- a/plugins/salesforce/komand_salesforce/actions/get_fields/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/get_fields/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import GetFields diff --git a/plugins/salesforce/komand_salesforce/actions/get_fields/schema.py b/plugins/salesforce/komand_salesforce/actions/get_fields/schema.py index 51a58fcd81..28123c4833 100755 --- a/plugins/salesforce/komand_salesforce/actions/get_fields/schema.py +++ b/plugins/salesforce/komand_salesforce/actions/get_fields/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -11,14 +11,14 @@ class Input: FIELDS = "fields" OBJECTNAME = "objectName" RECORDID = "recordId" - + class Output: FIELDS = "fields" - + class GetFieldsInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -50,7 +50,8 @@ class GetFieldsInput(insightconnect_plugin_runtime.Input): "fields", "objectName", "recordId" - ] + ], + "definitions": {} } """) @@ -59,7 +60,7 @@ def __init__(self): class GetFieldsOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -70,7 +71,8 @@ class GetFieldsOutput(insightconnect_plugin_runtime.Output): "description": "An object with field names as keys, each with the corresponding value", "order": 1 } - } + }, + "definitions": {} } """) diff --git a/plugins/salesforce/komand_salesforce/actions/get_record/__init__.py b/plugins/salesforce/komand_salesforce/actions/get_record/__init__.py index 3f344089b2..738a9e7b64 100755 --- a/plugins/salesforce/komand_salesforce/actions/get_record/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/get_record/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import GetRecord diff --git a/plugins/salesforce/komand_salesforce/actions/get_record/schema.py b/plugins/salesforce/komand_salesforce/actions/get_record/schema.py index c45c3d5f8a..ae4c0a7846 100755 --- a/plugins/salesforce/komand_salesforce/actions/get_record/schema.py +++ b/plugins/salesforce/komand_salesforce/actions/get_record/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -11,14 +11,14 @@ class Input: EXTERNALIDFIELDNAME = "externalIdFieldName" OBJECTNAME = "objectName" RECORDID = "recordId" - + class Output: RECORD = "record" - + class GetRecordInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -27,7 +27,6 @@ class GetRecordInput(insightconnect_plugin_runtime.Input): "type": "string", "title": "External ID Field Name", "description": "The name of the external ID field that should be matched with record_id. If empty, the 'Id' field of the record is used", - "default": "", "order": 2 }, "objectName": { @@ -47,7 +46,8 @@ class GetRecordInput(insightconnect_plugin_runtime.Input): "required": [ "objectName", "recordId" - ] + ], + "definitions": {} } """) @@ -56,7 +56,7 @@ def __init__(self): class GetRecordOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -67,7 +67,8 @@ class GetRecordOutput(insightconnect_plugin_runtime.Output): "description": "Matched record", "order": 1 } - } + }, + "definitions": {} } """) diff --git a/plugins/salesforce/komand_salesforce/actions/simple_search/__init__.py b/plugins/salesforce/komand_salesforce/actions/simple_search/__init__.py index be0276584b..20eb0fe290 100755 --- a/plugins/salesforce/komand_salesforce/actions/simple_search/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/simple_search/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import SimpleSearch diff --git a/plugins/salesforce/komand_salesforce/actions/simple_search/schema.py b/plugins/salesforce/komand_salesforce/actions/simple_search/schema.py index 568bb8bd17..07592f8c31 100755 --- a/plugins/salesforce/komand_salesforce/actions/simple_search/schema.py +++ b/plugins/salesforce/komand_salesforce/actions/simple_search/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -9,14 +9,14 @@ class Component: class Input: TEXT = "text" - + class Output: SEARCHRESULTS = "searchResults" - + class SimpleSearchInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -30,7 +30,8 @@ class SimpleSearchInput(insightconnect_plugin_runtime.Input): }, "required": [ "text" - ] + ], + "definitions": {} } """) @@ -39,7 +40,7 @@ def __init__(self): class SimpleSearchOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -59,18 +60,6 @@ class SimpleSearchOutput(insightconnect_plugin_runtime.Output): "type": "object", "title": "searchResult", "properties": { - "id": { - "type": "string", - "title": "ID", - "description": "ID of the record", - "order": 4 - }, - "name": { - "type": "string", - "title": "Name", - "description": "Name of the record", - "order": 3 - }, "type": { "type": "string", "title": "Type", @@ -82,6 +71,18 @@ class SimpleSearchOutput(insightconnect_plugin_runtime.Output): "title": "URL", "description": "URL of the record", "order": 2 + }, + "name": { + "type": "string", + "title": "Name", + "description": "Name of the record", + "order": 3 + }, + "id": { + "type": "string", + "title": "ID", + "description": "ID of the record", + "order": 4 } } } diff --git a/plugins/salesforce/komand_salesforce/actions/update_record/__init__.py b/plugins/salesforce/komand_salesforce/actions/update_record/__init__.py index 92ff435631..697153b458 100755 --- a/plugins/salesforce/komand_salesforce/actions/update_record/__init__.py +++ b/plugins/salesforce/komand_salesforce/actions/update_record/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .action import UpdateRecord diff --git a/plugins/salesforce/komand_salesforce/actions/update_record/schema.py b/plugins/salesforce/komand_salesforce/actions/update_record/schema.py index a3c3fab55a..bd405a974d 100755 --- a/plugins/salesforce/komand_salesforce/actions/update_record/schema.py +++ b/plugins/salesforce/komand_salesforce/actions/update_record/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -11,14 +11,14 @@ class Input: OBJECTDATA = "objectData" OBJECTNAME = "objectName" RECORDID = "recordId" - + class Output: SUCCESS = "success" - + class UpdateRecordInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -47,7 +47,8 @@ class UpdateRecordInput(insightconnect_plugin_runtime.Input): "objectData", "objectName", "recordId" - ] + ], + "definitions": {} } """) @@ -56,7 +57,7 @@ def __init__(self): class UpdateRecordOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -67,7 +68,8 @@ class UpdateRecordOutput(insightconnect_plugin_runtime.Output): "description": "Was the operation successful", "order": 1 } - } + }, + "definitions": {} } """) diff --git a/plugins/salesforce/komand_salesforce/connection/__init__.py b/plugins/salesforce/komand_salesforce/connection/__init__.py index a515dcf6b0..c78d3356be 100755 --- a/plugins/salesforce/komand_salesforce/connection/__init__.py +++ b/plugins/salesforce/komand_salesforce/connection/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .connection import Connection diff --git a/plugins/salesforce/komand_salesforce/connection/schema.py b/plugins/salesforce/komand_salesforce/connection/schema.py index fb9a03fc1c..4e34fe820c 100755 --- a/plugins/salesforce/komand_salesforce/connection/schema.py +++ b/plugins/salesforce/komand_salesforce/connection/schema.py @@ -1,4 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json @@ -8,10 +8,10 @@ class Input: CLIENTSECRET = "clientSecret" SALESFORCEACCOUNTUSERNAMEANDPASSWORD = "salesforceAccountUsernameAndPassword" SECURITYTOKEN = "securityToken" - + class ConnectionSchema(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" { "type": "object", "title": "Variables", @@ -53,38 +53,38 @@ class ConnectionSchema(insightconnect_plugin_runtime.Input): "type": "object", "title": "Credential: Secret Key", "description": "A shared secret key", + "required": [ + "secretKey" + ], "properties": { "secretKey": { "type": "string", "title": "Secret Key", - "displayType": "password", "description": "The shared secret key", - "format": "password" + "format": "password", + "displayType": "password" } - }, - "required": [ - "secretKey" - ] + } }, "credential_username_password": { "id": "credential_username_password", - "type": "object", "title": "Credential: Username and Password", "description": "A username and password combination", + "type": "object", "properties": { + "username": { + "type": "string", + "title": "Username", + "description": "The username to log in with", + "order": 1 + }, "password": { "type": "string", "title": "Password", - "displayType": "password", "description": "The password", "format": "password", + "displayType": "password", "order": 2 - }, - "username": { - "type": "string", - "title": "Username", - "description": "The username to log in with", - "order": 1 } }, "required": [ diff --git a/plugins/salesforce/komand_salesforce/tasks/__init__.py b/plugins/salesforce/komand_salesforce/tasks/__init__.py index 349d51f6d9..4989bad18b 100755 --- a/plugins/salesforce/komand_salesforce/tasks/__init__.py +++ b/plugins/salesforce/komand_salesforce/tasks/__init__.py @@ -1,2 +1,4 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT + from .monitor_users.task import MonitorUsers + diff --git a/plugins/salesforce/komand_salesforce/tasks/monitor_users/__init__.py b/plugins/salesforce/komand_salesforce/tasks/monitor_users/__init__.py index 102297f7aa..1e6a5ccdfa 100755 --- a/plugins/salesforce/komand_salesforce/tasks/monitor_users/__init__.py +++ b/plugins/salesforce/komand_salesforce/tasks/monitor_users/__init__.py @@ -1,2 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from .task import MonitorUsers diff --git a/plugins/salesforce/komand_salesforce/tasks/monitor_users/schema.py b/plugins/salesforce/komand_salesforce/tasks/monitor_users/schema.py index 343e7cd58a..c3d480a0ca 100755 --- a/plugins/salesforce/komand_salesforce/tasks/monitor_users/schema.py +++ b/plugins/salesforce/komand_salesforce/tasks/monitor_users/schema.py @@ -1,24 +1,26 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT import insightconnect_plugin_runtime import json class Component: - DESCRIPTION = "Get information about users, their login history and changes made to user data" + DESCRIPTION = "Get information about users, their login history and which users have been updated" class Input: pass + class State: pass + class Output: USERS = "users" - + class MonitorUsersInput(insightconnect_plugin_runtime.Input): - schema = json.loads(""" + schema = json.loads(r""" {} """) @@ -27,7 +29,7 @@ def __init__(self): class MonitorUsersState(insightconnect_plugin_runtime.State): - schema = json.loads(""" + schema = json.loads(r""" {} """) @@ -36,17 +38,15 @@ def __init__(self): class MonitorUsersOutput(insightconnect_plugin_runtime.Output): - schema = json.loads(""" - { + schema = json.loads(r""" + { "type": "array", "title": "Users", - "description": "Information about users, their login history and changes made to user data", - "items": { - "type": "object" - }, + "description": "Information about users, their login history and which users have been updated", "required": [ "users" - ] + ], + "definitions": {} } """) diff --git a/plugins/salesforce/komand_salesforce/tasks/monitor_users/task.py b/plugins/salesforce/komand_salesforce/tasks/monitor_users/task.py index 0b3a10cc6a..5077ad156e 100755 --- a/plugins/salesforce/komand_salesforce/tasks/monitor_users/task.py +++ b/plugins/salesforce/komand_salesforce/tasks/monitor_users/task.py @@ -79,6 +79,7 @@ def run(self, params={}, state={}): # noqa: C901 is_valid_state, key = self._is_valid_state(state) if not is_valid_state: + self.logger.info(f"Bad request error occurred. Invalid timestamp format for {key}") return ( [], state, @@ -172,8 +173,10 @@ def run(self, params={}, state={}): # noqa: C901 return records, state, has_more_pages, 200, None except ApiException as error: + self.logger.info(f"An API Exception has been raised. Status code: {error.status_code}. Error: {error}") return [], state, False, error.status_code, error except Exception as error: + self.logger.info(f"An Exception has been raised. Error: {error}") return [], state, False, 500, PluginException(preset=PluginException.Preset.UNKNOWN, data=error) def _is_valid_state(self, state: dict) -> Union[bool, str]: diff --git a/plugins/salesforce/komand_salesforce/triggers/__init__.py b/plugins/salesforce/komand_salesforce/triggers/__init__.py index bace8db897..7020c9a4ad 100755 --- a/plugins/salesforce/komand_salesforce/triggers/__init__.py +++ b/plugins/salesforce/komand_salesforce/triggers/__init__.py @@ -1 +1,2 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT + diff --git a/plugins/salesforce/plugin.spec.yaml b/plugins/salesforce/plugin.spec.yaml index 16bec75161..889a75c160 100644 --- a/plugins/salesforce/plugin.spec.yaml +++ b/plugins/salesforce/plugin.spec.yaml @@ -4,13 +4,17 @@ products: [insightconnect] name: salesforce title: Salesforce description: The Salesforce plugin allows you to search, update, and manage salesforce records -version: 2.1.4 +version: 2.1.5 connection_version: 2 vendor: rapid7 support: community cloud_ready: true status: [] supported_versions: ["Salesforce API v58 2023-06-30"] +sdk: + type: full + version: 5 + user: nobody resources: source_url: https://github.com/rapid7/insightconnect-plugins/tree/master/plugins/salesforce license_url: https://github.com/rapid7/insightconnect-plugins/blob/master/LICENSE @@ -182,7 +186,7 @@ actions: description: List of search results type: '[]searchResult' required: false - example: [] + example: '[{"type":"Account","url":"/services/data/v58.0/sobjects/Account/001Hn00001uAccount","id":"001Hn00001uAccount"},{"type":"ExternalObject__c","url":"/services/data/v58.0/sobjects/ExternalObject__c/a00Hn00000External","id":"a00Hn00000External"},{"type":"Customer","url":"/services/data/v58.0/sobjects/Customer/0o6Hn00000Customer","id":"0o6Hn00000Customer"},{"type":"Topic","url":"/services/data/v58.0/sobjects/Topic/0TOHn000000I1Topic","id":"0TOHn000000I1Topic"},{"type":"CollaborationGroup","url":"/services/data/v58.0/sobjects/CollaborationGroup/0F9Hn000000PCollab","id":"0F9Hn000000PCollab"},{"type":"Note","url":"/services/data/v58.0/sobjects/Note/002Hn00000n5KANote","id":"002Hn00000n5KANote"}]' advanced_search: title: Advanced Search description: Execute a SOQL (Salesforce Object Query Language) query @@ -199,7 +203,7 @@ actions: description: List of search results type: '[]searchResult' required: false - example: [] + example: '[{"type":"Account","url":"/services/data/v58.0/sobjects/Account/001Hn00001uLl12aBC","name":"Example Account","id":"001Hn00001uLl12aBC"}]' create_record: title: Create Record description: Create a new SObject record @@ -268,7 +272,6 @@ actions: description: The name of the external ID field that should be matched with record_id. If empty, the 'Id' field of the record is used type: string required: false - default: '' example: ExampleExtID__c objectName: title: Object Name @@ -283,7 +286,7 @@ actions: description: Matched record type: object required: false - example: {} + example: '{"attributes":{"type":"Folder","url":"/services/data/v58.0/sobjects/Folder/00lHn000002nFolder"},"id":"00lHn000002nFolder","name":"Example Folder","developerName":"Bot_v5","accessType":"Hidden","isReadonly":true,"type":"Report","namespacePrefix":null,"createdDate":"2022-06-20T01:51:22.000+0000","createdById":"005Hn00000HExample","lastModifiedDate":"2022-06-20T01:51:22.000+0000","lastModifiedById":"005Hn00000HExample","systemModstamp":"2022-06-20T01:51:22.000+0000"}' delete_record: title: Delete Record description: Delete a record @@ -330,14 +333,14 @@ actions: description: The fields which values should be retrieved type: '[]string' required: true - example: ["Id", "Name", "Description"] + example: '["Id", "Name", "Description"]' output: fields: title: Fields description: An object with field names as keys, each with the corresponding value type: object required: false - example: {} + example: '{"id":"001Hn00001uAJRtaB3","name":"Example Account","description":"Example description"}' get_blob_data: title: Get Blob Data description: Retrieve blob data for a given record @@ -379,4 +382,4 @@ tasks: description: Information about users, their login history and which users have been updated type: "[]object" required: true - example: [] + example: '[{"attributes":{"type":"User","url":"/services/data/v58.0/sobjects/User/005Hn00000HVWwxIAH"},"id":"005Hn00000HVWwxIAH","firstName":"Security","lastName":"User","email":"user@example.com","alias":"sec","isActive":true,"dataType":"User Update"},{"attributes":{"type":"User","url":"/services/data/v58.0/sobjects/User/005Hn00000H35JtIAJ"},"id":"005Hn00000H35JtIAJ","firstName":"Example","lastName":"User","email":"user2@example.com","alias":"exam","isActive":true,"dataType":"User"},{"attributes":{"type":"User","url":"/services/data/v58.0/sobjects/User/005Hn00000HVWwxIAH"},"id":"005Hn00000HVWwxIAH","firstName":"Security","lastName":"User","email":"user@example.com","alias":"sec","isActive":true,"dataType":"User"},{"attributes":{"type":"LoginHistory","url":"/services/data/v58.0/sobjects/LoginHistory/0YaHn0000EUyGdHKQV"},"loginTime":"2023-07-23T16:18:23.000+0000","userId":"005Hn00000H35JtIAJ","loginType":"Remote Access 2.0","loginUrl":"login.salesforce.com","sourceIp":"198.51.100.1","status":"Success","application":"New Connected App","browser":"Unknown","dataType":"User Login"},{"attributes":{"type":"LoginHistory","url":"/services/data/v58.0/sobjects/LoginHistory/0YaHn0000EUyGkcKQF"},"loginTime":"2023-07-23T16:20:13.000+0000","userId":"005Hn00000H35JtIAJ","loginType":"Application","loginUrl":"example.salesforce.com","sourceIp":"198.51.100.1","status":"Success","application":"Browser","browser":"Chrome 115","dataType":"User Login"}]' diff --git a/plugins/salesforce/setup.py b/plugins/salesforce/setup.py index 3d8e088106..e77665181e 100755 --- a/plugins/salesforce/setup.py +++ b/plugins/salesforce/setup.py @@ -1,9 +1,9 @@ -# GENERATED BY KOMAND SDK - DO NOT EDIT +# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT from setuptools import setup, find_packages setup(name="salesforce-rapid7-plugin", - version="2.1.4", + version="2.1.5", description="The Salesforce plugin allows you to search, update, and manage salesforce records", author="rapid7", author_email="", diff --git a/plugins/salesforce/unit_test/test_advanced_search.py b/plugins/salesforce/unit_test/test_advanced_search.py index c61c9a1995..66d0e43322 100644 --- a/plugins/salesforce/unit_test/test_advanced_search.py +++ b/plugins/salesforce/unit_test/test_advanced_search.py @@ -1,15 +1,19 @@ -import sys import os - +import sys sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase -from komand_salesforce.actions.advanced_search import AdvancedSearch -from unittest.mock import patch -from parameterized import parameterized +from unittest.mock import MagicMock, patch + from insightconnect_plugin_runtime.exceptions import PluginException +from jsonschema import validate +from komand_salesforce.actions.advanced_search import AdvancedSearch +from komand_salesforce.actions.advanced_search.schema import AdvancedSearchOutput from komand_salesforce.util.exceptions import ApiException +from parameterized import parameterized + from util import Util @@ -43,8 +47,11 @@ def setUpClass(cls) -> None: ], ] ) - def test_advanced_search(self, mock_request, test_name, input_params, expected): + def test_advanced_search( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: Dict[str, Any] + ) -> None: actual = self.action.run(input_params) + validate(actual, AdvancedSearchOutput.schema) self.assertEqual(actual, expected) @parameterized.expand( @@ -57,7 +64,9 @@ def test_advanced_search(self, mock_request, test_name, input_params, expected): ] ] ) - def test_advanced_search_raise_api_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_advanced_search_raise_api_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(ApiException) as error: self.action.run(input_params) self.assertEqual(error.exception.cause, cause) diff --git a/plugins/salesforce/unit_test/test_connection.py b/plugins/salesforce/unit_test/test_connection.py index e3ac2b734c..77ed5e059d 100644 --- a/plugins/salesforce/unit_test/test_connection.py +++ b/plugins/salesforce/unit_test/test_connection.py @@ -1,16 +1,19 @@ -import sys import os +import sys from insightconnect_plugin_runtime.exceptions import PluginException sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase +from unittest.mock import MagicMock, patch + from komand_salesforce.actions.simple_search import SimpleSearch -from util import Util -from unittest.mock import patch from parameterized import parameterized +from util import Util + @patch("requests.request", side_effect=Util.mock_request) class TestConnection(TestCase): @@ -23,7 +26,9 @@ class TestConnection(TestCase): ] ] ) - def test_connection(self, mock_request, test_name, input_params, expected): + def test_connection( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: str + ) -> None: self.action = Util.default_connector(SimpleSearch(), input_params) token, url = self.action.connection.api._get_token( self.action.connection.api._client_id, @@ -44,7 +49,9 @@ def test_connection(self, mock_request, test_name, input_params, expected): ] ] ) - def test_connection_raise_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_connection_raise_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(PluginException) as error: self.action = Util.default_connector(SimpleSearch(), input_params) self.action.connection.api._get_token( diff --git a/plugins/salesforce/unit_test/test_create_record.py b/plugins/salesforce/unit_test/test_create_record.py index b04039e9c3..1e2354e2c1 100644 --- a/plugins/salesforce/unit_test/test_create_record.py +++ b/plugins/salesforce/unit_test/test_create_record.py @@ -1,14 +1,19 @@ -import sys import os +import sys sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase -from komand_salesforce.actions.create_record.action import CreateRecord -from unittest.mock import patch -from parameterized import parameterized +from unittest.mock import MagicMock, patch + from insightconnect_plugin_runtime.exceptions import PluginException +from jsonschema import validate +from komand_salesforce.actions.create_record.action import CreateRecord +from komand_salesforce.actions.create_record.schema import CreateRecordOutput from komand_salesforce.util.exceptions import ApiException +from parameterized import parameterized + from util import Util @@ -32,8 +37,11 @@ def setUpClass(cls) -> None: ], ] ) - def test_create_record(self, mock_request, test_name, input_params, expected): + def test_create_record( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: str + ) -> None: actual = self.action.run(input_params) + validate(actual, CreateRecordOutput.schema) self.assertEqual(actual, expected) @parameterized.expand( @@ -58,7 +66,9 @@ def test_create_record(self, mock_request, test_name, input_params, expected): ], ] ) - def test_create_record_raise_api_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_create_record_raise_api_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(ApiException) as error: self.action.run(input_params) self.assertEqual(error.exception.cause, cause) diff --git a/plugins/salesforce/unit_test/test_delete_record.py b/plugins/salesforce/unit_test/test_delete_record.py index 22f8048c5e..b7eb647621 100644 --- a/plugins/salesforce/unit_test/test_delete_record.py +++ b/plugins/salesforce/unit_test/test_delete_record.py @@ -1,15 +1,20 @@ -import sys import os +import sys sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase +from unittest.mock import MagicMock, patch + +from insightconnect_plugin_runtime.exceptions import PluginException +from jsonschema import validate from komand_salesforce.actions.delete_record.action import DeleteRecord -from unittest.mock import patch -from parameterized import parameterized +from komand_salesforce.actions.delete_record.schema import DeleteRecordOutput from komand_salesforce.util.exceptions import ApiException +from parameterized import parameterized + from util import Util -from insightconnect_plugin_runtime.exceptions import PluginException @patch("requests.request", side_effect=Util.mock_request) @@ -27,8 +32,11 @@ def setUpClass(cls) -> None: ], ] ) - def test_delete_record(self, mock_request, test_name, input_params, expected): + def test_delete_record( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: str + ) -> None: actual = self.action.run(input_params) + validate(actual, DeleteRecordOutput.schema) self.assertEqual(actual, expected) @parameterized.expand( @@ -47,7 +55,9 @@ def test_delete_record(self, mock_request, test_name, input_params, expected): ], ] ) - def test_delete_record_raise_api_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_delete_record_raise_api_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(ApiException) as error: self.action.run(input_params) self.assertEqual(error.exception.cause, cause) diff --git a/plugins/salesforce/unit_test/test_get_blob_data.py b/plugins/salesforce/unit_test/test_get_blob_data.py index 43342ad54c..444a620183 100644 --- a/plugins/salesforce/unit_test/test_get_blob_data.py +++ b/plugins/salesforce/unit_test/test_get_blob_data.py @@ -1,15 +1,20 @@ -import sys import os +import sys sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase +from unittest.mock import MagicMock, patch + +from insightconnect_plugin_runtime.exceptions import PluginException +from jsonschema import validate from komand_salesforce.actions.get_blob_data import GetBlobData -from unittest.mock import patch -from parameterized import parameterized +from komand_salesforce.actions.get_blob_data.schema import GetBlobDataOutput from komand_salesforce.util.exceptions import ApiException +from parameterized import parameterized + from util import Util -from insightconnect_plugin_runtime.exceptions import PluginException @patch("requests.request", side_effect=Util.mock_request) @@ -32,8 +37,11 @@ def setUpClass(cls) -> None: ], ] ) - def test_get_blob_data(self, mock_request, test_name, input_params, expected): + def test_get_blob_data( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: Dict[str, Any] + ) -> None: actual = self.action.run(input_params) + validate(actual, GetBlobDataOutput.schema) self.assertEqual(actual, expected) @parameterized.expand( @@ -52,7 +60,9 @@ def test_get_blob_data(self, mock_request, test_name, input_params, expected): ], ] ) - def test_get_blob_data_raise_api_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_get_blob_data_raise_api_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(ApiException) as error: self.action.run(input_params) self.assertEqual(error.exception.cause, cause) diff --git a/plugins/salesforce/unit_test/test_get_fields.py b/plugins/salesforce/unit_test/test_get_fields.py index 031a617b36..6a741a4689 100644 --- a/plugins/salesforce/unit_test/test_get_fields.py +++ b/plugins/salesforce/unit_test/test_get_fields.py @@ -1,14 +1,19 @@ -import sys import os +import sys sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase -from komand_salesforce.actions.get_fields import GetFields -from unittest.mock import patch -from parameterized import parameterized +from unittest.mock import MagicMock, patch + from insightconnect_plugin_runtime.exceptions import PluginException +from jsonschema import validate +from komand_salesforce.actions.get_fields import GetFields +from komand_salesforce.actions.get_fields.schema import GetFieldsOutput from komand_salesforce.util.exceptions import ApiException +from parameterized import parameterized + from util import Util @@ -37,8 +42,11 @@ def setUpClass(cls) -> None: ], ] ) - def test_get_fields(self, mock_request, test_name, input_params, expected): + def test_get_fields( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: Dict[str, Any] + ) -> None: actual = self.action.run(input_params) + validate(actual, GetFieldsOutput.schema) self.assertEqual(actual, expected) @parameterized.expand( @@ -63,7 +71,9 @@ def test_get_fields(self, mock_request, test_name, input_params, expected): ], ] ) - def test_get_fields_raise_api_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_get_fields_raise_api_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(ApiException) as error: self.action.run(input_params) self.assertEqual(error.exception.cause, cause) diff --git a/plugins/salesforce/unit_test/test_get_record.py b/plugins/salesforce/unit_test/test_get_record.py index 3648a26afa..e237d1a12a 100644 --- a/plugins/salesforce/unit_test/test_get_record.py +++ b/plugins/salesforce/unit_test/test_get_record.py @@ -1,16 +1,21 @@ -import sys import os +import sys from insightconnect_plugin_runtime.exceptions import PluginException sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase +from unittest.mock import MagicMock, patch + +from jsonschema import validate from komand_salesforce.actions.get_record import GetRecord -from util import Util -from unittest.mock import patch +from komand_salesforce.actions.get_record.schema import GetRecordOutput from parameterized import parameterized +from util import Util + @patch("requests.request", side_effect=Util.mock_request) class TestGetRecord(TestCase): @@ -28,8 +33,11 @@ def setUpClass(cls, mock_request) -> None: ] ] ) - def test_get_record(self, mock_request, test_name, input_params, expected): + def test_get_record( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: Dict[str, Any] + ) -> None: actual = self.action.run(input_params) + validate(actual, GetRecordOutput.schema) self.assertEqual(actual, expected) @parameterized.expand( @@ -42,7 +50,9 @@ def test_get_record(self, mock_request, test_name, input_params, expected): ] ] ) - def test_get_record_raise_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_get_record_raise_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(PluginException) as error: self.action.run(input_params) self.assertEqual(error.exception.cause, cause) diff --git a/plugins/salesforce/unit_test/test_monitor_users.py b/plugins/salesforce/unit_test/test_monitor_users.py index cf6c0f6a61..d507c4c7ab 100644 --- a/plugins/salesforce/unit_test/test_monitor_users.py +++ b/plugins/salesforce/unit_test/test_monitor_users.py @@ -1,13 +1,18 @@ -import sys import os +import sys sys.path.append(os.path.abspath("../")) +from datetime import datetime, timezone +from typing import Any, Dict from unittest import TestCase +from unittest.mock import MagicMock, patch + +from jsonschema import validate +from komand_salesforce.tasks.monitor_users.schema import MonitorUsersOutput from komand_salesforce.tasks.monitor_users.task import MonitorUsers -from unittest.mock import patch from parameterized import parameterized -from datetime import datetime, timezone + from util import Util @@ -57,8 +62,16 @@ def setUpClass(cls) -> None: ], ] ) - def test_monitor_users(self, mock_request, mock_get_time, test_name, current_state, expected): + def test_monitor_users( + self, + mock_request: MagicMock, + mock_get_time: MagicMock, + test_name: str, + current_state: Dict[str, Any], + expected: Dict[str, Any], + ) -> None: actual, actual_state, has_more_pages, status_code, error = self.action.run(state=current_state) + validate(actual, MonitorUsersOutput.schema) self.assertEqual(actual, expected.get("users")) self.assertEqual(actual_state, expected.get("state")) self.assertEqual(has_more_pages, expected.get("has_more_pages")) diff --git a/plugins/salesforce/unit_test/test_simple_search.py b/plugins/salesforce/unit_test/test_simple_search.py index 5ccf3308bd..7f3da642ea 100644 --- a/plugins/salesforce/unit_test/test_simple_search.py +++ b/plugins/salesforce/unit_test/test_simple_search.py @@ -1,16 +1,21 @@ -import sys import os +import sys from insightconnect_plugin_runtime.exceptions import PluginException sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase +from unittest.mock import MagicMock, patch + +from jsonschema import validate from komand_salesforce.actions.simple_search import SimpleSearch -from util import Util -from unittest.mock import patch +from komand_salesforce.actions.simple_search.schema import SimpleSearchOutput from parameterized import parameterized +from util import Util + @patch("requests.request", side_effect=Util.mock_request) class TestSimpleSearch(TestCase): @@ -28,8 +33,11 @@ def setUpClass(cls, mock_req) -> None: ] ] ) - def test_simple_search(self, mock_request, test_name, input_params, expected): + def test_simple_search( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: Dict[str, Any] + ) -> None: actual = self.action.run(input_params) + validate(actual, SimpleSearchOutput.schema) self.assertEqual(actual, expected) @parameterized.expand( @@ -42,7 +50,9 @@ def test_simple_search(self, mock_request, test_name, input_params, expected): ] ] ) - def test_simple_search_raise_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_simple_search_raise_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(PluginException) as error: self.action.run(input_params) self.assertEqual(error.exception.cause, cause) diff --git a/plugins/salesforce/unit_test/test_update_record.py b/plugins/salesforce/unit_test/test_update_record.py index b5f64b8600..44227cd6e3 100644 --- a/plugins/salesforce/unit_test/test_update_record.py +++ b/plugins/salesforce/unit_test/test_update_record.py @@ -1,14 +1,19 @@ -import sys import os +import sys sys.path.append(os.path.abspath("../")) +from typing import Any, Dict from unittest import TestCase -from komand_salesforce.actions.update_record.action import UpdateRecord -from unittest.mock import patch -from parameterized import parameterized +from unittest.mock import MagicMock, patch + from insightconnect_plugin_runtime.exceptions import PluginException +from jsonschema import validate +from komand_salesforce.actions.update_record.action import UpdateRecord +from komand_salesforce.actions.update_record.schema import UpdateRecordOutput from komand_salesforce.util.exceptions import ApiException +from parameterized import parameterized + from util import Util @@ -27,8 +32,11 @@ def setUpClass(cls) -> None: ], ] ) - def test_update_record(self, mock_request, test_name, input_params, expected): + def test_update_record( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], expected: Dict[str, Any] + ) -> None: actual = self.action.run(input_params) + validate(actual, UpdateRecordOutput.schema) self.assertEqual(actual, expected) @parameterized.expand( @@ -53,7 +61,9 @@ def test_update_record(self, mock_request, test_name, input_params, expected): ], ] ) - def test_update_record_raise_api_exception(self, mock_request, test_name, input_params, cause, assistance): + def test_update_record_raise_api_exception( + self, mock_request: MagicMock, test_name: str, input_params: Dict[str, Any], cause: str, assistance: str + ) -> None: with self.assertRaises(ApiException) as error: self.action.run(input_params) self.assertEqual(error.exception.cause, cause) diff --git a/plugins/salesforce/unit_test/util.py b/plugins/salesforce/unit_test/util.py index f77b20e55e..e52acfa050 100644 --- a/plugins/salesforce/unit_test/util.py +++ b/plugins/salesforce/unit_test/util.py @@ -1,7 +1,7 @@ import json import logging -import sys import os +import sys sys.path.append(os.path.abspath("../"))