Skip to content

Commit e67948d

Browse files
authored
VED-000 Resolve new Sonar issues (#1078)
1 parent 6431e2c commit e67948d

File tree

6 files changed

+24
-17
lines changed

6 files changed

+24
-17
lines changed

.github/workflows/create-release-tag.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ jobs:
2929
run: pip install semver
3030

3131
- name: Set SPEC_VERSION env var
32-
run: echo ::set-env name=SPEC_VERSION::$(python utilities/scripts/calculate_version.py)
33-
env:
34-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
32+
run: echo "SPEC_VERSION::$(python utilities/scripts/calculate_version.py)" >> $GITHUB_ENV
3533

3634
- name: Create release (master only)
3735
id: create-release

.github/workflows/deploy-backend.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ env: # Sonarcloud - do not allow direct usage of untrusted data
4848
ENVIRONMENT: ${{ inputs.environment }}
4949
SUB_ENVIRONMENT: ${{ inputs.sub_environment }}
5050

51-
permissions:
52-
id-token: write
53-
contents: read
54-
5551
run-name: Deploy Backend - ${{ inputs.environment }} ${{ inputs.sub_environment }}
5652

5753
jobs:
5854
terraform-plan:
55+
permissions:
56+
id-token: write
57+
contents: read
5958
runs-on: ubuntu-latest
6059
environment:
6160
name: ${{ inputs.environment }}
@@ -89,6 +88,9 @@ jobs:
8988
path: infrastructure/instance/tfplan
9089

9190
terraform-apply:
91+
permissions:
92+
id-token: write
93+
contents: read
9294
needs: terraform-plan
9395
runs-on: ubuntu-latest
9496
environment:

.github/workflows/run-e2e-tests.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,10 @@ env:
5454
STATUS_API_KEY: ${{ secrets.STATUS_API_KEY }}
5555
SOURCE_COMMIT_ID: ${{ github.sha }}
5656

57-
permissions:
58-
id-token: write
59-
contents: read
60-
6157
jobs:
6258
wait-for-deployment:
59+
permissions:
60+
contents: read
6361
runs-on: ubuntu-latest
6462
environment: ${{ inputs.apigee_environment }}
6563
outputs:
@@ -109,6 +107,9 @@ jobs:
109107
fi
110108
111109
e2e-tests:
110+
permissions:
111+
id-token: write
112+
contents: read
112113
runs-on: ubuntu-latest
113114
needs: [wait-for-deployment]
114115
environment: ${{ inputs.apigee_environment }}
@@ -202,6 +203,9 @@ jobs:
202203
run: poetry run python -m unittest
203204

204205
batch-e2e-tests:
206+
permissions:
207+
id-token: write
208+
contents: read
205209
needs: [wait-for-deployment, e2e-tests]
206210
# Only actually depend on wait-for-deployment, but run after e2e-tests
207211
if: ${{ !cancelled() && needs.wait-for-deployment.result == 'success' && needs.wait-for-deployment.outputs.RUN_BATCH_E2E_TESTS == 'true' }}

lambdas/backend/src/controller/parameter_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def parse_search_params(search_params_in_req: dict[str, list[str]]) -> dict[str,
166166
"""Ensures the search params provided in the event do not contain duplicated keys. Will split the parameters
167167
provided by comma separators. Raises a ParameterExceptionError for duplicated keys. Existing business logic stipulated
168168
that the API only accepts comma separated values rather than multi-value."""
169-
if any([len(values) > 1 for _, values in search_params_in_req.items()]):
169+
if any(len(values) > 1 for _, values in search_params_in_req.items()):
170170
raise ParameterExceptionError(DUPLICATED_PARAMETERS_ERROR_MESSAGE)
171171

172172
parsed_params = {}

lambdas/shared/src/common/models/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def to_operation_outcome(self) -> dict:
6767

6868
class ApiValidationError(RuntimeError):
6969
def to_operation_outcome(self) -> dict:
70-
pass
70+
raise NotImplementedError("Improper usage: base class")
7171

7272

7373
@dataclass

lambdas/shared/tests/test_common/test_errors.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,14 @@ def test_errors_unhandled_response_error(self):
129129
self.assertEqual(issue.get("diagnostics"), f"{test_message}\n{test_response}")
130130

131131
def test_errors_api_validation_error(self):
132-
"""Test correct operation of ApiValidationError"""
133-
with self.assertRaises(errors.ApiValidationError) as context:
132+
"""Test base ApiValidationError class cannot be used"""
133+
with self.assertRaises(errors.ApiValidationError) as initial_error:
134134
raise errors.ApiValidationError()
135-
outcome = context.exception.to_operation_outcome()
136-
self.assertIsNone(outcome)
135+
136+
with self.assertRaises(NotImplementedError) as not_implemented_error:
137+
initial_error.exception.to_operation_outcome()
138+
139+
self.assertEqual(str(not_implemented_error.exception), "Improper usage: base class")
137140

138141
def test_errors_custom_validation_error(self):
139142
"""Test correct operation of CustomValidationError"""

0 commit comments

Comments
 (0)