Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
#
# pip-compile --no-emit-index-url --no-strip-extras lambdas/python/cognito-backup/requirements-dev.in
#
aws-lambda-powertools==3.24.0
aws-lambda-powertools==3.27.0
# via -r lambdas/python/cognito-backup/requirements-dev.in
boto3==1.42.42
boto3==1.42.84
# via
# -r lambdas/python/cognito-backup/requirements-dev.in
# moto
botocore==1.42.42
botocore==1.42.84
# via
# -r lambdas/python/cognito-backup/requirements-dev.in
# boto3
# moto
# s3transfer
certifi==2026.1.4
certifi==2026.2.25
# via requests
cffi==2.0.0
# via cryptography
charset-normalizer==3.4.4
charset-normalizer==3.4.7
# via requests
cryptography==46.0.4
cryptography==46.0.6
# via
# joserfc
# moto
Expand All @@ -37,13 +37,13 @@ jmespath==1.1.0
# aws-lambda-powertools
# boto3
# botocore
joserfc==1.6.1
joserfc==1.6.3
# via moto
markupsafe==3.0.3
# via
# jinja2
# werkzeug
moto[cognitoidp,s3]==5.1.20
moto[cognitoidp,s3]==5.1.22
# via -r lambdas/python/cognito-backup/requirements-dev.in
packaging==26.0
# via pytest
Expand All @@ -53,7 +53,7 @@ py-partiql-parser==0.6.3
# via moto
pycparser==3.0
# via cffi
pygments==2.19.2
pygments==2.20.0
# via pytest
pytest==9.0.2
# via -r lambdas/python/cognito-backup/requirements-dev.in
Expand All @@ -65,11 +65,11 @@ pyyaml==6.0.3
# via
# moto
# responses
requests==2.32.5
requests==2.33.1
# via
# moto
# responses
responses==0.25.8
responses==0.26.0
# via moto
s3transfer==0.16.0
# via boto3
Expand All @@ -82,7 +82,7 @@ urllib3==2.6.3
# botocore
# requests
# responses
werkzeug==3.1.5
werkzeug==3.1.8
# via moto
xmltodict==1.0.2
xmltodict==1.0.4
# via moto
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,15 @@ def create_provider_privileges(
privilege_jurisdictions=jurisdiction_postal_abbreviations,
)

if not jurisdiction_postal_abbreviations:
logger.error(
'No list of jurisdictions provided. Cannot generate privileges for empty list.',
compact=compact,
provider_id=provider_id,
compact_transaction_id=compact_transaction_id,
)
raise CCInternalException('No list of jurisdictions provided. Cannot generate privileges for empty list.')

license_jurisdiction = provider_record.licenseJurisdiction

privileges = []
Expand All @@ -431,6 +440,8 @@ def create_provider_privileges(
processed_transactions = []
privilege_update_records = []

now = config.current_standard_datetime

for postal_abbreviation in jurisdiction_postal_abbreviations:
# get the original privilege issuance date from an existing privilege record if it exists
original_privilege = next(
Expand All @@ -457,8 +468,6 @@ def create_provider_privileges(

privileges.append(privilege_record)

now = config.current_standard_datetime

# Create privilege update record if this is updating an existing privilege
if original_privilege:
update_record = PrivilegeUpdateData.create_new(
Expand Down Expand Up @@ -527,9 +536,15 @@ def create_provider_privileges(
'pk': {'S': f'{compact}#PROVIDER#{provider_id}'},
'sk': {'S': f'{compact}#PROVIDER'},
},
'UpdateExpression': 'ADD #privilegeJurisdictions :newJurisdictions',
'UpdateExpression': 'ADD #privilegeJurisdictions :newJurisdictions '
'SET dateOfUpdate = :dateOfUpdate, providerDateOfUpdate = :providerDateOfUpdate',
'ExpressionAttributeNames': {'#privilegeJurisdictions': 'privilegeJurisdictions'},
'ExpressionAttributeValues': {':newJurisdictions': {'SS': jurisdiction_postal_abbreviations}},
'ExpressionAttributeValues': {
':newJurisdictions': {'SS': jurisdiction_postal_abbreviations},
':dateOfUpdate': {'S': now.isoformat()},
':providerDateOfUpdate': {'S': now.isoformat()},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
},
'ConditionExpression': 'attribute_exists(pk)',
}
}
)
Expand Down Expand Up @@ -727,12 +742,14 @@ def complete_military_affiliation_initialization(self, compact: str, provider_id
'UpdateExpression': (
'SET militaryStatus = :militaryStatus, '
'militaryStatusNote = :militaryStatusNote, '
'dateOfUpdate = :dateOfUpdate'
'dateOfUpdate = :dateOfUpdate, '
'providerDateOfUpdate = :providerDateOfUpdate'
),
'ExpressionAttributeValues': {
':militaryStatus': {'S': MilitaryStatus.TENTATIVE},
':militaryStatusNote': {'S': ''},
':dateOfUpdate': {'S': self.config.current_standard_datetime.isoformat()},
':dateOfUpdate': {'S': now.isoformat()},
':providerDateOfUpdate': {'S': now.isoformat()},
},
'ConditionExpression': 'attribute_exists(pk)',
}
Expand Down Expand Up @@ -765,7 +782,7 @@ def complete_military_affiliation_initialization(self, compact: str, provider_id
'ExpressionAttributeNames': {'#status': 'status'},
'ExpressionAttributeValues': {
':status': {'S': status_value},
':dateOfUpdate': {'S': self.config.current_standard_datetime.isoformat()},
':dateOfUpdate': {'S': now.isoformat()},
},
}
}
Expand Down Expand Up @@ -902,9 +919,13 @@ def end_military_affiliation(self, compact: str, provider_id: str) -> None:
'pk': {'S': provider_serialized_record['pk']},
'sk': {'S': provider_serialized_record['sk']},
},
'UpdateExpression': ('SET dateOfUpdate = :dateOfUpdate REMOVE militaryStatus, militaryStatusNote'),
'UpdateExpression': (
'SET dateOfUpdate = :dateOfUpdate, providerDateOfUpdate = :providerDateOfUpdate '
'REMOVE militaryStatus, militaryStatusNote'
),
'ExpressionAttributeValues': {
':dateOfUpdate': {'S': self.config.current_standard_datetime.isoformat()},
':dateOfUpdate': {'S': now.isoformat()},
':providerDateOfUpdate': {'S': now.isoformat()},
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
'ConditionExpression': 'attribute_exists(pk)',
}
Expand Down Expand Up @@ -1040,12 +1061,14 @@ def process_military_audit(
'UpdateExpression': (
'SET militaryStatus = :militaryStatus, '
'militaryStatusNote = :militaryStatusNote, '
'dateOfUpdate = :dateOfUpdate'
'dateOfUpdate = :dateOfUpdate, '
'providerDateOfUpdate = :providerDateOfUpdate'
),
'ExpressionAttributeValues': {
':militaryStatus': {'S': military_status},
':militaryStatusNote': {'S': note_value},
':dateOfUpdate': {'S': self.config.current_standard_datetime.isoformat()},
':dateOfUpdate': {'S': now.isoformat()},
':providerDateOfUpdate': {'S': now.isoformat()},
},
'ConditionExpression': 'attribute_exists(pk)',
}
Expand Down Expand Up @@ -1473,8 +1496,25 @@ def deactivate_privilege(
'UpdateExpression': 'SET administratorSetStatus = :status, dateOfUpdate = :dateOfUpdate',
'ExpressionAttributeValues': {
':status': {'S': ActiveInactiveStatus.INACTIVE},
':dateOfUpdate': {'S': self.config.current_standard_datetime.isoformat()},
':dateOfUpdate': {'S': now.isoformat()},
},
},
},
# Update dateOfUpdate and providerDateOfUpdate on the top-level provider record
{
'Update': {
'TableName': self.config.provider_table.name,
'Key': {
'pk': {'S': f'{compact}#PROVIDER#{provider_id}'},
'sk': {'S': f'{compact}#PROVIDER'},
},
'UpdateExpression': 'SET dateOfUpdate = :dateOfUpdate, '
'providerDateOfUpdate = :providerDateOfUpdate',
'ExpressionAttributeValues': {
':dateOfUpdate': {'S': now.isoformat()},
':providerDateOfUpdate': {'S': now.isoformat()},
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
'ConditionExpression': 'attribute_exists(pk)',
},
},
# Create a history record, reflecting this change
Expand Down Expand Up @@ -1560,10 +1600,22 @@ def _generate_set_provider_encumbered_status_item(
# licenses and providers share the same encumbered status enum
provider_encumbered_status: LicenseEncumberedStatusEnum,
):
return self._generate_encumbered_status_update_item(
data=provider_data,
encumbered_status=provider_encumbered_status,
)
data_record = provider_data.serialize_to_database_record()
now = self.config.current_standard_datetime
return {
'Update': {
'TableName': self.config.provider_table.name,
'Key': {'pk': {'S': data_record['pk']}, 'sk': {'S': data_record['sk']}},
'UpdateExpression': 'SET encumberedStatus = :status, dateOfUpdate = :dateOfUpdate, '
'providerDateOfUpdate = :providerDateOfUpdate',
'ExpressionAttributeValues': {
':status': {'S': provider_encumbered_status},
':dateOfUpdate': {'S': now.isoformat()},
':providerDateOfUpdate': {'S': now.isoformat()},
},
'ConditionExpression': 'attribute_exists(pk)',
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

def _generate_put_transaction_item(self, item: dict):
return {'Put': {'TableName': self.config.provider_table.name, 'Item': TypeSerializer().serialize(item)['M']}}
Expand Down Expand Up @@ -2965,11 +3017,14 @@ def _get_provider_record_transaction_items_for_jurisdiction_with_no_known_licens
},
'UpdateExpression': 'SET '
'currentHomeJurisdiction = :currentHomeJurisdiction, '
'dateOfUpdate = :dateOfUpdate',
'dateOfUpdate = :dateOfUpdate, '
'providerDateOfUpdate = :providerDateOfUpdate',
'ExpressionAttributeValues': {
':currentHomeJurisdiction': {'S': selected_jurisdiction},
':dateOfUpdate': {'S': self.config.current_standard_datetime.isoformat()},
':dateOfUpdate': {'S': now.isoformat()},
':providerDateOfUpdate': {'S': now.isoformat()},
},
'ConditionExpression': 'attribute_exists(pk)',
}
},
]
Expand Down Expand Up @@ -3850,12 +3905,14 @@ def complete_provider_email_update(
},
'UpdateExpression': (
'SET compactConnectRegisteredEmailAddress = :new_email, '
'dateOfUpdate = :date_of_update '
'dateOfUpdate = :date_of_update, '
'providerDateOfUpdate = :provider_date_of_update '
'REMOVE pendingEmailAddress, emailVerificationCode, emailVerificationExpiry'
),
'ExpressionAttributeValues': {
':new_email': {'S': new_email_address},
':date_of_update': {'S': self.config.current_standard_datetime.isoformat()},
':date_of_update': {'S': now.isoformat()},
':provider_date_of_update': {'S': now.isoformat()},
},
# Ensure the provider record exists before updating
'ConditionExpression': 'attribute_exists(pk)',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Keep attrs on 25.x to match root requirements.txt (jsii/cattrs); avoids pip-sync conflicts.
moto[all]>=5.0.12, <6
boto3-stubs[full]
Faker>=37, <38
cryptography>=46, <47
attrs>=25, <26
Loading
Loading