def test_sign_claim_messages_no_signatures( mock_quay_client, mock_remove_duplicate_claim_msgs, mock_filter_claim_msgs, mock_get_radas_signatures, mock_validate_radas_msgs, mock_upload_signatures_to_pyxis, target_settings, container_signing_push_item, container_multiarch_push_item, ): hub = mock.MagicMock() mock_remove_duplicate_claim_msgs.return_value = [ "msg1", "msg2", "msg3", "msg4" ] mock_filter_claim_msgs.return_value = [] sig_handler = signature_handler.BasicSignatureHandler( hub, target_settings, "some-target") sig_handler.sign_claim_messages(["msg1", "msg2", "msg3", "msg4"]) mock_remove_duplicate_claim_msgs.assert_called_once_with( ["msg1", "msg2", "msg3", "msg4"]) mock_filter_claim_msgs.assert_called_once_with( ["msg1", "msg2", "msg3", "msg4"]) mock_get_radas_signatures.assert_not_called() mock_validate_radas_msgs.assert_not_called() mock_upload_signatures_to_pyxis.assert_not_called()
def test_basic_signature_handler_init(mock_quay_api_client, mock_quay_client, target_settings): hub = mock.MagicMock() sig_handler = signature_handler.BasicSignatureHandler(hub, target_settings, "some-target") assert sig_handler.hub == hub assert sig_handler.task_id == "1" assert sig_handler.dest_registries == ["some-registry1.com", "some-registry2.com"] assert sig_handler.target_settings == target_settings assert sig_handler.quay_host == "quay.io" mock_quay_client.assert_not_called() mock_quay_api_client.assert_not_called() assert sig_handler.quay_client == mock_quay_client.return_value assert sig_handler.quay_api_client == mock_quay_api_client.return_value mock_quay_client.assert_called_once_with("quay-user", "quay-pass", "quay.io") mock_quay_api_client.assert_called_once_with("quay-token", "quay.io")
def test_sign_claim_messages_not_allowed( mock_quay_api_client, mock_quay_client, mock_filter_claim_msgs, mock_get_radas_signatures, mock_validate_radas_msgs, mock_upload_signatures_to_pyxis, target_settings, container_signing_push_item, ): hub = mock.MagicMock() target_settings["docker_settings"]["docker_container_signing_enabled"] = False sig_handler = signature_handler.BasicSignatureHandler(hub, target_settings, "some-target") sig_handler.sign_claim_messages(["msg1", "msg2", "msg3", "msg4"]) mock_filter_claim_msgs.assert_not_called() mock_get_radas_signatures.assert_not_called() mock_validate_radas_msgs.assert_not_called() mock_upload_signatures_to_pyxis.assert_not_called()