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

Add version to l2vpn #323

Merged
merged 6 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdx_controller/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

@app.route("/", methods=["GET"])
def index():
return redirect("/SDX-Controller/1.0.0/ui/")
return redirect("/SDX-Controller/ui/")


@atexit.register
Expand Down
6 changes: 3 additions & 3 deletions sdx_controller/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ externalDocs:
description: Find out more about Swagger
url: http://swagger.io
servers:
- url: https://virtserver.swaggerhub.com/SDX-Controller/1.0.0
- url: https://virtserver.swaggerhub.com/SDX-Controller/
description: SwaggerHub API Auto Mocking
- url: https://0.0.0.0:8080/v2
description: Localhost
Expand Down Expand Up @@ -133,7 +133,7 @@ paths:
"404":
description: Link not found
x-openapi-router-controller: sdx_controller.controllers.link_controller
/l2vpn:
/l2vpn/1.0:
get:
tags:
- l2vpn
Expand Down Expand Up @@ -178,7 +178,7 @@ paths:
"400":
description: Invalid Connection
x-openapi-router-controller: sdx_controller.controllers.l2vpn_controller
/l2vpn/{service_id}:
/l2vpn/1.0/{service_id}:
get:
tags:
- l2vpn
Expand Down
40 changes: 20 additions & 20 deletions sdx_controller/test/test_l2vpn_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from sdx_controller.models.l2vpn_body import L2vpnBody # noqa: E501
from sdx_controller.test import BaseTestCase, TestData

BASE_PATH = "/SDX-Controller/1.0.0"
BASE_PATH = "/SDX-Controller"


class TestL2vpnController(BaseTestCase):
Expand All @@ -28,7 +28,7 @@ def test_delete_connection_no_setup(self):
"""
connection_id = 2
response = self.client.open(
f"{BASE_PATH}/l2vpn/{connection_id}",
f"{BASE_PATH}/l2vpn/1.0/{connection_id}",
method="DELETE",
)
self.assert404(response, f"Response body is : {response.data.decode('utf-8')}")
Expand All @@ -53,15 +53,15 @@ def test_delete_connection_with_setup(self):
Test case for delete_connection()

Set up a connection request, get the connection ID from the
response, and then do `DELETE /l2vpn/:connection_id`
response, and then do `DELETE /l2vpn/1.0/:connection_id`
"""
# set up temanager connection first
self.__add_the_three_topologies()

request_body = TestData.CONNECTION_REQ.read_text()

connection_response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=request_body,
content_type="application/json",
Expand All @@ -75,7 +75,7 @@ def test_delete_connection_with_setup(self):
print(f"Deleting request_id: {connection_id}")

delete_response = self.client.open(
f"{BASE_PATH}/l2vpn/{connection_id}",
f"{BASE_PATH}/l2vpn/1.0/{connection_id}",
method="DELETE",
)

Expand All @@ -92,7 +92,7 @@ def test_getconnection_by_id(self):
"""
connection_id = 10
response = self.client.open(
f"{BASE_PATH}/l2vpn/{connection_id}",
f"{BASE_PATH}/l2vpn/1.0/{connection_id}",
method="GET",
)

Expand All @@ -110,7 +110,7 @@ def test_place_connection_no_topology(self):
body = Connection()

response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=json.dumps(body),
content_type="application/json",
Expand All @@ -131,7 +131,7 @@ def test_place_connection_v2_no_topology(self):
body = ConnectionV2()

response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=json.dumps(body),
content_type="application/json",
Expand All @@ -153,7 +153,7 @@ def __test_with_one_topology(self, topology_file):
request = TestData.CONNECTION_REQ.read_text()

response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=request,
content_type="application/json",
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_place_connection_no_id(self):
print(f"request: {request} {type(request)}")

response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=request,
content_type="application/json",
Expand Down Expand Up @@ -232,7 +232,7 @@ def test_place_connection_with_three_topologies(self):
request = TestData.CONNECTION_REQ.read_text()

response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=request,
content_type="application/json",
Expand Down Expand Up @@ -265,7 +265,7 @@ def test_place_connection_with_three_topologies_added_in_sequence(self):
request = TestData.CONNECTION_REQ.read_text()

response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=request,
content_type="application/json",
Expand Down Expand Up @@ -303,7 +303,7 @@ def test_place_connection_v2_with_three_topologies_400_response(self):
print(f"new_request: {new_request}")

response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=new_request,
content_type="application/json",
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_place_connection_v2_with_three_topologies_200_response(self):
print(f"new_request: {new_request}")

response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=new_request,
content_type="application/json",
Expand Down Expand Up @@ -378,7 +378,7 @@ def test_z100_getconnection_by_id_expect_404(self):
# Generate a random ID.
connection_id = uuid.uuid4()
response = self.client.open(
f"{BASE_PATH}/l2vpn/{connection_id}",
f"{BASE_PATH}/l2vpn/1.0/{connection_id}",
method="GET",
)

Expand All @@ -396,7 +396,7 @@ def test_z100_getconnection_by_id_expect_200(self):
request_body = TestData.CONNECTION_REQ.read_text()

post_response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="POST",
data=request_body,
content_type="application/json",
Expand All @@ -409,9 +409,9 @@ def test_z100_getconnection_by_id_expect_200(self):
connection_id = post_response.get_json().get("service_id")
print(f"Got connection_id: {connection_id}")

# Now try `GET /l2vpn/{connection_id}`
# Now try `GET /l2vpn/1.0/{connection_id}`
get_response = self.client.open(
f"{BASE_PATH}/l2vpn/{connection_id}",
f"{BASE_PATH}/l2vpn/1.0/{connection_id}",
method="GET",
)

Expand All @@ -424,15 +424,15 @@ def test_z105_getconnections_fail(self, mock_get_all_entries):
"""Test case for getconnections."""
mock_get_all_entries.return_value = {}
response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="GET",
)
self.assertStatus(response, 404)

def test_z105_getconnections_success(self):
"""Test case for getconnections."""
response = self.client.open(
f"{BASE_PATH}/l2vpn",
f"{BASE_PATH}/l2vpn/1.0",
method="GET",
)

Expand Down
2 changes: 1 addition & 1 deletion sdx_controller/test/test_link_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_get_link(self):

get an existing link
"""
response = self.client.open("/SDX-Controller/1.0.0/link", method="GET")
response = self.client.open("/SDX-Controller/link", method="GET")
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))


Expand Down
2 changes: 1 addition & 1 deletion sdx_controller/test/test_node_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_get_node(self):

get an existing node
"""
response = self.client.open("/SDX-Controller/1.0.0/node", method="GET")
response = self.client.open("/SDX-Controller/node", method="GET")
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))


Expand Down
6 changes: 3 additions & 3 deletions sdx_controller/test/test_topology_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_get_topology(self):

get an existing topology
"""
response = self.client.open("/SDX-Controller/1.0.0/topology", method="GET")
response = self.client.open("/SDX-Controller/topology", method="GET")
# There's nothing corresponding to `latest_topo` in DB at this
# point, so we get a 204 No Content response. We should
# probably get a 404 Not Found response though. See
Expand All @@ -27,7 +27,7 @@ def test_get_topologyby_version(self):
"""
query_string = [("topology_id", 789)]
response = self.client.open(
"/SDX-Controller/1.0.0/topology/{version}".format(version=789),
"/SDX-Controller/topology/{version}".format(version=789),
method="GET",
query_string=query_string,
)
Expand All @@ -41,7 +41,7 @@ def test_topology_version(self):
"""
query_string = [("topology_id", "test:topology:test_topology.net")]
response = self.client.open(
"/SDX-Controller/1.0.0/topology/version",
"/SDX-Controller/topology/version",
method="GET",
query_string=query_string,
)
Expand Down
16 changes: 8 additions & 8 deletions sdx_controller/test/test_user_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_create_user(self):
"""
body = User()
response = self.client.open(
"/SDX-Controller/1.0.0/user",
"/SDX-Controller/user",
method="POST",
data=json.dumps(body),
content_type="application/json",
Expand All @@ -32,7 +32,7 @@ def test_create_users_with_array_input(self):
"""
body = [User()]
response = self.client.open(
"/SDX-Controller/1.0.0/user/createWithArray",
"/SDX-Controller/user/createWithArray",
method="POST",
data=json.dumps(body),
content_type="application/json",
Expand All @@ -46,7 +46,7 @@ def test_create_users_with_list_input(self):
"""
body = [User()]
response = self.client.open(
"/SDX-Controller/1.0.0/user/createWithList",
"/SDX-Controller/user/createWithList",
method="POST",
data=json.dumps(body),
content_type="application/json",
Expand All @@ -59,7 +59,7 @@ def test_delete_user(self):
Delete user
"""
response = self.client.open(
"/SDX-Controller/1.0.0/user/{username}".format(username="username_example"),
"/SDX-Controller/user/{username}".format(username="username_example"),
method="DELETE",
)
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))
Expand All @@ -70,7 +70,7 @@ def test_get_user_by_name(self):
Get user by user name
"""
response = self.client.open(
"/SDX-Controller/1.0.0/user/{username}".format(username="username_example"),
"/SDX-Controller/user/{username}".format(username="username_example"),
method="GET",
)
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))
Expand All @@ -85,7 +85,7 @@ def test_login_user(self):
("password", "password_example"),
]
response = self.client.open(
"/SDX-Controller/1.0.0/user/login", method="GET", query_string=query_string
"/SDX-Controller/user/login", method="GET", query_string=query_string
)
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))

Expand All @@ -94,7 +94,7 @@ def test_logout_user(self):

Logs out current logged in user session
"""
response = self.client.open("/SDX-Controller/1.0.0/user/logout", method="GET")
response = self.client.open("/SDX-Controller/user/logout", method="GET")
self.assert200(response, "Response body is : " + response.data.decode("utf-8"))

def test_update_user(self):
Expand All @@ -104,7 +104,7 @@ def test_update_user(self):
"""
body = User()
response = self.client.open(
"/SDX-Controller/1.0.0/user/{username}".format(username="username_example"),
"/SDX-Controller/user/{username}".format(username="username_example"),
method="PUT",
data=json.dumps(body),
content_type="application/json",
Expand Down