def setUp(self): self.client = Client() site = Site(name='Site 1', slug='site-1') site.save() manufacturer = Manufacturer(name='Manufacturer 1', slug='manufacturer-1') manufacturer.save() devicetype = DeviceType(manufacturer=manufacturer, model='Device Type 1') devicetype.save() devicerole = DeviceRole(name='Device Role 1', slug='device-role-1') devicerole.save() device = Device(name='Device 1', site=site, device_type=devicetype, device_role=devicerole) device.save() secretrole = SecretRole(name='Secret Role 1', slug='secret-role-1') secretrole.save() Secret.objects.bulk_create([ Secret(device=device, role=secretrole, name='Secret 1', ciphertext=b'1234567890'), Secret(device=device, role=secretrole, name='Secret 2', ciphertext=b'1234567890'), Secret(device=device, role=secretrole, name='Secret 3', ciphertext=b'1234567890'), ])
def setUp(self): user = create_test_user(permissions=['secrets.view_secret']) self.client = Client() self.client.force_login(user) site = Site(name='Site 1', slug='site-1') site.save() manufacturer = Manufacturer(name='Manufacturer 1', slug='manufacturer-1') manufacturer.save() devicetype = DeviceType(manufacturer=manufacturer, model='Device Type 1') devicetype.save() devicerole = DeviceRole(name='Device Role 1', slug='device-role-1') devicerole.save() device = Device(name='Device 1', site=site, device_type=devicetype, device_role=devicerole) device.save() secretrole = SecretRole(name='Secret Role 1', slug='secret-role-1') secretrole.save() Secret.objects.bulk_create([ Secret(device=device, role=secretrole, name='Secret 1', ciphertext=b'1234567890'), Secret(device=device, role=secretrole, name='Secret 2', ciphertext=b'1234567890'), Secret(device=device, role=secretrole, name='Secret 3', ciphertext=b'1234567890'), ])
def setUp(self): user = create_test_user(permissions=[ 'secrets.view_secret', 'secrets.add_secret', ]) # Set up a master key userkey = UserKey(user=user, public_key=PUBLIC_KEY) userkey.save() master_key = userkey.get_master_key(PRIVATE_KEY) self.session_key = SessionKey(userkey=userkey) self.session_key.save(master_key) self.client = Client() self.client.force_login(user) site = Site(name='Site 1', slug='site-1') site.save() manufacturer = Manufacturer(name='Manufacturer 1', slug='manufacturer-1') manufacturer.save() devicetype = DeviceType(manufacturer=manufacturer, model='Device Type 1') devicetype.save() devicerole = DeviceRole(name='Device Role 1', slug='device-role-1') devicerole.save() device = Device(name='Device 1', site=site, device_type=devicetype, device_role=devicerole) device.save() secretrole = SecretRole(name='Secret Role 1', slug='secret-role-1') secretrole.save() Secret.objects.bulk_create([ Secret(device=device, role=secretrole, name='Secret 1', ciphertext=b'1234567890'), Secret(device=device, role=secretrole, name='Secret 2', ciphertext=b'1234567890'), Secret(device=device, role=secretrole, name='Secret 3', ciphertext=b'1234567890'), ])