def _EscrowPassphrase(self, passphrase): fvv = firmware.LinuxFirmwarePassword( manufacturer=self.manufacturer, serial=self.serial, password=passphrase, hostname='somehost.local', machine_uuid=self.machine_uuid, created_by=users.User('*****@*****.**')) return fvv.put()
def testLinuxFirmwareSearch(self): firmware.LinuxFirmwarePassword( owner='stub7', serial='stub', created_by=users.User('*****@*****.**'), password=str(uuid.uuid4()), machine_uuid='stub', hostname='host1', manufacturer='Vendor', ).put() resp = self.testapp.get( '/search?search_type=linux_firmware&field1=owner&value1=stub7&json=1') self.assertEqual(1, len(util.FromSafeJson(resp.body)['passphrases']))
def MakeLinuxFirmware(save=True, **kwargs): """Create and return a LinuxFirmware for test.""" defaults = { 'manufacturer': 'Lonovo', 'serial': 'blah', 'password': '******', 'machine_uuid': str(uuid.uuid4()).upper(), 'owner': 'someone', 'asset_tags': ['12345'], 'hostname': 'zerocool.example.com', } defaults.update(kwargs) entity = firmware.LinuxFirmwarePassword(**defaults) if save: entity.put() return entity
def testRetrieval(self): password = '******' hostname = 'host1' serial = 'SERIAL' manufacturer = 'Vendor' machine_uuid = 'ID1' firmware.LinuxFirmwarePassword(serial=serial, hostname=hostname, password=password, owner='stub7', machine_uuid=machine_uuid, manufacturer=manufacturer).put() resp = util.FromSafeJson( self.testapp.get('/linux_firmware/VendorSERIALID1', status=httplib.OK).body) self.assertEqual(password, resp['passphrase']) self.assertEqual(manufacturer + serial + machine_uuid, resp['volume_uuid'])