Skip to content

Commit

Permalink
Release 2022.01.1 (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman authored Jan 18, 2022
2 parents 0d2d2cb + bf4500a commit 35a2007
Show file tree
Hide file tree
Showing 38 changed files with 262 additions and 90 deletions.
1 change: 1 addition & 0 deletions .devcontainer/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CONFIG_FILE=??_*.json
# Django config
DJANGO_ADMIN=false
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,[::1]
DJANGO_TRUSTED_ORIGINS=http://localhost,http://127.0.0.1
DJANGO_DB=django
DJANGO_DEBUG=true
DJANGO_INIT_PATH=fixtures/??_*.json
Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- ANALYTICS_KEY
- DJANGO_ADMIN
- DJANGO_ALLOWED_HOSTS
- DJANGO_TRUSTED_ORIGINS
- DJANGO_DB
- DJANGO_DEBUG
- DJANGO_INIT_PATH
Expand All @@ -29,6 +30,7 @@ services:
- CYPRESS_baseUrl
- DJANGO_ADMIN
- DJANGO_ALLOWED_HOSTS
- DJANGO_TRUSTED_ORIGINS
- DJANGO_DB
- DJANGO_DEBUG
- DJANGO_INIT_PATH
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/postAttach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ pre-commit install --install-hooks --overwrite
pre-commit install --hook-type commit-msg

# install cypress
cd tests/e2e && npm install && npx cypress install
cd tests/cypress && npm install && npx cypress install
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ updates:
labels:
- "dependencies"
- package-ecosystem: "npm"
directory: "/tests/e2e" # e2e Cypress testing
directory: "/tests/cypress" # Cypress testing
schedule:
interval: "daily"
commit-message:
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/check-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Check access to API

on:
workflow_dispatch:
inputs:
environment:
type: choice
description: Select the API environment
options: [all, prod, qa]
schedule:
- cron: "0 12 * * *"

jobs:
check-api:
runs-on: ubuntu-latest
env:
SHOULD_RUN: |
${{ github.event_name == 'schedule'
|| github.event.inputs.environment == 'all'
|| github.event.inputs.environment == matrix.name
}}
strategy:
fail-fast: false
matrix:
include:
- name: prod
cert: API_CHECK_PROD_CERT
key: API_CHECK_PROD_KEY
ca-cert: API_CHECK_PROD_CA_CERT
url: API_CHECK_PROD_URL
data: API_CHECK_PROD_DATA

- name: qa
cert: API_CHECK_QA_CERT
key: API_CHECK_QA_KEY
ca-cert: API_CHECK_QA_CA_CERT
url: API_CHECK_QA_URL
data: API_CHECK_QA_DATA

name: Check API endpoint (${{ matrix.name }})
steps:
- name: Echo workflow run information
run: |
echo "Triggering event name: ${{ github.event_name }}, \
APIs to check: ${{ github.event.inputs.environment }}"
- name: Decode cert files
if: contains(env.SHOULD_RUN, 'true')
run: |
mkdir $RUNNER_TEMP/${{ matrix.name }}
temp_dir=$RUNNER_TEMP/${{ matrix.name }}
cat > $temp_dir/cert.pem <<- EOM
${{ secrets[matrix.cert] }}
EOM
cat > $temp_dir/key.pem <<- EOM
${{ secrets[matrix.key] }}
EOM
cat > $temp_dir/cacert.ca <<- EOM
${{ secrets[matrix.ca-cert] }}
EOM
- name: Call API endpoint
if: contains(env.SHOULD_RUN, 'true')
run: |
temp_dir=$RUNNER_TEMP/${{ matrix.name }}
curl -i --url ${{ secrets[matrix.url] }} \
--header 'Accept: application/json' \
--header 'Content-type: application/json' \
--data '${{ secrets[matrix.data] }}' \
--cert $temp_dir/cert.pem \
--key $temp_dir/key.pem \
--cacert $temp_dir/cacert.ca > $temp_dir/payload.txt
test $(head -n 1 $temp_dir/payload.txt | grep -o 201)
4 changes: 1 addition & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Pre-commit checks

on:
push:
branches: [prod, test, dev]
pull_request:
branches: [prod, test, dev]
branches: "*"

jobs:
pre-commit:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: |
docker run \
--detach \
--env-file tests/e2e/.env.tests \
--env-file tests/cypress/.env.tests \
-p 8000:8000 \
-v ${{ github.workspace }}/fixtures:/home/calitp/app/fixtures \
benefits_client:${{ github.sha }}
Expand All @@ -46,10 +46,10 @@ jobs:
env:
CYPRESS_baseUrl: http://localhost:8000
with:
working-directory: tests/e2e
working-directory: tests/cypress
wait-on: http://localhost:8000/healthcheck
spec: |
cypress/specs/ui/*.spec.js
specs/ui/*.spec.js
- name: Run Lighthouse tests for a11y
uses: treosh/lighthouse-ci-action@v8
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v1
rev: v1.2.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand Down
2 changes: 1 addition & 1 deletion benefits/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "0.0.1"
__version__ = "2022.01.1"

VERSION = __version__
6 changes: 4 additions & 2 deletions benefits/core/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ def __init__(self, request, event_type, **kwargs):
self.__dict__.update(kwargs)

agency = session.agency(request)
self.update_event_properties(path=request.path, provider_name=agency.long_name if agency else None)
name = agency.long_name if agency else None

self.update_event_properties(path=request.path, provider_name=name)

uagent = request.headers.get("user-agent")

ref = request.headers.get("referer")
match = Event._domain_re.match(ref) if ref else None
refdom = match.group(1) if match else None

self.update_user_properties(referrer=ref, referring_domain=refdom, user_agent=uagent)
self.update_user_properties(referrer=ref, referring_domain=refdom, user_agent=uagent, provider_name=name)

# event is initialized, consume next counter
self.event_id = next(Event._counter)
Expand Down
5 changes: 4 additions & 1 deletion benefits/core/templates/core/payment-options.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<li>{% translate "core.payments.option.debitcard" %}</li>
</ul>
<p>{% translate "core.payments.p4" %}</p>
<p>{% translate "core.payments.p5" %}</p>
<p>{% translate "core.payments.p5" %}
<a rel="noreferrer" target="_blank" href="https://cash.app/help/us/en-us/14425-cal-transit">Cash App Visa Debit Card</a>
{% translate "core.payments.or" %}
<a rel="noreferrer" target="_blank" href="https://venmo.com/about/debitcard/">Venmo Mastercard Debit Card</a>.</p>
<p>{% translate "core.payments.p6" %}</p>
{% endblock %}
2 changes: 1 addition & 1 deletion benefits/core/viewmodels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
The core application: view model definitions for the root of the webapp.
"""
from django.utils.translation import pgettext, ugettext as _
from django.utils.translation import pgettext, gettext as _

from benefits.core import models

Expand Down
2 changes: 1 addition & 1 deletion benefits/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.template import loader
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.translation import pgettext, ugettext as _
from django.utils.translation import pgettext, gettext as _

from . import middleware, models, session, viewmodels

Expand Down
9 changes: 7 additions & 2 deletions benefits/eligibility/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,13 @@ def _request(self, sub, name):
except requests.HTTPError as e:
raise ApiError(e)

logger.debug("Process eligiblity verification response")
return self._tokenize_response(r)
expected_status_codes = {200, 400}
if r.status_code in expected_status_codes:
logger.debug("Process eligiblity verification response")
return self._tokenize_response(r)
else:
logger.warning(f"Unexpected eligibility verification response status code: {r.status_code}")
raise ApiError("Unexpected eligibility verification response")

def verify(self, sub, name):
"""Check eligibility for the subject and name."""
Expand Down
2 changes: 1 addition & 1 deletion benefits/eligibility/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging

from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from benefits.core import widgets

Expand Down
2 changes: 1 addition & 1 deletion benefits/eligibility/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.decorators import decorator_from_middleware
from django.utils.translation import pgettext, ugettext as _
from django.utils.translation import pgettext, gettext as _

from benefits.core import middleware, session, viewmodels
from benefits.core.views import PageTemplateResponse, _index_image
Expand Down
2 changes: 1 addition & 1 deletion benefits/enrollment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.decorators import decorator_from_middleware
from django.utils.translation import pgettext, ugettext as _
from django.utils.translation import pgettext, gettext as _

from benefits.core import middleware, models, session, viewmodels
from benefits.core.views import PageTemplateResponse
Expand Down
19 changes: 12 additions & 7 deletions benefits/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ msgstr ""
msgid "core.payments.p1"
msgstr ""
"Cal-ITP is a new program serving all Californians. In order to activate your "
"discount, you need a bank card that has the contactless symbol on it. The "
"contactless symbol is four curved lines and it looks like this:"
"discount, you need a contactless-enabled bank card. Cards that are "
"contactless-enabled have the following symbol (four curved lines) "
"on the front or the back of them:"

#: benefits/core/templates/core/payment-options.html:7
msgctxt "image alt text"
msgid "core.icons.contactless"
msgstr "The contactless symbol"
msgstr "Four curved lines on contactless-enabled cards"

#: benefits/core/templates/core/payment-options.html:9
msgid "core.payments.p3"
Expand All @@ -108,11 +109,15 @@ msgstr "Note: Must include a Visa or Mastercard logo."
#: benefits/core/templates/core/payment-options.html:15
msgid "core.payments.p5"
msgstr ""
"We are working to add additional options for people who do not have access "
"to a bank card. Please check back on this website, or get in touch with your "
"local transit provider."
"Don't have access to a bank card? You can request a contactless card "
"from one of the companies that offer free contactless prepaid debit "
"cards, such as the "

#: benefits/core/templates/core/payment-options.html:16
#: benefits/core/templates/core/payment-options.html:17
msgid "core.payments.or"
msgstr "or the"

#: benefits/core/templates/core/payment-options.html:19
msgid "core.payments.p6"
msgstr ""
"You can still get your discount by going through your local transit "
Expand Down
20 changes: 12 additions & 8 deletions benefits/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ msgstr ""
msgid "core.payments.p1"
msgstr ""
"Cal-ITP es un nuevo programa que sirve a todos los Californianos. Para "
"activar su descuento, necesita una tarjeta bancaria que tenga el símbolo de "
"sin contacto. El símbolo sin contacto tiene cuatro líneas curveadas y se ve "
"así:"
"activar su descuento, necesita una tarjeta bancaria habilitada sin "
"contacto. Las tarjetas habilitadas sin contacto tienen el siguiente símbolo "
"(cuatro líneas curvas) en la parte delantera o trasera de la tarjeta:"

#: benefits/core/templates/core/payment-options.html:7
msgctxt "image alt text"
msgid "core.icons.contactless"
msgstr "El símbolo sin contacto"
msgstr "Cuatro líneas curvas en las tarjetas habilitadas sin contacto"

#: benefits/core/templates/core/payment-options.html:9
msgid "core.payments.p3"
Expand All @@ -111,11 +111,15 @@ msgstr "Nota: Debe incluir un logo de Visa o Mastercard"
#: benefits/core/templates/core/payment-options.html:15
msgid "core.payments.p5"
msgstr ""
"Estamos trabajando para agregar opciones adicionales para las personas que "
"no tienen acceso a una tarjeta bancaria. Vuelva a consultar este sitio web o "
"póngase en contacto con su proveedor de transporte público."
"¿No tienes acceso a una tarjeta bancaria? Puede solicitar una tarjeta "
"sin contacto a una de las compañías que ofrecen tarjetas de débito "
"prepagas sin contacto gratuitas, como la tarjeta de "

#: benefits/core/templates/core/payment-options.html:16
#: benefits/core/templates/core/payment-options.html:17
msgid "core.payments.or"
msgstr "o la"

#: benefits/core/templates/core/payment-options.html:19
msgid "core.payments.p6"
msgstr ""
"Aún puede obtener su descuento mediante el proceso de solicitud de su "
Expand Down
9 changes: 2 additions & 7 deletions benefits/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@

ADMIN = os.environ.get("DJANGO_ADMIN", "False").lower() == "true"

ALLOWED_HOSTS = []

if DEBUG:
ALLOWED_HOSTS.extend(["*"])
else:
hosts = os.environ["DJANGO_ALLOWED_HOSTS"].split(",")
ALLOWED_HOSTS.extend(hosts)
ALLOWED_HOSTS = os.environ["DJANGO_ALLOWED_HOSTS"].split(",")

# Application definition

Expand Down Expand Up @@ -68,6 +62,7 @@
CSRF_COOKIE_AGE = None
CSRF_COOKIE_SAMESITE = "Strict"
CSRF_COOKIE_HTTPONLY = True
CSRF_TRUSTED_ORIGINS = os.environ["DJANGO_TRUSTED_ORIGINS"].split(",")

SESSION_COOKIE_SAMESITE = "Strict"
SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
Expand Down
Loading

0 comments on commit 35a2007

Please sign in to comment.