Skip to content

Commit

Permalink
Merge branch 'main' into helm-tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
P0NDER0SA authored Jan 8, 2025
2 parents 1df1978 + 431c869 commit 1fb9d43
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 215 deletions.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ AWS_SECRET_ACCESS_KEY=

REDIS_ENABLED=False

MIXPANEL_PROJECT_TOKEN=<project_token>

ALLOW_DEBUG_ROUTE=False
DEBUG_KEY=
2 changes: 1 addition & 1 deletion .github/workflows/cypress-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ jobs:
- name: Notify Slack channel if this job failed
if: ${{ failure() }}
run: |
json="{'text':'<!here> Staging a11y tests failed: <https://github.com/cds-snc/notification-admin/actions/runs/${GITHUB_RUN_ID}|see failure details> !'}"
json='{"text":"<!here> Staging a11y tests failed: <https://github.com/cds-snc/notification-admin/actions/runs/${GITHUB_RUN_ID}|see failure details> !"}'
curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.SLACK_WEBHOOK }}
2 changes: 1 addition & 1 deletion .github/workflows/export_github_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
DNS_PROXY_FORWARDTOSENTINEL: "true"
DNS_PROXY_LOGANALYTICSWORKSPACEID: ${{ secrets.LOG_ANALYTICS_WORKSPACE_ID }}
DNS_PROXY_LOGANALYTICSSHAREDKEY: ${{ secrets.LOG_ANALYTICS_WORKSPACE_KEY }}
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Export Data
uses: cds-snc/github-repository-metadata-exporter@main
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ossf-scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@72803a12483ed6f4f7c34f804818169f50162e37
uses: ossf/scorecard-action@e48dbb732fab761267783321dfa71e2a5c6e263d
with:
results_file: ossf-results.json
results_format: json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/s3-backup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:

- name: Checkout
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0 # retrieve all history

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
- run: /bin/bash -c "scripts/bootstrap.sh && poetry run make test"
env:
A11Y_TRACKER_KEY: ${{ secrets.A11Y_TRACKER_KEY }}
MIXPANEL_PROJECT_TOKEN: <project_token>
- name: Notify Slack channel if this job failed in default branch
if: ${{ failure() && github.ref == 'refs/heads/main' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_endpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
echo "PYTHONPATH=/github/workspace/env/site-packages:${{ env.PYTHONPATH}}" >> $GITHUB_ENV
- name: Checks for new endpoints against AWS WAF rules
uses: cds-snc/notification-utils/.github/actions/[email protected].1
uses: cds-snc/notification-utils/.github/actions/[email protected].3
with:
app-loc: '/github/workspace'
app-libs: '/github/workspace/env/site-packages'
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test_prod_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
- run: /bin/bash -c "scripts/bootstrap.sh && poetry run make test"
env:
A11Y_TRACKER_KEY: ${{ secrets.A11Y_TRACKER_KEY }}
MIXPANEL_PROJECT_TOKEN: <project_token>
- name: Notify Slack channel if this job failed in default branch
if: ${{ failure() && github.ref == 'refs/heads/main' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion app/main/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def validate_callback_url(service_callback_url, bearer_token):
response = requests.post(
url=service_callback_url,
allow_redirects=True,
data={"health_check": "true"},
json={"health_check": True},
headers={"Content-Type": "application/json", "Authorization": f"Bearer {bearer_token}"},
timeout=2,
)
Expand Down
4 changes: 2 additions & 2 deletions app/main/views/api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def delete_delivery_status_callback(service_id):

form = ServiceDeliveryStatusCallbackForm(
url=delivery_status_callback.get("url") if delivery_status_callback else "",
bearer_token=dummy_bearer_token if delivery_status_callback else "",
bearer_token=delivery_status_callback.get("bearer") if delivery_status_callback else "",
)

return render_template(
Expand All @@ -216,7 +216,7 @@ def delivery_status_callback(service_id):

form = ServiceDeliveryStatusCallbackForm(
url=delivery_status_callback.get("url") if delivery_status_callback else "",
bearer_token=dummy_bearer_token if delivery_status_callback else "",
bearer_token=delivery_status_callback.get("bearer") if delivery_status_callback else "",
)

if form.validate_on_submit():
Expand Down
5 changes: 0 additions & 5 deletions app/main/views/authenticator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from flask import session

from app.models.user import User
from config.mixpanel import NotifyMixpanel


class Authenticator:
def __init__(self, user_id):
self.user = User.from_id(user_id)
self.mixpanel = NotifyMixpanel()

def __enter__(self) -> User:
# the user will have a new current_session_id set by the API - store it in the cookie for future requests
Expand All @@ -23,9 +21,6 @@ def __enter__(self) -> User:
return self.user

def __exit__(self, _exec_type, _exec_value, _traceback) -> None:
self.mixpanel.track_user_profile(self.user)
self.mixpanel.track_event(self.user, "Notify: Logged in")

# get rid of anything in the session that we don't expect to have been set during register/sign in flow
session.pop("user_details", None)
session.pop("file_uploads", None)
80 changes: 49 additions & 31 deletions app/templates/partials/jobs/status.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
{% from "components/table.html" import mapping_table, row, row_heading, text_field, link_field, with context %}

<div class="ajax-block-container">
<p class='mb-12 clear-both contain-floats'>

<div data-test-id="dr_header">
<div class="pb-4">
{{ _('Sent by:') }}
{% if job.api_key %}
{{ _("API key '<a href='{}'>{}</a>'").format(url_for('.api_keys', service_id=current_service.id), job.api_key.name) }}
{% else %}
{{ job.created_by.name }}
{% endif %}
</div>
<div class="pb-4">
{{ _('Started:') }}
<time class="local-datetime-short">{{ job.created_at }}</time>
</div>
<div class="pb-4">
{% if job.api_key %}
{{ _('API request name:')}}
{% else %}
{{ _('Spreadsheet:') }}
{% endif %}
{{ job.original_file_name }}
</div>
</div>


{% if template_type == "letter" %}
<p id="printing-info">
{{ letter_print_day }}
</p>
<div class="flex flex-wrap mb-8">
{% set caption = _("Scheduled messages") %}

{% call mapping_table(
caption=caption,
field_headings_visible=False,
caption_visible=False,
font_size='table-font-small',
) %}

{% call row() %}
{% call row_heading(cell_width="sm:w-1/3") %}
{{ _('Sent by') }}
{% endcall %}
{% if job.api_key %}
{{ text_field(_("API key '<a href='{}'>{}</a>'").format(url_for('.api_keys', service_id=current_service.id), job.api_key.name)) }}
{% else %}
{{ text_field(job.created_by.name) }}
{% endif %}
</p>
{% endcall %}

{% call row() %}
{% call row_heading(cell_width="sm:w-1/3") %}
{{ _('Started') }}
{% endcall %}
{{ text_field(text=job.created_at, date_format="local-datetime-short") }}
{% endcall %}

{% call row() %}
{% call row_heading(cell_width="sm:w-1/3") %}
{% if job.api_key %}
{{ _('API request name')}}
{% else %}
{{ _('Spreadsheet') }}
{% endif %}
{% endcall %}
{{ text_field(job.original_file_name) }}
{% endcall %}

{% call row() %}
{% call row_heading(cell_width="sm:w-1/3") %}
{{ _('Template') }}
{% endcall %}
{{ link_field(template.name, url_for('.view_template', service_id=job.service, template_id=template.id)) }}
{% endcall %}
{% endcall %}

</div>
</div>
1 change: 1 addition & 0 deletions app/translations/csv/fr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,7 @@
"Try creating {} in a different application","Essayez de créer {} dans une application différente."
"Sent by:","Envoyé par&nbsp;:"
"Started:","Début&nbsp;:"
"Started","Début"
"Spreadsheet:","Feuille de calcul&nbsp;:"
"API request name:","Nom de la requête API&nbsp;:"
"GC Notify disposed of the information in this report on <time class='local-datetime-short'>{}</time>","Notification GC a supprimé les renseignements de ce rapport le <time class='local-datetime-short'>{}</time>"
Expand Down
1 change: 0 additions & 1 deletion ci/cloudbuild-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ steps:
args: ["-c", "/workspace/scripts/bootstrap.sh && make test"]
env:
- 'CHROMEDRIVER_PATH=/usr/bin/chromedriver'
- 'MIXPANEL_PROJECT_TOKEN=<project_token>'
options:
machineType: 'N1_HIGHCPU_32'
45 changes: 0 additions & 45 deletions config/mixpanel.py

This file was deleted.

24 changes: 4 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ WTForms = "3.1.2"
email-validator = "1.3.1"
Werkzeug = "3.0.4"
greenlet = "3.1.1"
mixpanel = "4.10.1"
unidecode = "^1.3.8"

# PaaS
awscli-cwlogs = "^1.4.6"
notifications-utils = { git = "https://github.com/cds-snc/notifier-utils.git", tag = "53.0.1"}
notifications-utils = { git = "https://github.com/cds-snc/notifier-utils.git", tag = "53.0.3"}


# Pinned dependencies
Expand Down
24 changes: 13 additions & 11 deletions tests/app/main/views/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ def test_should_show_page_for_one_job(
)

assert page.h1.text.strip() == "Delivery report"
assert " ".join(page.find("tbody").find("tr").text.split()) == ("6502532222 template content No Delivered 11:10:00.061258")
dashboard_table = page.find_all("table")[1]
assert " ".join(dashboard_table.find("tbody").find("tr").text.split()) == (
"6502532222 template content No Delivered 11:10:00.061258"
)
assert page.find("div", {"data-key": "notifications"})["data-resource"] == url_for(
"main.view_job_updates",
service_id=SERVICE_ONE_ID,
Expand All @@ -204,10 +207,10 @@ def test_should_show_page_for_one_job(
assert csv_link.text == "Download this report"
assert page.find("time", {"id": "time-left"}).text.split(" ")[0] == "2016-01-09"

assert normalize_spaces(page.select_one("tbody tr").text) == normalize_spaces(
assert normalize_spaces(dashboard_table.select_one("tbody tr").text) == normalize_spaces(
"6502532222 " "template content " "No " "Delivered 11:10:00.061258"
)
assert page.select_one("tbody tr a")["href"] == url_for(
assert dashboard_table.select_one("tbody tr a")["href"] == url_for(
"main.view_notification",
service_id=SERVICE_ONE_ID,
notification_id=sample_uuid(),
Expand Down Expand Up @@ -434,15 +437,13 @@ def test_should_show_job_from_api(
service_id=SERVICE_ONE_ID,
job_id=fake_uuid,
)
job_info_table = page.find_all("table")[0]

assert (
normalize_spaces(page.select("div[data-test-id='dr_header'] >div:nth-child(1)")[0].text)
== f"Sent by: API key '{JOB_API_KEY_NAME}'"
)
assert (
normalize_spaces(page.select("div[data-test-id='dr_header'] >div:nth-child(2)")[0].text)
== "Started: 2016-01-01T00:00:00.061258+0000"
)
assert normalize_spaces(job_info_table.select("th")[0].text) == "Sent by"
assert normalize_spaces(job_info_table.select("td")[0].text) == f"API key '{JOB_API_KEY_NAME}'"

assert normalize_spaces(job_info_table.select("th")[1].text) == "Started"
assert normalize_spaces(job_info_table.select("td")[1].text) == "2016-01-01T00:00:00.061258+0000"


# TODO: This test could be migrated to Cypress instead
Expand Down Expand Up @@ -579,6 +580,7 @@ def test_should_not_show_cancel_link_for_letter_job_if_too_late(


@freeze_time("2019-06-20 15:32:00.000001")
@pytest.mark.skip(reason="feature not in use")
@pytest.mark.parametrize(" job_status", ["finished", "in progress"])
def test_should_show_cancel_link_for_letter_job(
client_request,
Expand Down
Loading

0 comments on commit 1fb9d43

Please sign in to comment.