~michaelh1/linaro-image-tools/fractional-partitions

« back to all changes in this revision

Viewing changes to linaro_image_tools/hwpack/tests/test_hardwarepack.py

  • Committer: Fathi Boudra
  • Date: 2012-04-30 16:13:01 UTC
  • mfrom: (513.1.1 linaro-image-tools)
  • Revision ID: fathi.boudra@linaro.org-20120430161301-vy1t9d36zr9qcv2f
Hide password for private PPA access: strip passwords from apt sources in the generated hwpack and obfuscate passwords leaked by ConfigParser/FetchFailed exceptions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import tarfile
25
25
 
26
26
from testtools import TestCase
27
 
from testtools.matchers import Equals
 
27
from testtools.matchers import Equals, MismatchError
28
28
 
29
29
from linaro_image_tools.hwpack.hardwarepack import HardwarePack, Metadata
30
30
from linaro_image_tools.hwpack.packages import get_packages_file
560
560
        self.assertThat(
561
561
            tf,
562
562
            HardwarePackHasFile("sources.list.d.gpg", type=tarfile.DIRTYPE))
 
563
 
 
564
    def test_password_removed_from_urls(self):
 
565
        hwpack = HardwarePack(self.metadata)
 
566
 
 
567
        url = "https://username:password@hostname/url precise main"
 
568
        hwpack.add_apt_sources({"protected": url})
 
569
 
 
570
        tf = self.get_tarfile(hwpack)
 
571
        try:
 
572
            self.assertThat(
 
573
                tf, HardwarePackHasFile("sources.list.d/protected.list",
 
574
                                        content="deb " + url + "\n"))
 
575
        except MismatchError:
 
576
            pass  # Expect to not find the password protected URL
 
577
        else:
 
578
            self.assertTrue(False, "Found password protected URL in hwpack")