kytos-ng / kytos-end-to-end-tests

Kytos End-to-End Tests
0 stars 10 forks source link

Patching Evc's backup_path attribute returns an unrelated response code #80

Closed ArturoQuintana closed 3 years ago

ArturoQuintana commented 3 years ago

The action to update a new circuit through a patch API call using an inconsistent backup_path information returns an invalid response given the nature of the process. In this case, we have identified that this execution is returning 200, and it should be 400, given the nature of the method.

def test_120_patch_an_inconsistent_backup_path(self):
        api_url = KYTOS_API + '/mef_eline/v2/evc/'
        payload1 = {
            "name": "my evc1",
            "enabled": True,
            "uni_a": {
                "interface_id": "00:00:00:00:00:00:00:01:1",
            },
            "uni_z": {
                "interface_id": "00:00:00:00:00:00:00:02:1"
            },
            "primary_path": [
                {"endpoint_a": {"id": "00:00:00:00:00:00:00:01:4"},
                 "endpoint_b": {"id": "00:00:00:00:00:00:00:03:3"}},
                {"endpoint_a": {"id": "00:00:00:00:00:00:00:03:2"},
                 "endpoint_b": {"id": "00:00:00:00:00:00:00:02:3"}}
            ],
            "backup_path": [
                {"endpoint_a": {"id": "00:00:00:00:00:00:00:01:3"},
                 "endpoint_b": {"id": "00:00:00:00:00:00:00:02:2"}}
            ]
        }
        response = requests.post(api_url, data=json.dumps(payload1),
                                 headers={'Content-type': 'application/json'})
        data = response.json()
        evc1 = data['circuit_id']

        payload2 = {
            "backup_path": [
                {"endpoint_a": {"id": "00:00:00:00:00:00:00:01:1"},
                 "endpoint_b": {"id": "00:00:00:00:00:00:00:02:1"}}
            ]
        }

        # It sets a new circuit's primary_path
        response = requests.patch(api_url + evc1, data=json.dumps(payload2),
                                  headers={'Content-type': 'application/json'})
        assert response.status_code == 400
        time.sleep(10)

        # It verifies EVC's data
        response = requests.get(api_url + evc1)
        data = response.json()

        paths = []
        for _path in data['backup_path']:
            paths.append({"endpoint_a": {"id": _path['endpoint_a']['id']},
                          "endpoint_b": {"id": _path['endpoint_b']['id']}})

        assert paths == payload1["backup_path"]
        assert data['active'] is True

Something similar is happening if the attribute backup_path specifies unrelated path information. See example:

def test_125_patch_an_unrelated_backup_path(self):
        api_url = KYTOS_API + '/mef_eline/v2/evc/'
        payload1 = {
            "name": "my evc1",
            "enabled": True,
            "uni_a": {
                "interface_id": "00:00:00:00:00:00:00:01:1",
            },
            "uni_z": {
                "interface_id": "00:00:00:00:00:00:00:02:1"
            },
            "primary_path": [
                {"endpoint_a": {"id": "00:00:00:00:00:00:00:01:4"},
                 "endpoint_b": {"id": "00:00:00:00:00:00:00:03:3"}},
                {"endpoint_a": {"id": "00:00:00:00:00:00:00:03:2"},
                 "endpoint_b": {"id": "00:00:00:00:00:00:00:02:3"}}
            ],
            "backup_path": [
                {"endpoint_a": {"id": "00:00:00:00:00:00:00:01:3"},
                 "endpoint_b": {"id": "00:00:00:00:00:00:00:02:2"}}
            ]
        }
        response = requests.post(api_url, data=json.dumps(payload1),
                                 headers={'Content-type': 'application/json'})
        data = response.json()
        evc1 = data['circuit_id']

        payload2 = {
            "backup_path": [
                {"endpoint_a": {"id": "00:00:00:00:00:00:00:01:4"},
                 "endpoint_b": {"id": "00:00:00:00:00:00:00:03:3"}}
            ]
        }

        # It sets a new circuit's primary_path
        response = requests.patch(api_url + evc1, data=json.dumps(payload2),
                                  headers={'Content-type': 'application/json'})
        assert response.status_code == 400
        time.sleep(10)

        # It verifies EVC's data
        response = requests.get(api_url + evc1)
        data = response.json()

        paths = []
        for _path in data['backup_path']:
            paths.append({"endpoint_a": {"id": _path['endpoint_a']['id']},
                          "endpoint_b": {"id": _path['endpoint_b']['id']}})

        assert paths == payload1["backup_path"]
        assert data['active'] is True

Source

ArturoQuintana commented 3 years ago

Transferred to mef_eline https://github.com/kytos-ng/mef_eline/issues/42