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

Feat: EligibilityVerifier active flag #1665

Merged
merged 6 commits into from
Aug 16, 2023
Merged
3 changes: 2 additions & 1 deletion benefits/core/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.4 on 2023-08-07 16:23
# Generated by Django 4.2.4 on 2023-08-16 15:06

from django.db import migrations, models
import django.db.models.deletion
Expand Down Expand Up @@ -38,6 +38,7 @@ class Migration(migrations.Migration):
fields=[
("id", models.AutoField(primary_key=True, serialize=False)),
("name", models.TextField()),
("active", models.BooleanField(default=False)),
("api_url", models.TextField(null=True)),
("api_auth_header", models.TextField(null=True)),
("api_auth_key", models.TextField(null=True)),
Expand Down
5 changes: 5 additions & 0 deletions benefits/core/migrations/0002_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def load_data(app, *args, **kwargs):

mst_senior_verifier = EligibilityVerifier.objects.create(
name=os.environ.get("MST_OAUTH_VERIFIER_NAME", "OAuth claims via Login.gov (MST)"),
active=os.environ.get("MST_OAUTH_VERIFIER_ACTIVE", "True").lower() == "true",
eligibility_type=mst_senior_type,
auth_provider=senior_auth_provider,
selection_label_template="eligibility/includes/selection-label--senior.html",
Expand All @@ -175,6 +176,7 @@ def load_data(app, *args, **kwargs):

mst_veteran_verifier = EligibilityVerifier.objects.create(
name=os.environ.get("MST_VETERAN_VERIFIER_NAME", "VA.gov - Veteran (MST)"),
active=os.environ.get("MST_VETERAN_VERIFIER_ACTIVE", "True").lower() == "true",
eligibility_type=mst_veteran_type,
auth_provider=veteran_auth_provider,
selection_label_template="eligibility/includes/selection-label--veteran.html",
Expand All @@ -183,6 +185,7 @@ def load_data(app, *args, **kwargs):

mst_courtesy_card_verifier = EligibilityVerifier.objects.create(
name=os.environ.get("COURTESY_CARD_VERIFIER", "Eligibility Server Verifier"),
active=os.environ.get("COURTESY_CARD_VERIFIER_ACTIVE", "True").lower() == "true",
api_url=os.environ.get("COURTESY_CARD_VERIFIER_API_URL", "http://server:8000/verify"),
api_auth_header=os.environ.get("COURTESY_CARD_VERIFIER_API_AUTH_HEADER", "X-Server-API-Key"),
api_auth_key=os.environ.get("COURTESY_CARD_VERIFIER_API_AUTH_KEY", "server-auth-token"),
Expand All @@ -199,6 +202,7 @@ def load_data(app, *args, **kwargs):

sacrt_senior_verifier = EligibilityVerifier.objects.create(
name=os.environ.get("SACRT_OAUTH_VERIFIER_NAME", "OAuth claims via Login.gov (SacRT)"),
active=os.environ.get("SACRT_OAUTH_VERIFIER_ACTIVE", "False").lower() == "true",
eligibility_type=sacrt_senior_type,
auth_provider=senior_auth_provider,
selection_label_template="eligibility/includes/selection-label--senior.html",
Expand All @@ -207,6 +211,7 @@ def load_data(app, *args, **kwargs):

sbmtd_senior_verifier = EligibilityVerifier.objects.create(
name=os.environ.get("SBMTD_OAUTH_VERIFIER_NAME", "OAuth claims via Login.gov (SBMTD)"),
active=os.environ.get("SBMTD_OAUTH_VERIFIER_ACTIVE", "False").lower() == "true",
eligibility_type=sbmtd_senior_type,
auth_provider=senior_auth_provider,
selection_label_template="eligibility/includes/selection-label--senior.html",
Expand Down
1 change: 1 addition & 0 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class EligibilityVerifier(models.Model):

id = models.AutoField(primary_key=True)
name = models.TextField()
active = models.BooleanField(default=False)
api_url = models.TextField(null=True)
api_auth_header = models.TextField(null=True)
api_auth_key = models.TextField(null=True)
Expand Down
2 changes: 1 addition & 1 deletion benefits/eligibility/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EligibilityVerifierSelectionForm(forms.Form):

def __init__(self, agency: models.TransitAgency, *args, **kwargs):
super().__init__(*args, **kwargs)
verifiers = agency.eligibility_verifiers.all()
verifiers = agency.eligibility_verifiers.filter(active=True)

self.classes = "col-lg-8"
# second element is not used since we render the whole label using selection_label_template,
Expand Down
7 changes: 6 additions & 1 deletion terraform/app_service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,21 @@ resource "azurerm_linux_web_app" "main" {
"VETERAN_AUTH_PROVIDER_CLAIM" = "${local.secret_prefix}veteran-auth-provider-claim)"
"VETERAN_AUTH_PROVIDER_SCHEME" = "${local.secret_prefix}veteran-auth-provider-scheme)"
"MST_OAUTH_VERIFIER_NAME" = "${local.secret_prefix}mst-oauth-verifier-name)"
"MST_OAUTH_VERIFIER_ACTIVE" = "${local.secret_prefix}mst-oauth-verifier-active)"
"MST_VETERAN_VERIFIER_NAME" = "${local.secret_prefix}mst-veteran-verifier-name)"
"MST_VETERAN_VERIFIER_ACTIVE" = "${local.secret_prefix}mst-veteran-verifier-active)"
"COURTESY_CARD_VERIFIER" = "${local.secret_prefix}courtesy-card-verifier)"
"COURTESY_CARD_VERIFIER_ACTIVE" = "${local.secret_prefix}courtesy-card-verifier-active)"
"COURTESY_CARD_VERIFIER_API_URL" = "${local.secret_prefix}courtesy-card-verifier-api-url)"
"COURTESY_CARD_VERIFIER_API_AUTH_HEADER" = "${local.secret_prefix}courtesy-card-verifier-api-auth-header)"
"COURTESY_CARD_VERIFIER_API_AUTH_KEY" = "${local.secret_prefix}courtesy-card-verifier-api-auth-key)"
"COURTESY_CARD_VERIFIER_JWE_CEK_ENC" = "${local.secret_prefix}courtesy-card-verifier-jwe-cek-enc)"
"COURTESY_CARD_VERIFIER_JWE_ENCRYPTION_ALG" = "${local.secret_prefix}courtesy-card-verifier-jwe-encryption-alg)"
"COURTESY_CARD_VERIFIER_JWS_SIGNING_ALG" = "${local.secret_prefix}courtesy-card-verifier-jws-signing-alg)"
"SACRT_OAUTH_VERIFIER_NAME" = "${local.secret_prefix}sacrt-oauth-verifier-name)"
"SBMTD_SENIOR_VERIFIER_NAME" = "${local.secret_prefix}sbmtd-senior-verifier-name"
"SACRT_OAUTH_VERIFIER_ACTIVE" = "${local.secret_prefix}sacrt-oauth-verifier-active)"
"SBMTD_SENIOR_VERIFIER_NAME" = "${local.secret_prefix}sbmtd-senior-verifier-name)"
"SBMTD_SENIOR_VERIFIER_ACTIVE" = "${local.secret_prefix}sbmtd-senior-verifier-active)"
"MST_PAYMENT_PROCESSOR_NAME" = "${local.secret_prefix}mst-payment-processor-name)"
"MST_PAYMENT_PROCESSOR_API_BASE_URL" = "${local.secret_prefix}mst-payment-processor-api-base-url)"
"MST_PAYMENT_PROCESSOR_API_ACCESS_TOKEN_ENDPOINT" = "${local.secret_prefix}mst-payment-processor-api-access-token-endpoint)"
Expand Down
1 change: 1 addition & 0 deletions tests/pytest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def model_EligibilityType():
def model_EligibilityVerifier(model_PemData, model_EligibilityType):
verifier = EligibilityVerifier.objects.create(
name="Test Verifier",
active=True,
api_url="https://example.com/verify",
api_auth_header="X-API-AUTH",
api_auth_key="secret-key",
Expand Down
4 changes: 2 additions & 2 deletions tests/pytest/eligibility/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_index_get_agency_multiple_verifiers(
):
# override the mocked session agency with a mock agency that has multiple verifiers
mock_agency = mocker.Mock(spec=model_TransitAgency)
mock_agency.eligibility_verifiers.all.return_value = [model_EligibilityVerifier, model_EligibilityVerifier]
mock_agency.eligibility_verifiers.filter.return_value = [model_EligibilityVerifier, model_EligibilityVerifier]
mock_agency.eligibility_verifiers.count.return_value = 2
mock_agency.index_url = "/agency"
mock_agency.eligibility_index_template = "eligibility/index.html"
Expand All @@ -107,7 +107,7 @@ def test_index_get_agency_single_verifier(
):
# override the mocked session agency with a mock agency that has a single verifier
mock_agency = mocker.Mock(spec=model_TransitAgency)
mock_agency.eligibility_verifiers.all.return_value = [model_EligibilityVerifier]
mock_agency.eligibility_verifiers.filter.return_value = [model_EligibilityVerifier]
mock_agency.eligibility_verifiers.count.return_value = 1
mock_agency.index_url = "/agency"
mock_agency.eligibility_index_template = "eligibility/index.html"
Expand Down