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

2024-07-02 | MAIN --> PROD | DEV (7cdd9af) --> STAGING #4047

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 46 additions & 13 deletions backend/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

from audit.models import SingleAuditChecklist, Access
from api.uei import get_uei_info_from_sam_gov

from audit.validators import (
validate_general_information_json,
)
from config.settings import CHARACTER_LIMITS_GENERAL


# Eligibility step messages
SPENDING_THRESHOLD = _(
Expand Down Expand Up @@ -197,29 +198,61 @@ class Meta:

class AccessAndSubmissionSerializer(serializers.Serializer):
# This serializer isn't tied to a model, so it's just input fields with the below layout
certifying_auditee_contact_fullname = serializers.CharField()
certifying_auditee_contact_email = serializers.EmailField()
certifying_auditor_contact_fullname = serializers.CharField()
certifying_auditor_contact_email = serializers.EmailField()
certifying_auditee_contact_fullname = serializers.CharField(
min_length=CHARACTER_LIMITS_GENERAL["auditee_contact_name"]["min"],
max_length=CHARACTER_LIMITS_GENERAL["auditee_contact_name"]["max"],
)
certifying_auditee_contact_email = serializers.EmailField(
min_length=CHARACTER_LIMITS_GENERAL["auditee_email"]["min"],
max_length=CHARACTER_LIMITS_GENERAL["auditee_email"]["max"],
)
certifying_auditor_contact_fullname = serializers.CharField(
min_length=CHARACTER_LIMITS_GENERAL["auditor_contact_name"]["min"],
max_length=CHARACTER_LIMITS_GENERAL["auditor_contact_name"]["max"],
)
certifying_auditor_contact_email = serializers.EmailField(
min_length=CHARACTER_LIMITS_GENERAL["auditor_email"]["min"],
max_length=CHARACTER_LIMITS_GENERAL["auditor_email"]["max"],
)
auditor_contacts_email = serializers.ListField(
child=serializers.EmailField(required=False, allow_null=True, allow_blank=True),
child=serializers.EmailField(
required=False,
allow_null=True,
allow_blank=True,
min_length=CHARACTER_LIMITS_GENERAL["auditor_email"]["min"],
max_length=CHARACTER_LIMITS_GENERAL["auditor_email"]["max"],
),
allow_empty=True,
min_length=0,
)
auditee_contacts_email = serializers.ListField(
child=serializers.EmailField(required=False, allow_null=True, allow_blank=True),
child=serializers.EmailField(
required=False,
allow_null=True,
allow_blank=True,
min_length=CHARACTER_LIMITS_GENERAL["auditee_email"]["min"],
max_length=CHARACTER_LIMITS_GENERAL["auditee_email"]["max"],
),
allow_empty=True,
min_length=0,
)
auditor_contacts_fullname = serializers.ListField(
child=serializers.CharField(required=False, allow_null=True, allow_blank=True),
child=serializers.CharField(
required=False,
allow_null=True,
allow_blank=True,
min_length=CHARACTER_LIMITS_GENERAL["auditor_contact_name"]["min"],
max_length=CHARACTER_LIMITS_GENERAL["auditor_contact_name"]["max"],
),
allow_empty=True,
min_length=0,
)
auditee_contacts_fullname = serializers.ListField(
child=serializers.CharField(required=False, allow_null=True, allow_blank=True),
child=serializers.CharField(
required=False,
allow_null=True,
allow_blank=True,
min_length=CHARACTER_LIMITS_GENERAL["auditee_contact_name"]["min"],
max_length=CHARACTER_LIMITS_GENERAL["auditee_contact_name"]["max"],
),
allow_empty=True,
min_length=0,
)

def validate(self, data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{% endif %}

{% comment %} Auditor Certification {% endcomment %}
<li class="usa-icon-list__item padding-bottom-105"
<li class="usa-icon-list__item padding-bottom-105 margin-top-5"
id="auditor-certification-completed">
{% if certification.auditor_certified %}
{% include './icon-list-icon.html' with completed=certification.auditor_certified %}
Expand Down
11 changes: 0 additions & 11 deletions backend/audit/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,6 @@ def test_invalid_auditee_fiscal_period_end(self):
schema,
)

def test_null_auditee_name(self):
"""
If the auditee_name is null, validation should pass
"""
schema = self.GENERAL_INFO_SCHEMA
instance = jsoncopy(self.SIMPLE_CASE)

instance["auditee_name"] = ""

validate(instance, schema)

def test_invalid_ein(self):
"""
If the EIN is not in a valid format, validation should fail
Expand Down
71 changes: 71 additions & 0 deletions backend/audit/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,65 @@ def setUp(self):
"audit_period_covered": "Invalid",
}

character_limits = settings.CHARACTER_LIMITS_GENERAL

self.too_short_emails = self.valid_general_information | {
"auditee_email": "a@b",
"auditor_email": "a@b",
}

self.too_long_emails = self.valid_general_information | {
"auditee_email": "a" * character_limits["auditee_email"]["max"]
+ "NowItIsDefinitelyTooLong",
"auditor_email": "a" * character_limits["auditor_email"]["max"]
+ "NowItIsDefinitelyTooLong",
}

self.too_short_addresses = self.valid_general_information | {
"auditee_address_line_1": "a",
"auditee_city": "a",
}

self.too_long_addresses = self.valid_general_information | {
"auditee_address_line_1": "a"
* character_limits["auditee_address_line_1"]["max"]
+ "NowItIsDefinitelyTooLong",
"auditee_city": "a" * character_limits["auditee_city"]["max"]
+ "NowItIsDefinitelyTooLong",
}

self.too_short_names = self.valid_general_information | {
"auditee_name": "a",
"auditee_certify_name": "a",
"auditee_certify_title": "a",
"auditee_contact_name": "a",
"auditor_firm_name": "a",
"auditor_contact_title": "a",
"auditor_contact_name": "a",
}

self.too_long_names = self.valid_general_information | {
"auditee_name": "a" * character_limits["auditee_name"]["max"]
+ "NowItIsDefinitelyTooLong",
"auditee_certify_name": "a"
* character_limits["auditee_certify_name"]["max"]
+ "NowItIsDefinitelyTooLong",
"auditee_certify_title": "a"
* character_limits["auditee_certify_title"]["max"]
+ "NowItIsDefinitelyTooLong",
"auditee_contact_name": "a"
* character_limits["auditee_contact_name"]["max"]
+ "NowItIsDefinitelyTooLong",
"auditor_firm_name": "a" * character_limits["auditor_firm_name"]["max"]
+ "NowItIsDefinitelyTooLong",
"auditor_contact_title": "a"
* character_limits["auditor_contact_title"]["max"]
+ "NowItIsDefinitelyTooLong",
"auditor_contact_name": "a"
* character_limits["auditor_contact_name"]["max"]
+ "NowItIsDefinitelyTooLong",
}

def test_validate_general_information_schema_with_valid_data(self):
"""
Test the validation method with valid general information data.
Expand Down Expand Up @@ -1139,6 +1198,18 @@ def test_validate_general_information_schema_with_invalid_data(self):
validate_general_information_schema(self.invalid_email)
with self.assertRaises(ValidationError):
validate_general_information_schema(self.invalid_audit_period_covered)
with self.assertRaises(ValidationError):
validate_general_information_schema(self.too_short_emails)
with self.assertRaises(ValidationError):
validate_general_information_schema(self.too_long_emails)
with self.assertRaises(ValidationError):
validate_general_information_schema(self.too_short_addresses)
with self.assertRaises(ValidationError):
validate_general_information_schema(self.too_long_addresses)
with self.assertRaises(ValidationError):
validate_general_information_schema(self.too_short_names)
with self.assertRaises(ValidationError):
validate_general_information_schema(self.too_long_names)

def test_validate_general_information_schema_rules_with_valid_data(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions backend/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@
STATE_ABBREVS = json.load(open(f"{SCHEMA_BASE_DIR}/States.json"))[
"UnitedStatesStateAbbr"
]
CHARACTER_LIMITS_GENERAL = json.load(
open(f"{SCHEMA_BASE_DIR}/character_limits/general.json")
)

ENABLE_DEBUG_TOOLBAR = (
env.bool("ENABLE_DEBUG_TOOLBAR", False) and ENVIRONMENT == "LOCAL" and not TEST_RUN
Expand Down
76 changes: 41 additions & 35 deletions backend/package-lock.json

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

Loading
Loading