src/tests/api/t_p5p.py
changeset 2310 ce10607d5332
parent 2286 938fbb350ad2
child 2339 aa5954c06b9d
equal deleted inserted replaced
2309:5aa9213d0285 2310:ce10607d5332
   190                     "publisher",
   190                     "publisher",
   191                     "publisher/test",
   191                     "publisher/test",
   192                     "publisher/test/file",
   192                     "publisher/test/file",
   193                     "publisher/test/file/0a",
   193                     "publisher/test/file/0a",
   194                     "publisher/test/file/0a/0acf1107d31f3bab406f8611b21b8fade78ac874",
   194                     "publisher/test/file/0a/0acf1107d31f3bab406f8611b21b8fade78ac874",
   195                     "publisher/test/file/34",
       
   196                     "publisher/test/file/34/344f2a94afd12146336340d71962254f647874be",
       
   197                     "publisher/test/file/65",
       
   198                     "publisher/test/file/65/65154063c6988c4de879751bb112703b06ba5129",
       
   199                     "publisher/test/file/6c",
       
   200                     "publisher/test/file/6c/6cd1527a2e4a2926b05663e0a29f0fd5207a7119",
       
   201                     "publisher/test/file/97",
       
   202                     "publisher/test/file/97/97ff81591147d40444c8fea6e794fefda382d199",
       
   203                     "publisher/test/file/9c",
       
   204                     "publisher/test/file/9c/9cb9f772cc4a01801b983f199114cc7884b026e3",
       
   205 
       
   206                     "publisher/test/file/a2",
   195                     "publisher/test/file/a2",
   207                     "publisher/test/file/a2/a285ada5f3cae14ea00e97a8d99bd3e357cb0dca",
   196                     "publisher/test/file/a2/a285ada5f3cae14ea00e97a8d99bd3e357cb0dca",
   208                     "publisher/test/file/b2",
   197                     "publisher/test/file/b2",
   209                     "publisher/test/file/b2/b265f2ec87c4a55eb2b6b4c926e7c65f7247a27e",
   198                     "publisher/test/file/b2/b265f2ec87c4a55eb2b6b4c926e7c65f7247a27e",
   210                     "publisher/test/file/d0",
       
   211                     "publisher/test/file/d0/d087434b648f50ab20107b6dfb03f754a06fa462",
       
   212                     "publisher/test/file/dc",
   199                     "publisher/test/file/dc",
   213                     "publisher/test/file/dc/dc84bd4b606fe43fc892eb245d9602b67f8cba38",
   200                     "publisher/test/file/dc/dc84bd4b606fe43fc892eb245d9602b67f8cba38",
   214                     "publisher/test/file/f7",
       
   215                     "publisher/test/file/f7/f72001172042e0afafef7cf5a1f90697866acf3d",
       
   216                     "publisher/test/pkg",
   201                     "publisher/test/pkg",
   217                     "publisher/test/pkg/foo",
   202                     "publisher/test/pkg/foo",
   218                     "publisher/test/pkg/%s" % self.foo.get_dir_path(),
   203                     "publisher/test/pkg/%s" % self.foo.get_dir_path(),
   219                     "publisher/test/pkg/signed",
   204                     "publisher/test/pkg/signed",
   220                     "publisher/test/pkg/%s" % self.signed.get_dir_path(),
   205                     "publisher/test/pkg/%s" % self.signed.get_dir_path(),
   390                 arc.add_package(self.quux, quux_path, dfroot)
   375                 arc.add_package(self.quux, quux_path, dfroot)
   391                 arc.close()
   376                 arc.close()
   392 
   377 
   393                 # Verify the result.
   378                 # Verify the result.
   394                 arc = ptf.PkgTarFile(name=arc_path, mode="r")
   379                 arc = ptf.PkgTarFile(name=arc_path, mode="r")
   395                 expected = self.multi_expected
   380                 expected = self.multi_expected[:]
       
   381                 action_certs = [self.calc_file_hash(t) for t in (
       
   382                     os.path.join(self.cs_dir, "cs1_ch5_ta1_cert.pem"),
       
   383                     os.path.join(self.chain_certs_dir, "ch1_ta1_cert.pem"),
       
   384                     os.path.join(self.chain_certs_dir, "ch2_ta1_cert.pem"),
       
   385                     os.path.join(self.chain_certs_dir, "ch3_ta1_cert.pem"),
       
   386                     os.path.join(self.chain_certs_dir, "ch4_ta1_cert.pem"),
       
   387                     os.path.join(self.chain_certs_dir, "ch5_ta1_cert.pem"),
       
   388                     os.path.join(self.chain_certs_dir, "ch1_ta3_cert.pem"),
       
   389                 )]
       
   390                 for hsh in action_certs:
       
   391                         d = "publisher/test/file/%s" % hsh[0:2]
       
   392                         f = "%s/%s" % (d, hsh)
       
   393                         expected.append(d)
       
   394                         expected.append(f)
       
   395 
   396                 actual = sorted(m.name for m in arc.getmembers())
   396                 actual = sorted(m.name for m in arc.getmembers())
   397                 self.assertEqualDiff(expected, actual)
   397                 self.assertEqualDiff(sorted(set(expected)), actual)
   398 
   398 
   399                 os.unlink(arc_path)
   399                 os.unlink(arc_path)
   400                 os.unlink(foo_path)
   400                 os.unlink(foo_path)
   401                 os.unlink(quux_path)
   401                 os.unlink(quux_path)
   402                 os.unlink(signed_path)
   402                 os.unlink(signed_path)
   438                 arc = ptf.PkgTarFile(name=arc_path, mode="r")
   438                 arc = ptf.PkgTarFile(name=arc_path, mode="r")
   439                 # Add in the p5i file since this is an archive with signed
   439                 # Add in the p5i file since this is an archive with signed
   440                 # packages created from a repo.
   440                 # packages created from a repo.
   441                 expected = sorted(self.multi_expected +
   441                 expected = sorted(self.multi_expected +
   442                     ["publisher/test/pub.p5i"])
   442                     ["publisher/test/pub.p5i"])
       
   443                 action_certs = [self.calc_file_hash(t) for t in (
       
   444                     os.path.join(self.cs_dir, "cs1_ch5_ta1_cert.pem"),
       
   445                     os.path.join(self.chain_certs_dir, "ch1_ta1_cert.pem"),
       
   446                     os.path.join(self.chain_certs_dir, "ch2_ta1_cert.pem"),
       
   447                     os.path.join(self.chain_certs_dir, "ch3_ta1_cert.pem"),
       
   448                     os.path.join(self.chain_certs_dir, "ch4_ta1_cert.pem"),
       
   449                     os.path.join(self.chain_certs_dir, "ch5_ta1_cert.pem"),
       
   450                     os.path.join(self.chain_certs_dir, "ch1_ta3_cert.pem"),
       
   451                 )]
       
   452                 for hsh in action_certs:
       
   453                         d = "publisher/test/file/%s" % hsh[0:2]
       
   454                         f = "%s/%s" % (d, hsh)
       
   455                         expected.append(d)
       
   456                         expected.append(f)
   443                 actual = sorted(m.name for m in arc.getmembers())
   457                 actual = sorted(m.name for m in arc.getmembers())
   444                 self.assertEqualDiff(expected, actual)
   458                 self.assertEqualDiff(sorted(set(expected)), actual)
   445 
   459 
   446                 os.unlink(arc_path)
   460                 os.unlink(arc_path)
   447 
   461 
   448         def __verify_manifest_sig(self, repo, pfmri, content):
   462         def __verify_manifest_sig(self, repo, pfmri, content):
   449                 """Helper method to verify that the given manifest signature
   463                 """Helper method to verify that the given manifest signature
   772                 arc = ptf.PkgTarFile(name=arc_path, mode="r")
   786                 arc = ptf.PkgTarFile(name=arc_path, mode="r")
   773                 # Add in the p5i file since this is an archive with signed
   787                 # Add in the p5i file since this is an archive with signed
   774                 # packages created from a repo.
   788                 # packages created from a repo.
   775                 expected = sorted(self.multi_expected +
   789                 expected = sorted(self.multi_expected +
   776                     ["publisher/test/pub.p5i"])
   790                     ["publisher/test/pub.p5i"])
       
   791                 action_certs = [self.calc_file_hash(t) for t in (
       
   792                     os.path.join(self.cs_dir, "cs1_ch5_ta1_cert.pem"),
       
   793                     os.path.join(self.chain_certs_dir, "ch1_ta1_cert.pem"),
       
   794                     os.path.join(self.chain_certs_dir, "ch2_ta1_cert.pem"),
       
   795                     os.path.join(self.chain_certs_dir, "ch3_ta1_cert.pem"),
       
   796                     os.path.join(self.chain_certs_dir, "ch4_ta1_cert.pem"),
       
   797                     os.path.join(self.chain_certs_dir, "ch5_ta1_cert.pem"),
       
   798                     os.path.join(self.chain_certs_dir, "ch1_ta3_cert.pem"),
       
   799                 )]
       
   800                 for hsh in action_certs:
       
   801                         d = "publisher/test/file/%s" % hsh[0:2]
       
   802                         f = "%s/%s" % (d, hsh)
       
   803                         expected.append(d)
       
   804                         expected.append(f)
   777                 actual = sorted(m.name for m in arc.getmembers())
   805                 actual = sorted(m.name for m in arc.getmembers())
   778                 self.assertEqualDiff(expected, actual)
   806                 self.assertEqualDiff(sorted(set(expected)), actual)
   779                 arc.close()
   807                 arc.close()
   780 
   808 
   781                 # Verify pkg(5) archive class extraction behaviour using
   809                 # Verify pkg(5) archive class extraction behaviour using
   782                 # the new archive.
   810                 # the new archive.
   783                 arc = self.__verify_extract(repo, arc_path, hashes, ext_dir)
   811                 arc = self.__verify_extract(repo, arc_path, hashes, ext_dir)