Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payload with non serializable JSON data #17

Open
ajoaoff opened this issue Jun 7, 2021 · 1 comment
Open

Payload with non serializable JSON data #17

ajoaoff opened this issue Jun 7, 2021 · 1 comment

Comments

@ajoaoff
Copy link

ajoaoff commented Jun 7, 2021

Original issue opened by @ArturoQuintana at kytos#138.

Hi, @cmagnobarbosa.
Issue 132 seems to be closed by PR 137, and in there, we referenced problems with some payloads.
The application continues failing in the case in which a payload specifies non-serializable JSON data.

some tests:

def test_030_install_flow_should_fail(self):
        """Test if the flow installation process specifying a
        wrong datatype payload behaves as expected (400 Error)."""

        payload = {
            "flows": [
                {
                    "priority"
                }
            ]
        }

        api_url = KYTOS_API + '/flow_manager/v2/flows/00:00:00:00:00:00:00:01'
        response = requests.post(api_url, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
        assert response.status_code == 400
def test_055_install_flows_should_fail(self):
        """Test if the flow installation process specifying a
        wrong datatype payload behaves as expected (400 Error)."""

        payload = {
            "flows": [
                {
                    "priority"
                }
            ]
        }

        api_url = KYTOS_API + '/flow_manager/v2/flows'
        response = requests.post(api_url, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
        assert response.status_code == 400
 def test_080_delete_flow_should_fail(self):
        """Test if the flow deletion process specifying a
        wrong datatype payload behaves as expected (400 Error)."""

        payload = {
            "flows": [
                {
                    "priority"
                }
            ]
        }

        # delete the flow
        api_url = KYTOS_API + '/flow_manager/v2/flows/00:00:00:00:00:00:00:01'
        response = requests.delete(api_url, data=json.dumps(payload),
                                   headers={'Content-type': 'application/json'})
        assert response.status_code == 400
def test_100_delete_flows_should_fail(self):
        """Test if the flow deletion process specifying a
        wrong datatype payload behaves as expected (400 Error)."""

        payload = {
            "flows": [
                {
                    "priority"
                }
            ]
        }

        # delete the flow
        api_url = KYTOS_API + '/flow_manager/v2/flows'
        response = requests.delete(api_url, data=json.dumps(payload),
                                   headers={'Content-type': 'application/json'})
        assert response.status_code == 400
@ajoaoff
Copy link
Author

ajoaoff commented Jun 8, 2021

@ArturoQuintana , what is the answer you are receiving? Your payload is really non-serializable, but as you try to serialize it prior to make the request, json.dumps call raises TypeError, so the call to kytos is never made.
To test this, you should try to pass the payload without serializing it first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant