Skip to content

Commit

Permalink
correct security to privacy
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobbins committed Jan 20, 2025
1 parent a0d69a9 commit 017735e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
7 changes: 4 additions & 3 deletions api/converters_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def test_minimal(self):
def test_maxmimal(self, mock_now):
"""If a Gate has all fields set, we can convert it to JSON."""
gate = Gate(
feature_id=1, stage_id=2, gate_type=GATE_SECURITY_ORIGIN_TRIAL, state=4,
feature_id=1, stage_id=2, gate_type=GATE_PRIVACY_ORIGIN_TRIAL, state=4,
requested_on=datetime(2022, 12, 14, 1, 2, 3), # Wednesday
assignee_emails=['appr1@example.com', 'appr2@example.com'],
next_action=datetime(2022, 12, 25),
Expand All @@ -572,10 +572,10 @@ def test_maxmimal(self, mock_now):
'id': gate.key.integer_id(),
'feature_id': 1,
'stage_id': 2,
'gate_type': GATE_SECURITY_ORIGIN_TRIAL,
'gate_type': GATE_PRIVACY_ORIGIN_TRIAL,
'team_name': appr_def.team_name,
'gate_name': appr_def.name,
'escalation_email': None,
'escalation_email': 'chrome-privacy-owp-rotation@google.com',
'state': 4,
'requested_on': '2022-12-14 01:02:03',
'responded_on': None,
Expand All @@ -597,6 +597,7 @@ def test_maxmimal(self, mock_now):
'launch_or_contact': 'reviewer@example.com',
},
}
self.maxDiff = None
self.assertEqual(expected, actual)

def test_slo_complete_review(self):
Expand Down
10 changes: 5 additions & 5 deletions internals/self_certify.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from chromestatus_openapi.models import SurveyAnswers as OASurveyAnswers

from internals.core_enums import GATE_SECURITY_ORIGIN_TRIAL, GATE_SECURITY_SHIP
from internals.core_enums import GATE_PRIVACY_ORIGIN_TRIAL, GATE_PRIVACY_SHIP
from internals.review_models import Gate, SurveyAnswers


Expand All @@ -35,8 +35,8 @@ def update_survey_answers(gate: Gate, new_answers: OASurveyAnswers):
answers.launch_or_contact = new_answers.launch_or_contact


def is_security_eligible(answers: SurveyAnswers) -> bool:
"""Return True if the answers allow self-certify for the Security gate."""
def is_privacy_eligible(answers: SurveyAnswers) -> bool:
"""Return True if the answers allow self-certify for the Privacy gate."""
return (
answers.is_language_polyfill or
answers.is_api_polyfill or
Expand All @@ -49,7 +49,7 @@ def is_eligible(gate: Gate) -> bool:
if answers is None:
return False

if gate.gate_type in [GATE_SECURITY_ORIGIN_TRIAL, GATE_SECURITY_SHIP]:
return is_security_eligible(answers)
if gate.gate_type in [GATE_PRIVACY_ORIGIN_TRIAL, GATE_PRIVACY_SHIP]:
return is_privacy_eligible(answers)

return False
28 changes: 14 additions & 14 deletions internals/self_certify_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,43 @@ def test_update_survey_answers__has_existing_answers(self):
self.assertFalse(gate.survey_answers.is_same_origin_css)
self.assertIsNone(gate.survey_answers.launch_or_contact)

def test_is_security_eligible(self):
"""Security is eligible if any of the booleans is True."""
self.assertFalse(self_certify.is_security_eligible(
def test_is_privacy_eligible(self):
"""Privacy is eligible if any of the booleans is True."""
self.assertFalse(self_certify.is_privacy_eligible(
SurveyAnswers()))
self.assertFalse(self_certify.is_security_eligible(
self.assertFalse(self_certify.is_privacy_eligible(
SurveyAnswers(is_language_polyfill=False)))
self.assertFalse(self_certify.is_security_eligible(
self.assertFalse(self_certify.is_privacy_eligible(
SurveyAnswers(is_api_polyfill=False)))
self.assertFalse(self_certify.is_security_eligible(
self.assertFalse(self_certify.is_privacy_eligible(
SurveyAnswers(is_same_origin_css=False)))
self.assertFalse(self_certify.is_security_eligible(
self.assertFalse(self_certify.is_privacy_eligible(
SurveyAnswers(
is_language_polyfill=False,
is_api_polyfill=False,
is_same_origin_css=False)))

self.assertTrue(self_certify.is_security_eligible(
self.assertTrue(self_certify.is_privacy_eligible(
SurveyAnswers(is_language_polyfill=True)))
self.assertTrue(self_certify.is_security_eligible(
self.assertTrue(self_certify.is_privacy_eligible(
SurveyAnswers(is_api_polyfill=True)))
self.assertTrue(self_certify.is_security_eligible(
self.assertTrue(self_certify.is_privacy_eligible(
SurveyAnswers(is_same_origin_css=True)))
self.assertTrue(self_certify.is_security_eligible(
self.assertTrue(self_certify.is_privacy_eligible(
SurveyAnswers(
is_language_polyfill=False, is_api_polyfill=False,
is_same_origin_css=True)))

def test_is_eligible(self):
"""Security gates are the only eligible type."""
"""Privacy gates are the only eligible type."""
self.assertTrue(self_certify.is_eligible(
Gate(
gate_type=GATE_SECURITY_ORIGIN_TRIAL,
gate_type=GATE_PRIVACY_ORIGIN_TRIAL,
survey_answers=SurveyAnswers(is_language_polyfill=True))))

self.assertFalse(self_certify.is_eligible(
Gate(
gate_type=GATE_SECURITY_ORIGIN_TRIAL,
gate_type=GATE_PRIVACY_ORIGIN_TRIAL,
survey_answers=SurveyAnswers())))

self.assertFalse(self_certify.is_eligible(
Expand Down

0 comments on commit 017735e

Please sign in to comment.