+
+/** Check for bug #1232 where remaking an encrypted DCP causes problems with HMAC IDs (?) */
+BOOST_AUTO_TEST_CASE (remake_id_test2)
+{
+ /* Make a DCP */
+ shared_ptr<Film> film = new_test_film2 ("remake_id_test2_1");
+ shared_ptr<Content> content = content_factory("test/data/flat_red.png").front();
+ film->examine_and_add_content (content);
+ film->set_encrypted (true);
+ BOOST_REQUIRE (!wait_for_jobs ());
+ film->make_dcp ();
+ BOOST_REQUIRE (!wait_for_jobs ());
+
+ /* Remove and remake it */
+ boost::filesystem::remove_all(film->dir(film->dcp_name()));
+ film->make_dcp();
+ BOOST_REQUIRE(!wait_for_jobs());
+
+ /* Find the CPL */
+ optional<boost::filesystem::path> cpl;
+ for (boost::filesystem::directory_iterator i(film->dir(film->dcp_name())); i != boost::filesystem::directory_iterator(); ++i) {
+ if (i->path().filename().string().substr(0, 4) == "cpl_") {
+ cpl = i->path();
+ }
+ }
+ BOOST_REQUIRE(cpl);
+
+ /* Make a DKDM */
+ dcp::EncryptedKDM kdm = film->make_kdm (
+ Config::instance()->decryption_chain()->leaf(),
+ vector<string>(),
+ *cpl,
+ dcp::LocalTime ("2030-01-01T01:00:00+00:00"),
+ dcp::LocalTime ("2031-01-01T01:00:00+00:00"),
+ dcp::MODIFIED_TRANSITIONAL_1,
+ true,
+ 0
+ );
+
+ /* Import the DCP into a new film */
+ shared_ptr<Film> film2 = new_test_film2("remake_id_test2_2");
+ shared_ptr<DCPContent> dcp_content(new DCPContent(film->dir(film->dcp_name())));
+ film2->examine_and_add_content(dcp_content);
+ BOOST_REQUIRE(!wait_for_jobs());
+ dcp_content->add_kdm(kdm);
+ JobManager::instance()->add(shared_ptr<Job>(new ExamineContentJob(film2, dcp_content)));
+ BOOST_REQUIRE(!wait_for_jobs());
+ film2->make_dcp();
+ BOOST_REQUIRE(!wait_for_jobs());
+}