def test_import(self): cache = tempfile.mkdtemp() expand = tempfile.mkdtemp() self.cleanpaths.append(cache) self.cleanpaths.append(expand) resp = dockerv2.pull_image(self.options, 'scanon/importtest', 'latest', cachedir=cache, expanddir=expand) assert os.path.exists(resp['expandedpath']) bfile = os.path.join(resp['expandedpath'], 'home') self.assertTrue(os.path.islink(bfile))
def test_chgtype(self): cache = tempfile.mkdtemp() expand = tempfile.mkdtemp() self.cleanpaths.append(cache) self.cleanpaths.append(expand) resp = dockerv2.pull_image(self.options, 'scanon/chgtype', 'latest', cachedir=cache, expanddir=expand) assert os.path.exists(resp['expandedpath']) bfile = os.path.join(resp['expandedpath'], 'build/test') assert os.path.exists(bfile) bfile = os.path.join(resp['expandedpath'], 'build/test2') assert os.path.exists(bfile)
def test_unicode(self): cache = tempfile.mkdtemp() expand = tempfile.mkdtemp() self.cleanpaths.append(cache) self.cleanpaths.append(expand) resp = dockerv2.pull_image(self.options, 'scanon/unicode', 'latest', cachedir=cache, expanddir=expand.encode('ascii')) assert os.path.exists(resp['expandedpath']) bfile = os.path.join(resp['expandedpath'], u'\ua000') self.assertIn('workdir', resp) assert os.path.exists(resp['expandedpath']) assert os.path.exists(bfile)
def test_whiteout(self): cache = tempfile.mkdtemp() expand = tempfile.mkdtemp() self.cleanpaths.append(cache) self.cleanpaths.append(expand) return resp = dockerv2.pull_image(self.options, 'dmjacobsen/whiteouttest', 'latest', cachedir=cache, expanddir=expand) assert os.path.exists(resp['expandedpath']) assert os.path.exists(os.path.join(resp['expandedpath'], 'usr')) noexist = ['usr/local', 'usr/.wh.local'] for loc in noexist: path = os.path.join(resp['expandedpath'], loc) assert not os.path.exists(path)
def test_unicode(self): cache = tempfile.mkdtemp() expand = tempfile.mkdtemp() self.cleanpaths.append(cache) self.cleanpaths.append(expand) resp = dockerv2.pull_image(self.options, 'scanon/unicode', 'latest', cachedir=cache, expanddir=expand.encode('ascii')) assert os.path.exists(resp['expandedpath']) bfile = os.path.join(resp['expandedpath'], u'\ua000') assert os.path.exists(resp['expandedpath']) assert os.path.exists(bfile)
def test_permission_fixes(self): cache = tempfile.mkdtemp() expand = tempfile.mkdtemp() self.cleanpaths.append(cache) self.cleanpaths.append(expand) resp = dockerv2.pull_image(None, 'scanon/shanetest', 'latest', cachedir=cache, expanddir=expand) assert os.path.exists(resp['expandedpath']) bfile = os.path.join(resp['expandedpath'], 'tmp/b') assert os.path.exists(bfile) with open(bfile) as f: data = f.read() assert(data == 'blah\n') return
def test_whiteout(self): cache = tempfile.mkdtemp() expand = tempfile.mkdtemp() self.cleanpaths.append(cache) self.cleanpaths.append(expand) resp = dockerv2.pull_image(None, 'dmjacobsen/whiteouttest', 'latest', \ cachedir=cache, expanddir=expand) assert os.path.exists(resp['expandedpath']) assert os.path.exists(os.path.join(resp['expandedpath'], 'usr')) noexist = ['usr/local', 'usr/.wh.local'] for loc in noexist: path = os.path.join(resp['expandedpath'], loc) assert not os.path.exists(path) return
def test_permission_fixes(self): cache = tempfile.mkdtemp() expand = tempfile.mkdtemp() self.cleanpaths.append(cache) self.cleanpaths.append(expand) resp = dockerv2.pull_image(self.options, 'scanon/shanetest', 'latest', cachedir=cache, expanddir=expand) assert os.path.exists(resp['expandedpath']) bfile = os.path.join(resp['expandedpath'], 'tmp/b') assert os.path.exists(bfile) with open(bfile) as f: data = f.read() assert (data == 'blah\n') return