Esempio n. 1
0
 def test_cant_change_signature_and_other_fields(self, mocker):
     # Mock the Autographer
     mock_autograph = mocker.patch("normandy.recipes.models.Autographer")
     mock_autograph.return_value.sign_data.return_value = [{"signature": "fake signature"}]
     action = ActionFactory(name="unchanged", signed=False)
     action.update_signature()
     action.name = "changed"
     with pytest.raises(ValidationError) as exc_info:
         action.save()
     assert exc_info.value.message == "Signatures must change alone"
Esempio n. 2
0
 def test_cant_change_signature_and_other_fields(self, mocker):
     # Mock the Autographer
     mock_autograph = mocker.patch("normandy.recipes.models.Autographer")
     mock_autograph.return_value.sign_data.return_value = [{"signature": "fake signature"}]
     action = ActionFactory(name="unchanged", signed=False)
     action.update_signature()
     action.name = "changed"
     with pytest.raises(ValidationError) as exc_info:
         action.save()
     assert exc_info.value.message == "Signatures must change alone"
Esempio n. 3
0
    def test_update_signature(self, mocker, mock_logger):
        # Mock the Autographer
        mock_autograph = mocker.patch("normandy.recipes.models.Autographer")
        mock_autograph.return_value.sign_data.return_value = [{"signature": "fake signature"}]

        action = ActionFactory(signed=False)
        action.update_signature()
        mock_logger.info.assert_called_with(
            Whatever.contains(action.name),
            extra={"code": INFO_REQUESTING_ACTION_SIGNATURES, "action_names": [action.name]},
        )

        action.save()
        assert action.signature is not None
        assert action.signature.signature == "fake signature"
Esempio n. 4
0
    def test_update_signature(self, mocker, mock_logger):
        # Mock the Autographer
        mock_autograph = mocker.patch("normandy.recipes.models.Autographer")
        mock_autograph.return_value.sign_data.return_value = [{"signature": "fake signature"}]

        action = ActionFactory(signed=False)
        action.update_signature()
        mock_logger.info.assert_called_with(
            Whatever.contains(action.name),
            extra={"code": INFO_REQUESTING_ACTION_SIGNATURES, "action_names": [action.name]},
        )

        action.save()
        assert action.signature is not None
        assert action.signature.signature == "fake signature"