Opened at 2021-10-28T14:43:42Z
Closed at 2021-10-30T11:33:54Z
#3832 closed defect (fixed)
test_storage_web.py duplicates internal lease management logic
Reported by: | exarkun | Owned by: | exarkun |
---|---|---|---|
Priority: | normal | Milestone: | undecided |
Component: | unknown | Version: | n/a |
Keywords: | Cc: | ||
Launchpad Bug: |
Description
test_storage_web.py contains:
def backdate_lease(self, sf, renew_secret, new_expire_time): # ShareFile.renew_lease ignores attempts to back-date a lease (i.e. # "renew" a lease with a new_expire_time that is older than what the # current lease has), so we have to reach inside it. for i,lease in enumerate(sf.get_leases()): if lease.renew_secret == renew_secret: lease = lease.renew(new_expire_time) f = open(sf.home, 'rb+') sf._write_lease_record(f, i, lease) f.close() return raise IndexError("unable to renew non-existent lease")
which is essentially a copy of the renew_lease function in immutable.py:
def renew_lease(self, renew_secret, new_expire_time): for i,lease in enumerate(self.get_leases()): if timing_safe_compare(lease.renew_secret, renew_secret): # yup. See if we need to update the owner time. if new_expire_time > lease.get_expiration_time(): # yes lease = lease.renew(new_expire_time) with open(self.home, 'rb+') as f: self._write_lease_record(f, i, lease) return raise IndexError("unable to renew non-existent lease")
except it omits the "no going backwards" check and doesn't manage the lifetime of the open share file safely.
This duplication is undesirable for the usual reasons and can easily be avoided by having the real implementation allow for backdated leases on request.
Change History (1)
comment:1 Changed at 2021-10-30T11:33:54Z by GitHub <noreply@…>
- Resolution set to fixed
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
In 7b554d1/trunk: