Ejemplo n.º 1
0
    def testUpdateMSU(self, mkdir, exe, dl, sha, rpath):
        bi = BuildInfo()

        # Setup
        remote = '@Drivers/HP/KB2990941-v3-x64.msu'
        local = r'c:\KB2990941-v3-x64.msu'
        sha_256 = (
            'd1acbdd8652d6c78ce284bf511f3a7f5f776a0a91357aca060039a99c6a93a16')
        conf = {
            'data': {
                'update': [[remote, local, sha_256]]
            },
            'path': ['/autobuild']
        }
        rpath.return_value = '/'

        # Success
        um = updates.UpdateMSU(conf['data']['update'], bi)
        um.Run()
        dl.assert_called_with(mock.ANY,
                              ('https://glazier-server.example.com/'
                               'bin/Drivers/HP/KB2990941-v3-x64.msu'),
                              local,
                              show_progress=True)
        sha.assert_called_with(mock.ANY, local, sha_256)
        cache = updates.constants.SYS_CACHE
        exe.assert_called_with(f'{updates.constants.SYS_SYSTEM32}/dism.exe', [
            '/image:c:\\', '/Add-Package',
            '/PackagePath:c:\\KB2990941-v3-x64.msu',
            f'/ScratchDir:{cache}\\Updates\\'
        ],
                               shell=True)
        mkdir.assert_called_with('%s\\Updates\\' % cache)

        # Invalid format
        conf['data']['update'][0][1] = 'C:\\Windows6.1-KB2990941-v3-x64.cab'
        um = updates.UpdateMSU(conf['data']['update'], bi)
        self.assertRaises(updates.ActionError, um.Run)
        conf['data']['update'][0][1] = 'C:\\Windows6.1-KB2990941-v3-x64.msu'

        # Dism Fail
        exe.side_effect = updates.execute.Error
        with self.assertRaises(updates.ActionError):
            um.Run()
Ejemplo n.º 2
0
 def testUpdateMSUValidate(self):
   g = updates.UpdateMSU('String', None)
   self.assertRaises(updates.ValidationError, g.Validate)
   g = updates.UpdateMSU([[1, 2, 3]], None)
   self.assertRaises(updates.ValidationError, g.Validate)
   g = updates.UpdateMSU([[1, '/tmp/out/path']], None)
   self.assertRaises(updates.ValidationError, g.Validate)
   g = updates.UpdateMSU([['/tmp/src.zip', 2]], None)
   self.assertRaises(updates.ValidationError, g.Validate)
   g = updates.UpdateMSU(
       [['https://glazier/bin/src.msu', '/tmp/out/src.zip']], None)
   self.assertRaises(updates.ValidationError, g.Validate)
   g = updates.UpdateMSU(
       [['https://glazier/bin/src.msu', '/tmp/out/src.msu']], None)
   g.Validate()
   g = updates.UpdateMSU(
       [['https://glazier/bin/src.msu', '/tmp/out/src.msu', '12345']], None)
   g.Validate()
   g = updates.UpdateMSU([['https://glazier/bin/src.zip', '/tmp/out/src.zip',
                           '12345', '67890']], None)
   self.assertRaises(updates.ValidationError, g.Validate)