Skip to content

Commit

Permalink
Merge pull request #65 from AirWalk-Digital/fix/framework-endpoint-tr…
Browse files Browse the repository at this point in the history
…ailing-slashes

feat: trailing slashes in framework endpoints
  • Loading branch information
afdezl authored Jul 4, 2023
2 parents 956e6ab + ee7405a commit 4f3a5df
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions app/airview_api/controllers/frameworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def post(self, data):
abort(400, message=str(e))


@blp.route("/<int:framework_id>")
@blp.route("/<int:framework_id>/")
class Framework(MethodView):
@blp.response(200, FrameworkSchema)
@blp.role(Roles.CONTENT_READER)
Expand All @@ -54,7 +54,7 @@ def get(self, framework_id):
return data


@blp.route("/<int:framework_id>/sections")
@blp.route("/<int:framework_id>/sections/")
class FrameworkSection(MethodView):
@blp.response(200, FrameworkSectionSchema(many=True))
@blp.role(Roles.CONTENT_READER)
Expand All @@ -76,7 +76,7 @@ def post(self, data, framework_id):
abort(400, message=str(e))


@blp.route("/<int:framework_id>/sections/<int:section_id>/control_objectives")
@blp.route("/<int:framework_id>/sections/<int:section_id>/control_objectives/")
class FrameworkControlObjective(MethodView):
@blp.response(200, FrameworkControlObjectiveSchema(many=True))
@blp.role(Roles.CONTENT_READER)
Expand Down
8 changes: 4 additions & 4 deletions app/client/airviewclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def create_framework(self, framework: Framework) -> Optional[Framework]:
def get_framework_section(self, framework_section: FrameworkSection, framework_id: int) -> Optional[FrameworkSection]:
resp = self._session.get(
url=self.get_url(
f"/frameworks/{framework_id}/sections?name={framework_section.name}"
f"/frameworks/{framework_id}/sections/?name={framework_section.name}"
),
headers=self._headers
)
Expand All @@ -455,7 +455,7 @@ def get_framework_section(self, framework_section: FrameworkSection, framework_i
def create_framework_section(self, framework_section: FrameworkSection, framework_id: int) -> Optional[FrameworkSection]:
resp = self._session.post(
url=self.get_url(
f"/frameworks/{framework_id}/sections"
f"/frameworks/{framework_id}/sections/"
),
json={
"name": framework_section.name,
Expand All @@ -474,7 +474,7 @@ def create_framework_section(self, framework_section: FrameworkSection, framewor
def get_framework_control_objective(self, framework_control_objective: FrameworkControlObjective, framework_section_id: int, framework_id: int) -> Optional[FrameworkControlObjective]:
resp = self._session.get(
url=self.get_url(
f"/frameworks/{framework_id}/sections/{framework_section_id}/control_objectives?name={framework_control_objective.name}"
f"/frameworks/{framework_id}/sections/{framework_section_id}/control_objectives/?name={framework_control_objective.name}"
),
headers=self._headers
)
Expand All @@ -492,7 +492,7 @@ def get_framework_control_objective(self, framework_control_objective: Framework
def create_framework_control_objective(self, framework_control_objective: FrameworkControlObjective, framework_section_id: int, framework_id: int) -> Optional[FrameworkControlObjective]:
resp = self._session.post(
url=self.get_url(
f"/frameworks/{framework_id}/sections/{framework_section_id}/control_objectives"
f"/frameworks/{framework_id}/sections/{framework_section_id}/control_objectives/"
),
json={
"name": framework_control_objective.name,
Expand Down
16 changes: 8 additions & 8 deletions app/tests/api_tests/test_frameworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_framework_sections_post_ok(client):

# Act
resp = client.post(
"/frameworks/1/sections",
"/frameworks/1/sections/",
json={
"name": "Access Control",
"link": "/nisttest/access_control",
Expand Down Expand Up @@ -217,7 +217,7 @@ def test_framework_sections_get_ok(client):

# Act
resp = client.get(
"/frameworks/1/sections",
"/frameworks/1/sections/",
)
data = resp.get_json()
# Assert
Expand Down Expand Up @@ -265,7 +265,7 @@ def test_framework_sections_get_by_name(client):

# Act
resp = client.get(
"/frameworks/1/sections?name=Logging",
"/frameworks/1/sections/?name=Logging",
)
data = resp.get_json()
# Assert
Expand Down Expand Up @@ -314,7 +314,7 @@ def test_framework_sections_get_missing_by_name(client):

# Act
resp = client.get(
"/frameworks/1/sections?name=Monitoring",
"/frameworks/1/sections/?name=Monitoring",
)
data = resp.get_json()
# Assert
Expand Down Expand Up @@ -346,7 +346,7 @@ def test_framework_control_objective_post_ok(client):

# Act
resp = client.post(
"/frameworks/1/sections/1/control_objectives",
"/frameworks/1/sections/1/control_objectives/",
json={
"name": "Ensure 2FA is enabled",
"link": "/nisttest/access_control/ensure_2fa_is_enabled",
Expand Down Expand Up @@ -430,7 +430,7 @@ def test_framework_control_objective_get_ok(client):

# Act
resp = client.get(
"/frameworks/2/sections/3/control_objectives",
"/frameworks/2/sections/3/control_objectives/",
)
data = resp.get_json()
# Assert
Expand Down Expand Up @@ -500,7 +500,7 @@ def test_framework_control_objective_get_by_name(client):

# Act
resp = client.get(
"/frameworks/2/sections/1/control_objectives?name=Users password must be at least 20 characters long",
"/frameworks/2/sections/1/control_objectives/?name=Users password must be at least 20 characters long",
)
data = resp.get_json()
# Assert
Expand Down Expand Up @@ -567,7 +567,7 @@ def test_framework_control_objective_get_missing_by_name(client):

# Act
resp = client.get(
"/frameworks/2/sections/1/control_objectives?name=Users password must be at least 20 characters long",
"/frameworks/2/sections/1/control_objectives/?name=Users password must be at least 20 characters long",
)
data = resp.get_json()
# Assert
Expand Down
14 changes: 7 additions & 7 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@
"x-api-rbac-role": "ContentWriter"
}
},
"/frameworks/{framework_id}": {
"/frameworks/{framework_id}/": {
"get": {
"responses": {
"200": {
Expand Down Expand Up @@ -1148,7 +1148,7 @@
}
]
},
"/frameworks/{framework_id}/sections": {
"/frameworks/{framework_id}/sections/": {
"get": {
"responses": {
"200": {
Expand Down Expand Up @@ -1219,7 +1219,7 @@
"x-api-rbac-role": "ContentWriter"
}
},
"/frameworks/{framework_id}/sections/{section_id}/control_objectives": {
"/frameworks/{framework_id}/sections/{section_id}/control_objectives/": {
"get": {
"responses": {
"200": {
Expand Down Expand Up @@ -1304,15 +1304,15 @@
"parameters": [
{
"in": "query",
"name": "resourceId",
"name": "technicalControlId",
"required": true,
"schema": {
"type": "integer"
}
},
{
"in": "query",
"name": "technicalControlId",
"name": "resourceId",
"required": true,
"schema": {
"type": "integer"
Expand Down Expand Up @@ -1352,15 +1352,15 @@
"parameters": [
{
"in": "query",
"name": "type",
"name": "reference",
"required": false,
"schema": {
"type": "string"
}
},
{
"in": "query",
"name": "reference",
"name": "type",
"required": false,
"schema": {
"type": "string"
Expand Down

0 comments on commit 4f3a5df

Please sign in to comment.