def test_it_fails_if_a_signature_does_not_verify(self, mocker, settings): settings.CERTIFICATES_EXPIRE_EARLY_DAYS = None recipe = RecipeFactory(signed=True) mock_verify_x5u = mocker.patch('normandy.recipes.checks.signing.verify_x5u') mock_verify_x5u.side_effect = signing.BadCertificate('testing exception') errors = checks.signatures_use_good_certificates(None) mock_verify_x5u.assert_called_once_with(recipe.signature.x5u, None) assert len(errors) == 1 assert errors[0].id == checks.WARNING_BAD_SIGNING_CERTIFICATE
def test_it_fails_if_a_signature_does_not_verify(self, mocker, settings): settings.CERTIFICATES_EXPIRE_EARLY_DAYS = None recipe = RecipeFactory(approver=UserFactory(), signed=True) mock_verify_x5u = mocker.patch( "normandy.recipes.checks.signing.verify_x5u") mock_verify_x5u.side_effect = signing.BadCertificate( "testing exception") errors = checks.signatures_use_good_certificates(None) mock_verify_x5u.assert_called_once_with(recipe.signature.x5u, None) assert len(errors) == 1 assert errors[0].id == checks.ERROR_BAD_SIGNING_CERTIFICATE assert recipe.approved_revision.name in errors[0].msg
def side_effect(x5u, *args): if "bad" in x5u: raise signing.BadCertificate("testing exception") return True
def side_effect(x5u, *args): if 'bad' in x5u: raise signing.BadCertificate('testing exception') return True