Пример #1
0
def test_remediate_asset_command__invalid_action(client, requests_mock):
    """
     Configures mocker instance, requests_mock.
        Given:
            - Command arguments: Asset ID and invalid remediation action.
        When:
            - Remediating an asset.
        Then:
            - Raises a DemistoException.
    """
    from SaasSecurity import remediate_asset_command

    requests_mock.post('http://base_url/remediation/api/assets')
    remediate_asset_command(client, {
        'asset_id': '4',
        'remediation_type': 'Invalid remediation'
    })
Пример #2
0
def test_remediate_asset_command(client, requests_mock):
    """
     Using the client mocker, requests_mock.
        Given:
            - Command arguments: Asset ID and remediation action.
        When:
            - Remediating an asset.
        Then:
            - Sends request with the expected query params and creates a CommandResult object.
    """

    from SaasSecurity import remediate_asset_command

    req_mocker = requests_mock.post('http://base_url/remediation/api/assets')
    result = remediate_asset_command(
        client, {
            'asset_id': '4',
            'remediation_type': 'Remove public sharing'
        })

    assert 'remove_public_sharing' in req_mocker.last_request.text
    assert result.outputs.get('asset_id') == '4'
    assert result.outputs.get('remediation_type') == 'remove_public_sharing'
    assert result.outputs.get('status') == 'pending'