Beispiel #1
0
def test_create_api_invalid_contact(api_gateway: FlaskClient, auth_header, execdb):
    """Assert that various invalid contact info are rejected"""

    inputs = [
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app:1.0.0
            contact_info: not an object
            description: An invalid App API with non-object contact info
            actions:
              - name: test_action
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app2:1.0.0
            contact_info: 
              name: good
              bad: not good
            description: An invalid App API with extra field in contact
            actions:
              - name: test_action
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app3:1.0.0
            contact_info: 
              name: name
              email: not a valid email
            description: An invalid App API with invalid email in contact
            actions:
              - name: test_action
            """,
        },
        # URL format from connexion/jsonschema does not seem to actually validate anything
        # """
        #     walkoff_version: 1.0.0
        #     app_version: 1.0.0
        #     name: test_app:1.0.0
        #     contact_info:
        #       name: name
        #       url: http://not a valid url
        #     description: An invalid App API with invalid URL in contact
        #     actions:
        #       - name: test_action
        # """
    ]
    assert_crud_resource(api_gateway, auth_header, apps_api_url, inputs, yaml.full_load, valid=False)
Beispiel #2
0
def test_create_api_minimum(api_gateway: FlaskClient, auth_header, execdb):
    """Assert that a minimum valid API is accepted"""

    inputs = [
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app:1.0.0
            description: A minimum valid App API
            actions:
              - name: test_action
            """
        }
    ]
    assert_crud_resource(api_gateway, auth_header, apps_api_url, inputs, yaml.full_load)
Beispiel #3
0
def test_create_api_invalid_semver(api_gateway: FlaskClient, auth_header, execdb):
    """Assert that walkoff_version, app_version, name all have correct sematic versioning"""

    inputs = [
        {
            "create": """
            walkoff_version: "1.0"
            app_version: 1.0.0
            name: test_app:1.0.0
            description: An invalid App API with bad semantic versioning in walkoff_version
            actions:
              - name: test_action
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: "1.0"
            name: test_app2:1.0.0
            description: An invalid App API with bad semantic versioning in app_version
            actions:
              - name: test_action
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app3:1.0
            description: An invalid App API with bad semantic versioning in name
            actions:
              - name: test_action
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app4:1.0.1
            description: An invalid App API with mismatched semantic versioning in name and app_version
            actions:
              - name: test_action
            """
        }
    ]
    assert_crud_resource(api_gateway, auth_header, apps_api_url, inputs, yaml.full_load, valid=False)
Beispiel #4
0
def test_create_api_valid_contact(api_gateway: FlaskClient, auth_header, execdb):
    """Assert that valid contact info is accepted"""

    inputs = [
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app:1.0.0
            contact_info:
              name: name
              url: example.com
              email: [email protected]
            description: An invalid App API with non-object contact info
            actions:
              - name: test_action
            """,
        },
    ]
    assert_crud_resource(api_gateway, auth_header, apps_api_url, inputs, yaml.full_load)
def test_workflow_with_global(api_gateway, auth_header, execdb):
    with open("apps/basics/1.0.0/api.yaml") as f:
        r = {"create": f.read()}
    assert_crud_resource(api_gateway, auth_header, "/api/apps/apis", [r],
                         yaml.full_load)

    inputs = [
        {
            "create":
            """
            {
                "actions": [
                    {
                        "app_name": "hello_world:1.0.0",
                        "app_version": "1.0.0",
                        "id_": "703dc24c-5d83-9001-5e54-aabfbe401e64",
                        "label": "hello_world",
                        "name": "hello_world",
                        "position": {
                            "x": 0,
                            "y": 0
                        }
                    }
                ],
                "description": "A minimal hello world workflow",
                "name": "Test",
                "start": "703dc24c-5d83-9001-5e54-aabfbe401e64"
            }
            """,
        },
    ]
    assert_crud_resource(api_gateway,
                         auth_header,
                         workflows_url,
                         inputs,
                         json.loads,
                         delete=True)
Beispiel #6
0
def test_create_api_invalid_parameters(api_gateway: FlaskClient, auth_header, execdb):
    """Assert that invalid parameters are rejected"""
    inputs = [
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app:1.0.0
            description: An invalid App API with bad schema type
            actions:
              - name: test_action
                parameters: 
                  - name: param1
                    description: A parameter description
                    placeholder: A placeholder
                    schema: 
                      type: notatype
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app2:1.0.0
            description: An invalid App API with missing parameter name
            actions:
              - name: test_action
                parameters: 
                  - description: A parameter description
                    placeholder: A placeholder
                    schema: 
                      type: notatype
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app3:1.0.0
            description: A valid App API with minimum parameter info
            actions:
              - name: test_action
                parameters: 
                  - name: param1
                    description: A parameter description
                    placeholder: A placeholder
                    schema: 
                      type: object
                      properties:
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app4:1.0.0
            description: A valid App API with minimum parameter info
            actions:
              - name: test_action
                parameters: 
                  - name: param1
                    description: A parameter description
                    placeholder: A placeholder
                    schema: 
                      type: notatype
            """,
        },
    ]
    assert_crud_resource(api_gateway, auth_header, apps_api_url, inputs, yaml.full_load, valid=False)
Beispiel #7
0
def test_create_api_valid_parameters(api_gateway: FlaskClient, auth_header, execdb):
    """Assert that valid parameters are accepted"""
    inputs = [
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app:1.0.0
            description: A valid App API with minimum parameter info
            actions:
              - name: test_action
                parameters: 
                  - name: param1
                    schema: 
                      type: string
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app2:1.0.0
            description: A valid App API with all fields and required 
            actions:
              - name: test_action
                parameters: 
                  - name: param1
                    description: A parameter description
                    placeholder: 42
                    required: true
                    schema: 
                      type: number
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app3:1.0.0
            description: A valid App API with all fields and required set to false (default)
            actions:
              - name: test_action
                parameters: 
                  - name: param1
                    description: A parameter description
                    placeholder: A placeholder
                    required: false
                    schema: 
                      type: boolean
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app4:1.0.0
            description: A valid App API with object schema
            actions:
              - name: test_action
                parameters: 
                  - name: param1
                    description: A parameter description
                    placeholder: A placeholder
                    required: false
                    schema: 
                      type: object
                      required: [name, id]
                      properties:
                        name:
                          type: string
                        id:
                          type: number
            """,
        },
        {
            "create": """
            walkoff_version: 1.0.0
            app_version: 1.0.0
            name: test_app5:1.0.0
            description: A valid App API with object schema in multiple params
            actions:
              - name: test_action
                parameters: 
                  - name: param1
                    description: A parameter description
                    placeholder: A placeholder
                    required: false
                    schema: 
                      type: object
                      required: [name, id]
                      properties:
                        name:
                          type: string
                        id:
                          type: number
              - name: test_action2
                parameters: 
                  - name: param2
                    description: A parameter description
                    placeholder: A placeholder
                    required: false
                    schema: 
                      type: object
                      required: [name, id]
                      properties:
                        name:
                          type: string
                        id:
                          type: number
        """,
        },
    ]
    assert_crud_resource(api_gateway, auth_header, apps_api_url, inputs, yaml.full_load)
Beispiel #8
0
def test_create_global_no_template(api_gateway: FlaskClient, auth_header, execdb):
    """Assert that creating a global without a template is accepted"""
    inputs = [
        {
            "create": """
            {
                "name": "string",
                "value": "bar",
                "description": "string global variable"
            }
            """,
        },
        {
            "create": """
            {
                "name": "number",
                "value": 1234,
                "description": "number global variable"
            }
            """,
        },
        {
            "create": """
            {
                "name": "number2",
                "value": 1234.5678,
                "description": "float global variable"
            }
            """,
        },
        {
            "create": """
            {
                "name": "object", 
                "value": {
                    "string": "bar",
                    "number": 1234,
                    "number2": 1234.567,
                    "object": {
                        "string": "bar",
                        "number": 1234,
                        "number2": 1234.567,
                        "object": {
                            "string": "bar",
                            "number": 1234,
                            "number2": 1234.567
                        },
                        "array": [
                            "bar",
                            1234,
                            1234.567
                        ],
                        "boolean": true,
                        "boolean2": false
                    },
                    "array": [
                        "bar",
                        1234,
                        1234.567
                    ],
                    "boolean": true,
                    "boolean2": false
                },
                "description": "Nested JSON global"
            }
            """,
        },
        {
            "create": """
            {
                "name": "array",
                "value": [
                    "bar",
                    "1234",
                    "1234.567"
                ],
                "description": "array global variable"
            }
            """,
        },
        {
            "create": """
            {
                "name": "boolean",
                "value": true,
                "description": "boolean global variable"
            }
            """,
        },
        {
            "create": """
            {
                "name": "boolean2",
                "value": false,
                "description": "boolean global variable"
            }
            """,
        }
    ]
    assert_crud_resource(api_gateway, auth_header, globals_url, inputs, json.loads)