def test_should_pass_signer_options_to_signing_module(self):
        class DummySigner(object):
            @classmethod
            def sign(cls, data, signature_options, signer_options):
                self.assertEqual(signer_options, DUMMY_OPTIONS['signer'])

        capsule_helper.build_capsule(b'030303', DUMMY_OPTIONS['capsule'],
                                     DummySigner, DUMMY_OPTIONS['signer'])
    def test_should_pass_wrapped_blob_to_signing_module(self):
        dummy_payload = b'This_Is_My_Sample_Payload,ThereAreManyLikeIt;This One Is Mine'

        class DummySigner(object):
            @classmethod
            def sign(cls, data, signature_options, signer_options):
                self.assertTrue(dummy_payload in data)

        capsule_helper.build_capsule(dummy_payload, DUMMY_OPTIONS['capsule'],
                                     DummySigner, DUMMY_OPTIONS['signer'])
def main():
    args = get_cli_options()
    final_options = update_options(load_options_file(args.options_file),
                                   args.capsule_options, args.signer_options)

    # Verify minimum capsule options.
    required_capsule_options = ('fw_name', 'fw_version', 'lsv_version',
                                'fw_version_string', 'provider_name',
                                'fw_description', 'esrt_guid')
    missing_capsule_options = tuple(option
                                    for option in required_capsule_options
                                    if option not in final_options['capsule'])
    if len(missing_capsule_options) > 0:
        logging.error("Missing required capsule options: " +
                      ", ".join(missing_capsule_options) + "!")
        logging.error(
            "Options MUST be provided in either the options file or on the command line."
        )
        sys.exit(1)

    # Next, we're gonna need a signer.
    if args.builtin_signer is not None:
        signer = signing_helper.get_signer(args.builtin_signer)
    elif args.module_signer is not None:
        signer = signing_helper.get_signer(signing_helper.PYPATH_MODULE_SIGNER,
                                           args.module_signer)
    elif args.local_signer is not None:
        signer = signing_helper.get_signer(signing_helper.LOCAL_MODULE_SIGNER,
                                           args.local_signer)

    # Now, build the capsule.
    uefi_capsule_header = capsule_helper.build_capsule(
        args.capsule_payload.read(), final_options['capsule'], signer,
        final_options['signer'])

    # Save the capsule.
    capsule_helper.save_capsule(uefi_capsule_header, final_options['capsule'],
                                args.output_dir)

    # Build the INF file.
    capsule_helper.create_inf_file(final_options['capsule'], args.output_dir)

    # Build the CAT file.
    capsule_helper.create_cat_file(final_options['capsule'], args.output_dir)

    # If requested, save the final options for provenance.
    if args.save_final_options:
        final_options_file = os.path.join(args.output_dir,
                                          'Final_Capsule_Options.yaml')
        with open(final_options_file, 'w') as options_file:
            yaml.dump(final_options, options_file, indent=2)