kytos-ng / mef_eline

Kytos NApp to create and manage point-to-point L2 circuits
https://kytos-ng.github.io/api/mef_eline.html
MIT License
0 stars 9 forks source link

Patching Evc's uni_a or uni_z attributes returns an unrelated response code #58

Open italovalcy opened 3 years ago

italovalcy commented 3 years ago

The action to update a new circuit through a patch API call using an inconsistent uni_a or uni_z 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 40x, given the nature of the method.

See examples:

=================================== FAILURES ===================================
_____________ TestE2EMefEline.test_030_patch_an_inconsistent_uni_a _____________

self = <tests.test_e2e_13_mef_eline.TestE2EMefEline instance at 0x7f8376556f38>

   def test_030_patch_an_inconsistent_uni_a(self):
       """ Valid switch, valid Interface ID, but invalid tag_type (invalid value) """

       api_url = KYTOS_API + '/mef_eline/v2/evc/'
       evc1 = self.create_evc(100)

       payload = {
           "uni_a": {
               "interface_id": "00:00:00:00:00:00:00:01:1",
               "tag": {
                   "tag_type": 2,
                   "value": 101
               }
           }
       }

       # It tries to setting up a new uni_a
       response = requests.patch(api_url + evc1, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
     assert response.status_code == 400
E       assert 200 == 400
E        +  where 200 = <Response [200]>.status_code

tests/test_e2e_13_mef_eline.py:178: AssertionError
_____________ TestE2EMefEline.test_035_patch_an_inconsistent_uni_a _____________

self = <tests.test_e2e_13_mef_eline.TestE2EMefEline instance at 0x7f83768a8440>

   def test_035_patch_an_inconsistent_uni_a(self):
       """ Valid switch, valid Interface ID, valid tag_type, but invalid tag """

       api_url = KYTOS_API + '/mef_eline/v2/evc/'
       evc1 = self.create_evc(100)

       payload = {
           "uni_a": {
               "interface_id": "00:00:00:00:00:00:00:01:1",
               "tag": {
                   "tag_type": 1,
                   "value": -1
               }
           }
       }

       # It tries to setting up a new uni_a
       response = requests.patch(api_url + evc1, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
     assert response.status_code == 400
E       assert 200 == 400
E        +  where 200 = <Response [200]>.status_code

tests/test_e2e_13_mef_eline.py:199: AssertionError
_____________ TestE2EMefEline.test_040_patch_an_inconsistent_uni_a _____________

self = <tests.test_e2e_13_mef_eline.TestE2EMefEline instance at 0x7f83766b6b48>

   def test_040_patch_an_inconsistent_uni_a(self):
       """ Valid switch, valid Interface ID, valid tag_type, but invalid tag """

       api_url = KYTOS_API + '/mef_eline/v2/evc/'
       evc1 = self.create_evc(100)

       payload = {
           "uni_a": {
               "interface_id": "00:00:00:00:00:00:00:01:1",
               "tag": {
                   "tag_type": 1,
                   "value": "bla"
               }
           }
       }

       # It tries to setting up a new uni_a
       response = requests.patch(api_url + evc1, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
     assert response.status_code == 400
E       assert 200 == 400
E        +  where 200 = <Response [200]>.status_code

tests/test_e2e_13_mef_eline.py:220: AssertionError
_____________ TestE2EMefEline.test_045_patch_an_inconsistent_uni_a _____________

self = <tests.test_e2e_13_mef_eline.TestE2EMefEline instance at 0x7f83769e4e18>

   def test_045_patch_an_inconsistent_uni_a(self):
       """ Valid switch, valid Interface ID, valid tag_type, but invalid tag """

       api_url = KYTOS_API + '/mef_eline/v2/evc/'
       evc1 = self.create_evc(100)

       payload = {
           "uni_a": {
               "interface_id": "00:00:00:00:00:00:00:01:1",
               "tag": {
                   "tag_type": 1,
                   "value": 99999
               }
           }
       }

       # It tries to setting up a new uni_a
       response = requests.patch(api_url + evc1, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
     assert response.status_code == 400
E       assert 200 == 400
E        +  where 200 = <Response [200]>.status_code

tests/test_e2e_13_mef_eline.py:241: AssertionError
_____________ TestE2EMefEline.test_080_patch_an_inconsistent_uni_z _____________

self = <tests.test_e2e_13_mef_eline.TestE2EMefEline instance at 0x7f83765585f0>

   def test_080_patch_an_inconsistent_uni_z(self):
       """ Valid switch, valid Interface ID, but invalid tag_type (invalid value) """

       api_url = KYTOS_API + '/mef_eline/v2/evc/'
       evc1 = self.create_evc(100)

       payload = {
           "uni_z": {
               "interface_id": "00:00:00:00:00:00:00:01:1",
               "tag": {
                   "tag_type": 2,
                   "value": 101
               }
           }
       }

       # It tries to setting up a new uni_z
       response = requests.patch(api_url + evc1, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
     assert response.status_code == 400
E       assert 200 == 400
E        +  where 200 = <Response [200]>.status_code

tests/test_e2e_13_mef_eline.py:356: AssertionError
_____________ TestE2EMefEline.test_085_patch_an_inconsistent_uni_z _____________

self = <tests.test_e2e_13_mef_eline.TestE2EMefEline instance at 0x7f83769dec20>

   def test_085_patch_an_inconsistent_uni_z(self):
       """ Valid switch, valid Interface ID, valid tag_type, but invalid tag """

       api_url = KYTOS_API + '/mef_eline/v2/evc/'
       evc1 = self.create_evc(100)

       payload = {
           "uni_z": {
               "interface_id": "00:00:00:00:00:00:00:01:1",
               "tag": {
                   "tag_type": 1,
                   "value": -1
               }
           }
       }

       # It tries to setting up a new uni_z
       response = requests.patch(api_url + evc1, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
     assert response.status_code == 400
E       assert 200 == 400
E        +  where 200 = <Response [200]>.status_code

tests/test_e2e_13_mef_eline.py:377: AssertionError
_____________ TestE2EMefEline.test_090_patch_an_inconsistent_uni_z _____________

self = <tests.test_e2e_13_mef_eline.TestE2EMefEline instance at 0x7f837687ab48>

   def test_090_patch_an_inconsistent_uni_z(self):
       """ Valid switch, valid Interface ID, valid tag_type, but invalid tag """

       api_url = KYTOS_API + '/mef_eline/v2/evc/'
       evc1 = self.create_evc(100)

       payload = {
           "uni_z": {
               "interface_id": "00:00:00:00:00:00:00:01:1",
               "tag": {
                   "tag_type": 1,
                   "value": "bla"
               }
           }
       }

       # It tries to setting up a new uni_z
       response = requests.patch(api_url + evc1, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
     assert response.status_code == 400
E       assert 200 == 400
E        +  where 200 = <Response [200]>.status_code

tests/test_e2e_13_mef_eline.py:398: AssertionError
_____________ TestE2EMefEline.test_095_patch_an_inconsistent_uni_z _____________

self = <tests.test_e2e_13_mef_eline.TestE2EMefEline instance at 0x7f8376649878>

   def test_095_patch_an_inconsistent_uni_z(self):
       """ Valid switch, valid Interface ID, valid tag_type, but invalid tag """

       api_url = KYTOS_API + '/mef_eline/v2/evc/'
       evc1 = self.create_evc(100)

       payload = {
           "uni_z": {
               "interface_id": "00:00:00:00:00:00:00:01:1",
               "tag": {
                   "tag_type": 1,
                   "value": 99999
               }
           }
       }

       # It tries to setting up a new uni_z
       response = requests.patch(api_url + evc1, data=json.dumps(payload),
                                 headers={'Content-type': 'application/json'})
     assert response.status_code == 400
E       assert 200 == 400
E        +  where 200 = <Response [200]>.status_code

tests/test_e2e_13_mef_eline.py:419: AssertionError

Source

viniarck commented 1 year ago

Part of the issues have been fixed since mef_eline now has enhanced its OpenAPI validation, but still some values can cause issues as they've been marked on e2e tests. I'll go ahead and set this for version 2023.2 considering that it won't be able to make it on 2023.1.