Exemplo n.º 1
0
def main():
    endpoint = "reverse_proxy/location"
    key_to_check_for_changes = [
        "access_control", "allowed_networks", "auth_profile", "backend",
        "be_path", "comment", "denied_networks", "hot_standby", "path",
        "status", "stickysession_id", "stickysession_status",
        "websocket_passthrough"
    ]
    module = UTMModule(argument_spec=dict(
        name=dict(type='str', required=True),
        access_control=dict(
            type='str', required=False, default="0", choices=['0', '1']),
        allowed_networks=dict(type='list',
                              elements='str',
                              required=False,
                              default=['REF_NetworkAny']),
        auth_profile=dict(type='str', required=False, default=""),
        backend=dict(type='list', elements='str', required=False, default=[]),
        be_path=dict(type='str', required=False, default=""),
        comment=dict(type='str', required=False, default=""),
        denied_networks=dict(
            type='list', elements='str', required=False, default=[]),
        hot_standby=dict(type='bool', required=False, default=False),
        path=dict(type='str', required=False, default="/"),
        status=dict(type='bool', required=False, default=True),
        stickysession_id=dict(type='str', required=False, default='ROUTEID'),
        stickysession_status=dict(type='bool', required=False, default=False),
        websocket_passthrough=dict(type='bool', required=False, default=False),
    ))
    try:
        UTM(module, endpoint, key_to_check_for_changes).execute()
    except Exception as e:
        module.fail_json(msg=to_native(e))
Exemplo n.º 2
0
def main():
    endpoint = "aaa/group"
    key_to_check_for_changes = ["comment", "adirectory_groups", "adirectory_groups_sids", "backend_match", "dynamic",
                                "edirectory_groups", "ipsec_dn", "ldap_attribute", "ldap_attribute_value", "members",
                                "network", "radius_groups", "tacacs_groups"]
    module = UTMModule(
        argument_spec=dict(
            name=dict(type='str', required=True),
            adirectory_groups=dict(type='list', elements='str', required=False, default=[]),
            adirectory_groups_sids=dict(type='dict', required=False, default={}),
            backend_match=dict(type='str', required=False, default="none",
                               choices=["none", "adirectory", "edirectory", "radius", "tacacs", "ldap"]),
            comment=dict(type='str', required=False, default=""),
            dynamic=dict(type='str', required=False, default="none", choices=["none", "ipsec_dn", "directory_groups"]),
            edirectory_groups=dict(type='list', elements='str', required=False, default=[]),
            ipsec_dn=dict(type='str', required=False, default=""),
            ldap_attribute=dict(type='str', required=False, default=""),
            ldap_attribute_value=dict(type='str', required=False, default=""),
            members=dict(type='list', elements='str', required=False, default=[]),
            network=dict(type='str', required=False, default=""),
            radius_groups=dict(type='list', elements='str', required=False, default=[]),
            tacacs_groups=dict(type='list', elements='str', required=False, default=[]),
        )
    )
    try:
        UTM(module, endpoint, key_to_check_for_changes).execute()
    except Exception as e:
        module.fail_json(msg=to_native(e))
Exemplo n.º 3
0
def test_combine_headers_returns_only_default2():
    expected = {"Accept": "application/json", "Content-type": "application/json"}
    module = FakeModule(
        params={'utm_protocol': 'utm_protocol', 'utm_host': 'utm_host', 'utm_port': 1234, 'utm_token': 'utm_token',
                'name': 'FakeName'})
    result = UTM(module, "endpoint", [])._combine_headers()
    assert result == expected
Exemplo n.º 4
0
def main():
    endpoint = "reverse_proxy/exception"
    key_to_check_for_changes = [
        "op", "path", "skip_custom_threats_filters",
        "skip_threats_filter_categories", "skipav", "comment",
        "skipbadclients", "skipcookie", "skipform", "status",
        "skipform_missingtoken", "skiphtmlrewrite", "skiptft", "skipurl",
        "source"
    ]
    module = UTMModule(argument_spec=dict(
        name=dict(type='str', required=True),
        op=dict(
            type='str', required=False, default='AND', choices=['AND', 'OR']),
        path=dict(type='list', elements='string', required=False, default=[]),
        skip_custom_threats_filters=dict(
            type='list', elements='string', required=False, default=[]),
        skip_threats_filter_categories=dict(
            type='list', elements='string', required=False, default=[]),
        skipav=dict(type='bool', required=False, default=False),
        skipbadclients=dict(type='bool', required=False, default=False),
        skipcookie=dict(type='bool', required=False, default=False),
        skipform=dict(type='bool', required=False, default=False),
        skipform_missingtoken=dict(type='bool', required=False, default=False),
        skiphtmlrewrite=dict(type='bool', required=False, default=False),
        skiptft=dict(type='bool', required=False, default=False),
        skipurl=dict(type='bool', required=False, default=False),
        source=dict(type='list', elements='string', required=False,
                    default=[]),
        status=dict(type='bool', required=False, default=True),
    ))
    try:
        UTM(module, endpoint, key_to_check_for_changes).execute()
    except Exception as e:
        module.fail_json(msg=to_native(e))
Exemplo n.º 5
0
def main():
    endpoint = "network/interface_address"
    key_to_check_for_changes = []
    module = UTMModule(argument_spec=dict(
        name=dict(type='str', required=True)))
    try:
        UTM(module, endpoint, key_to_check_for_changes,
            info_only=True).execute()
    except Exception as e:
        module.fail_json(msg=to_native(e))
Exemplo n.º 6
0
def main():
    endpoint = "ca/host_key_cert"
    key_to_check_for_changes = []
    module = UTMModule(
        argument_spec=dict(
            name=dict(type='str', required=True)
        )
    )
    try:
        # This is needed because the bool value only accepts int values in the backend
        UTM(module, endpoint, key_to_check_for_changes, info_only=True).execute()
    except Exception as e:
        module.fail_json(msg=to_native(e))
Exemplo n.º 7
0
def main():
    endpoint = "reverse_proxy/frontend"
    key_to_check_for_changes = [
        "add_content_type_header", "address", "allowed_networks",
        "certificate", "comment", "disable_compression", "domain",
        "exceptions", "htmlrewrite", "htmlrewrite_cookies", "implicitredirect",
        "lbmethod", "locations", "port", "preservehost", "profile", "status",
        "type", "xheaders"
    ]
    module = UTMModule(argument_spec=dict(
        name=dict(type='str', required=True),
        add_content_type_header=dict(
            type='bool', required=False, default=False),
        address=dict(
            type='str', required=False, default="REF_DefaultInternalAddress"),
        allowed_networks=dict(type='list',
                              elements='str',
                              required=False,
                              default=["REF_NetworkAny"]),
        certificate=dict(type='str', required=False, default=""),
        comment=dict(type='str', required=False, default=""),
        disable_compression=dict(type='bool', required=False, default=False),
        domain=dict(type='list', elements='str', required=False),
        exceptions=dict(
            type='list', elements='str', required=False, default=[]),
        htmlrewrite=dict(type='bool', required=False, default=False),
        htmlrewrite_cookies=dict(type='bool', required=False, default=False),
        implicitredirect=dict(type='bool', required=False, default=False),
        lbmethod=dict(type='str',
                      required=False,
                      default="bybusyness",
                      choices=['bybusyness', 'bytraffic', 'byrequests', '']),
        locations=dict(type='list', elements='str', required=False,
                       default=[]),
        port=dict(type='int', required=False, default=80),
        preservehost=dict(type='bool', required=False, default=False),
        profile=dict(type='str', required=False, default=""),
        status=dict(type='bool', required=False, default=True),
        type=dict(type='str',
                  required=False,
                  default="http",
                  choices=['http', 'https']),
        xheaders=dict(type='bool', required=False, default=False),
    ))
    try:
        UTM(module, endpoint, key_to_check_for_changes).execute()
    except Exception as e:
        module.fail_json(msg=to_native(e))
Exemplo n.º 8
0
def main():
    endpoint = "ca/host_key_cert"
    key_to_check_for_changes = [
        "ca", "certificate", "comment", "encrypted", "key", "meta"
    ]
    module = UTMModule(argument_spec=dict(
        name=dict(type='str', required=True),
        ca=dict(type='str', required=True),
        meta=dict(type='str', required=True),
        certificate=dict(type='str', required=True),
        comment=dict(type='str', required=False),
        encrypted=dict(type='bool', required=False, default=False),
        key=dict(type='str', required=False, no_log=True),
    ))
    try:
        # This is needed because the bool value only accepts int values in the backend
        UTM(module, endpoint, key_to_check_for_changes).execute()
    except Exception as e:
        module.fail_json(msg=to_native(e))
Exemplo n.º 9
0
def main():
    endpoint = "network/dns_host"
    key_to_check_for_changes = ["comment", "hostname", "interface"]
    module = UTMModule(
        argument_spec=dict(
            name=dict(type='str', required=True),
            address=dict(type='str', required=False, default='0.0.0.0'),
            address6=dict(type='str', required=False, default='::'),
            comment=dict(type='str', required=False, default=""),
            hostname=dict(type='str', required=False),
            interface=dict(type='str', required=False, default=""),
            resolved=dict(type='bool', required=False, default=False),
            resolved6=dict(type='bool', required=False, default=False),
            timeout=dict(type='int', required=False, default=0),
        )
    )
    try:
        UTM(module, endpoint, key_to_check_for_changes).execute()
    except Exception as e:
        module.fail_json(msg=to_native(e))