X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=test%2Fremake_id_test.cc;h=c4953f98044ca1f1174994dbfa1e0a675e28e844;hp=d8bb5df830fcbbe8c75c6886a90bf458f5b5336b;hb=6d686ea45f5cd01a0d11f92a903ac77779ad8562;hpb=9b4cf50fc498028e43ce008dacc7057a488bb65a diff --git a/test/remake_id_test.cc b/test/remake_id_test.cc index d8bb5df83..c4953f980 100644 --- a/test/remake_id_test.cc +++ b/test/remake_id_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2017 Carl Hetherington + Copyright (C) 2017-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,38 +18,90 @@ */ + #include "lib/ffmpeg_content.h" #include "lib/content_factory.h" -#include "lib/subtitle_content.h" +#include "lib/text_content.h" +#include "lib/job_manager.h" #include "lib/film.h" +#include "lib/dcp_content.h" +#include "lib/examine_content_job.h" +#include "lib/config.h" #include "test.h" #include +#include + + +using std::string; +using std::vector; +using std::shared_ptr; +using std::dynamic_pointer_cast; +using std::make_shared; +using boost::optional; -using boost::shared_ptr; -using boost::dynamic_pointer_cast; /** Check for bug #1126 whereby making a new DCP using the same video asset as an old one * corrupts the old one. */ -BOOST_AUTO_TEST_CASE (remake_id_test) +BOOST_AUTO_TEST_CASE (remake_id_test1) { /* Make a DCP */ - shared_ptr film = new_test_film2 ("remake_id_test"); - shared_ptr content = content_factory(film, "test/data/flat_red.png").front(); - film->examine_and_add_content (content); - BOOST_REQUIRE (!wait_for_jobs ()); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + auto content = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("remake_id_test1_1", {content}); + make_and_verify_dcp (film); /* Copy the video file */ - boost::filesystem::path first_video = video_file(film); + auto first_video = dcp_file(film, "j2c"); boost::filesystem::copy_file (first_video, first_video.string() + ".copy"); /* Make a new DCP with the same video file */ - film->set_name ("remake_id_test2"); - film->make_dcp (); - BOOST_REQUIRE (!wait_for_jobs ()); + film->set_name ("remake_id_test1_2"); + make_and_verify_dcp (film); /* Check that the video in the first DCP hasn't changed */ check_file (first_video, first_video.string() + ".copy"); } + + +/** Check for bug #1232 where remaking an encrypted DCP causes problems with HMAC IDs (?) */ +BOOST_AUTO_TEST_CASE (remake_id_test2) +{ + /* Make a DCP */ + auto content = content_factory("test/data/flat_red.png").front(); + auto film = new_test_film2 ("remake_id_test2_1", {content}); + film->set_encrypted (true); + make_and_verify_dcp (film); + + /* Remove and remake it */ + boost::filesystem::remove_all(film->dir(film->dcp_name())); + make_and_verify_dcp (film); + + /* Find the CPL */ + optional cpl; + for (auto i: boost::filesystem::directory_iterator(film->dir(film->dcp_name()))) { + if (i.path().filename().string().substr(0, 4) == "cpl_") { + cpl = i.path(); + } + } + BOOST_REQUIRE(cpl); + + /* Make a DKDM */ + auto kdm = film->make_kdm ( + Config::instance()->decryption_chain()->leaf(), + vector(), + *cpl, + dcp::LocalTime ("2030-01-01T01:00:00+00:00"), + dcp::LocalTime ("2031-01-01T01:00:00+00:00"), + dcp::Formulation::MODIFIED_TRANSITIONAL_1, + true, + 0 + ); + + /* Import the DCP into a new film */ + auto dcp_content = make_shared(film->dir(film->dcp_name())); + auto film2 = new_test_film2("remake_id_test2_2", {dcp_content}); + dcp_content->add_kdm(kdm); + JobManager::instance()->add(make_shared(film2, dcp_content)); + BOOST_REQUIRE(!wait_for_jobs()); + make_and_verify_dcp (film2); +}