CyrenCountryLookup

Translates a country code provided by Cyren products to a full country name (English). Uses ISO 3166-1 alpha-2 for the lookup.

python · Cyren Threat InDepth Threat Intelligence

Details

IDCyrenCountryLookup
Languagepython
From Version6.0.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagstransformer

README

This script will translate a country code provided by Cyren Threat InDepth to the full country name, based on ISO 3166-1 as defined in pycountry.

Script Data


Name Description
Script Type python3
Tags transformer
XSOAR Version 6.0.0

Inputs


Argument Name Description
value the country code provided by Cyren Threat InDepth

Outputs


The full country name in the English language.

import pytest


@pytest.mark.parametrize(
    "value, expected",
    [
        ("DE", "Germany"),
        ("de", "Germany"),
        ("De", "Germany"),
        ("ZZ", "ZZ"),
        ("Zz", "Zz"),
    ],
)
def test_lookup(value, expected):
    """
    Given: Different arg input
    When: Running lookup command.
    Then: either the correct country name will be returned or the code itself if no match
    """
    from CyrenCountryLookup import lookup

    assert lookup({"value": value}) == expected


@pytest.mark.parametrize(
    "args",
    [
        {},
        {"value": None},
        {"value": ""},
        {"value": 9},
        {"value": []},
    ],
)
def test_lookup_error(args):
    """
    Given: Different arg input
    When: Running lookup command on invalid values
    Then: will raise an exception
    """
    from CyrenCountryLookup import lookup

    with pytest.raises(Exception):
        lookup(args)