diff --git a/networkapi/api_neighbor/models.py b/networkapi/api_neighbor/models.py index d498498c..cf85a476 100644 --- a/networkapi/api_neighbor/models.py +++ b/networkapi/api_neighbor/models.py @@ -325,7 +325,7 @@ def validate_neighbor_v4(self, user): self.check_if_local_ip_vrf_is_the_same_as_remote_ip_vrf() self.check_if_local_ip_and_local_asn_shares_at_least_one_equipment() self.check_if_remote_ip_and_remote_asn_shares_at_least_one_equipment() - # self.check_if_peer_group_environments_has_local_ip_environment() + self.check_if_peer_group_environments_has_local_ip_environment() self.check_if_neighbor_is_not_duplicated() def check_if_neighbor_already_deployed(self): @@ -673,7 +673,7 @@ def validate_neighbor_v6(self, user): self.check_if_local_ip_vrf_is_the_same_as_remote_ip_vrf() self.check_if_local_ip_and_local_asn_shares_at_least_one_equipment() self.check_if_remote_ip_and_remote_asn_shares_at_least_one_equipment() - # self.check_if_peer_group_environments_has_local_ip_environment() + self.check_if_peer_group_environments_has_local_ip_environment() self.check_if_neighbor_is_not_duplicated() def check_if_neighbor_already_deployed(self): diff --git a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_environment_peer_group.json b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_environment_peer_group.json index badf3760..da6aa6c8 100644 --- a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_environment_peer_group.json +++ b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_environment_peer_group.json @@ -14,5 +14,13 @@ }, "model": "api_peer_group.EnvironmentPeerGroup", "pk": 2 + }, + { + "fields": { + "environment": 1, + "peer_group": 4 + }, + "model": "api_peer_group.EnvironmentPeerGroup", + "pk": 2 } ] diff --git a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_ipv6.json b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_ipv6.json index 6589e3ae..61d2a926 100644 --- a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_ipv6.json +++ b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_ipv6.json @@ -129,7 +129,7 @@ "block6": "0000", "block7": "0000", "block8": "0003", - "networkipv6": 2 + "networkipv6": 5 }, "model": "ip.ipv6", "pk": 9 diff --git a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_networkipv6.json b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_networkipv6.json index f1e0ae56..7ec3500e 100644 --- a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_networkipv6.json +++ b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_networkipv6.json @@ -117,5 +117,33 @@ }, "model": "ip.networkipv6", "pk": 4 + }, + { + "fields": { + "active": true, + "ambient_vip": null, + "block": "64", + "block1": "fc00", + "block2": "0000", + "block3": "0000", + "block4": "0004", + "block5": "0000", + "block6": "0000", + "block7": "0000", + "block8": "0000", + "cluster_unit": "cluster-unit-1", + "mask1": "ffff", + "mask2": "ffff", + "mask3": "ffff", + "mask4": "ffff", + "mask5": "0000", + "mask6": "0000", + "mask7": "0000", + "mask8": "0000", + "network_type": 1, + "vlan": 5 + }, + "model": "ip.networkipv6", + "pk": 5 } ] diff --git a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_peer_group.json b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_peer_group.json index ca0392e3..2c20a13f 100644 --- a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_peer_group.json +++ b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_peer_group.json @@ -25,5 +25,14 @@ }, "model": "api_peer_group.PeerGroup", "pk": 3 + }, + { + "fields": { + "name": "peer_group_3", + "route_map_in": 5, + "route_map_out": 6 + }, + "model": "api_peer_group.PeerGroup", + "pk": 4 } ] diff --git a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_vlan.json b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_vlan.json index 2d6e3f93..1d5bf530 100644 --- a/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_vlan.json +++ b/networkapi/api_neighbor/v4/fixtures/neighbor_v6/initial_vlan.json @@ -34,5 +34,14 @@ }, "model": "vlan.vlan", "pk": 4 + }, + { + "fields": { + "ambiente": 2, + "nome": "VLAN 5 of env 2", + "num_vlan": 5 + }, + "model": "vlan.vlan", + "pk": 5 } ] diff --git a/networkapi/api_neighbor/v4/tests/neighbor_v4/sanity/sync/test_post.py b/networkapi/api_neighbor/v4/tests/neighbor_v4/sanity/sync/test_post.py index d02f3a88..ec16bef2 100644 --- a/networkapi/api_neighbor/v4/tests/neighbor_v4/sanity/sync/test_post.py +++ b/networkapi/api_neighbor/v4/tests/neighbor_v4/sanity/sync/test_post.py @@ -203,26 +203,26 @@ def test_post_neighbor_v4_with_remotes_in_different_eqpts(self): response.data['detail'] ) - # def test_post_neighbor_v4_with_peer_group_envs_diff_local_ip_env(self): - # """Test POST NeighborV4 with different peer groups environments - # different than LocalIp Environment.""" - - # neighbor_v4_path = self.json_path. \ - # format('neighbor_v4_with_peer_group_envs_' - # 'diff_than_local_ip_env.json') - - # response = self.client.post( - # self.neighbor_v4_uri, - # data=self.load_json(neighbor_v4_path), - # content_type=self.content_type, - # HTTP_AUTHORIZATION=self.authorization) - - # self.compare_status(400, response.status_code) - # self.compare_values( - # u'LocalIp id = 1 and PeerGroup id = 3 ' - # u'belongs to different Environments', - # response.data['detail'] - # ) + def test_post_neighbor_v4_with_peer_group_envs_diff_local_ip_env(self): + """Test POST NeighborV4 with different peer groups environments + different than LocalIp Environment.""" + + neighbor_v4_path = self.json_path. \ + format('neighbor_v4_with_peer_group_envs_' + 'diff_than_local_ip_env.json') + + response = self.client.post( + self.neighbor_v4_uri, + data=self.load_json(neighbor_v4_path), + content_type=self.content_type, + HTTP_AUTHORIZATION=self.authorization) + + self.compare_status(400, response.status_code) + self.compare_values( + u'LocalIp id = 9 and PeerGroup id = 4 ' + u'belongs to different Environments', + response.data['detail'] + ) def test_post_neighbor_v4_duplicated(self): """Test POST duplicated NeighborV4.""" diff --git a/networkapi/api_neighbor/v4/tests/neighbor_v4/sanity/sync/test_put.py b/networkapi/api_neighbor/v4/tests/neighbor_v4/sanity/sync/test_put.py index 87e9a362..4950745f 100644 --- a/networkapi/api_neighbor/v4/tests/neighbor_v4/sanity/sync/test_put.py +++ b/networkapi/api_neighbor/v4/tests/neighbor_v4/sanity/sync/test_put.py @@ -219,26 +219,26 @@ def test_put_neighbor_v4_with_remotes_in_different_eqpts(self): response.data['detail'] ) - # def test_put_neighbor_v4_with_peer_group_envs_diff_local_ip_env(self): - # """Test PUT NeighborV4 with peer groups environments - # different than LocalIp Environment.""" - - # neighbor_v4_path = self.json_path. \ - # format('neighbor_v4_with_peer_group_envs_' - # 'diff_than_local_ip_env.json') - - # response = self.client.put( - # self.neighbor_v4_uri, - # data=self.load_json(neighbor_v4_path), - # content_type=self.content_type, - # HTTP_AUTHORIZATION=self.authorization) - - # self.compare_status(400, response.status_code) - # self.compare_values( - # u'LocalIp id = 1 and PeerGroup id = 3 ' - # u'belongs to different Environments', - # response.data['detail'] - # ) + def test_put_neighbor_v4_with_peer_group_envs_diff_local_ip_env(self): + """Test PUT NeighborV4 with peer groups environments + different than LocalIp Environment.""" + + neighbor_v4_path = self.json_path. \ + format('neighbor_v4_with_peer_group_envs_' + 'diff_than_local_ip_env.json') + + response = self.client.put( + self.neighbor_v4_uri, + data=self.load_json(neighbor_v4_path), + content_type=self.content_type, + HTTP_AUTHORIZATION=self.authorization) + + self.compare_status(400, response.status_code) + self.compare_values( + u'LocalIp id = 1 and PeerGroup id = 3 ' + u'belongs to different Environments', + response.data['detail'] + ) def test_put_neighbor_v4_duplicated(self): """Test PUT duplicated NeighborV4.""" diff --git a/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/json/put/neighbor_v6_with_peer_group_envs_diff_than_local_ip_env.json b/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/json/put/neighbor_v6_with_peer_group_envs_diff_than_local_ip_env.json index 4afe0f27..a623e81c 100644 --- a/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/json/put/neighbor_v6_with_peer_group_envs_diff_than_local_ip_env.json +++ b/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/json/put/neighbor_v6_with_peer_group_envs_diff_than_local_ip_env.json @@ -2,16 +2,22 @@ "neighbors": [ { "id": 1, - "local_asn": 1, - "local_ip": 1, + "local_asn": 7, + "local_ip": 9, "peer_group": 3, - "remote_asn": 2, - "remote_ip": 2, + "remote_asn": 1, + "remote_ip": 1, "virtual_interface": "test_vi", "next_hop_self": true, "community": true, "soft_reconfiguration": true, - "remove_private_as": true + "remove_private_as": true, + "kind": "1", + "description": "teste", + "password": "123", + "maximum_hops": "2", + "timer_keepalive": "12", + "timer_timeout": "128" } ] } diff --git a/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/sync/test_post.py b/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/sync/test_post.py index 010b3470..1967ff5d 100644 --- a/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/sync/test_post.py +++ b/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/sync/test_post.py @@ -202,26 +202,26 @@ def test_post_neighbor_v6_with_remotes_in_different_eqpts(self): response.data['detail'] ) - # def test_post_neighbor_v6_with_peer_group_envs_diff_local_ip_env(self): - # """Test POST NeighborV6 with peer groups environments - # different than LocalIp Environment.""" - - # neighbor_v6_path = self.json_path. \ - # format('neighbor_v6_with_peer_group_envs_' - # 'diff_than_local_ip_env.json') - - # response = self.client.post( - # self.neighbor_v6_uri, - # data=self.load_json(neighbor_v6_path), - # content_type=self.content_type, - # HTTP_AUTHORIZATION=self.authorization) - - # self.compare_status(400, response.status_code) - # self.compare_values( - # u'LocalIp id = 1 and PeerGroup id = 3 ' - # u'belongs to different Environments', - # response.data['detail'] - # ) + def test_post_neighbor_v6_with_peer_group_envs_diff_local_ip_env(self): + """Test POST NeighborV6 with peer groups environments + different than LocalIp Environment.""" + + neighbor_v6_path = self.json_path. \ + format('neighbor_v6_with_peer_group_envs_' + 'diff_than_local_ip_env.json') + + response = self.client.post( + self.neighbor_v6_uri, + data=self.load_json(neighbor_v6_path), + content_type=self.content_type, + HTTP_AUTHORIZATION=self.authorization) + + self.compare_status(400, response.status_code) + self.compare_values( + u'LocalIp id = 1 and PeerGroup id = 3 ' + u'belongs to different Environments', + response.data['detail'] + ) def test_post_neighbor_v6_duplicated(self): """Test POST duplicated NeighborV6.""" diff --git a/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/sync/test_put.py b/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/sync/test_put.py index d0d07989..ee1b4e22 100644 --- a/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/sync/test_put.py +++ b/networkapi/api_neighbor/v4/tests/neighbor_v6/sanity/sync/test_put.py @@ -220,26 +220,26 @@ def test_put_neighbor_v6_with_remotes_in_different_eqpts(self): response.data['detail'] ) - # def test_put_neighbor_v6_with_peer_group_envs_diff_local_ip_env(self): - # """Test PUT NeighborV6 with peer groups environments - # different than LocalIp Environment.""" - - # neighbor_v6_path = self.json_path. \ - # format('neighbor_v6_with_peer_group_envs_' - # 'diff_than_local_ip_env.json') - - # response = self.client.put( - # self.neighbor_v6_uri, - # data=self.load_json(neighbor_v6_path), - # content_type=self.content_type, - # HTTP_AUTHORIZATION=self.authorization) - - # self.compare_status(400, response.status_code) - # self.compare_values( - # u'LocalIp id = 1 and PeerGroup id = 3 ' - # u'belongs to different Environments', - # response.data['detail'] - # ) + def test_put_neighbor_v6_with_peer_group_envs_diff_local_ip_env(self): + """Test PUT NeighborV6 with peer groups environments + different than LocalIp Environment.""" + + neighbor_v6_path = self.json_path. \ + format('neighbor_v6_with_peer_group_envs_' + 'diff_than_local_ip_env.json') + + response = self.client.put( + self.neighbor_v6_uri, + data=self.load_json(neighbor_v6_path), + content_type=self.content_type, + HTTP_AUTHORIZATION=self.authorization) + + self.compare_status(400, response.status_code) + self.compare_values( + u'LocalIp id = 9 and PeerGroup id = 3 ' + u'belongs to different Environments', + response.data['detail'] + ) def test_put_neighbor_v6_duplicated(self): """Test PUT duplicated NeighborV6."""