All this stuff was being called at the beginning of each test. It
belongs in 'setUp', so place it there.
Change-Id: Icb50e64d47c364c3485371311abe1311502831a5
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
The "r" for raw strings has to repeated when several strings are
concatenated, otherwise the backslash in the strings that miss
the "r" are interpreted directly, and result in invalid escapes.
Change-Id: I3736a40043c8aa6c36c21803bf68f842af5cd55e
In Icc19b7c8bdb6a3182939d5e9fdef21288b19f43d mask_password was made case
insensitive but mask_dict_password wasn't. This update makes the
behaviour of these functions the same.
Instead of lowering _SANITIZE_KEYS each time the source list is lowered.
New password patterns from realworld logs were added to the patterns.
Change-Id: Ic3ee301857630a15b9c26fd5d0fc907c43199517
Related-Bug: #1850843
It appears that Mistral service logs everything, and doesn't use yet
the mask_password (nor mask_dict_password) method. In order to ensure
all is properly masked, we have to add some new patterns, and make it
case insensitive in order to simplify and avoid duplicated entries.
Change-Id: Icc19b7c8bdb6a3182939d5e9fdef21288b19f43d
Related-Bug: #1850843
Signed-off-by: Cédric Jeanneret <cjeanner@redhat.com>
QEMU 4.0 and earlier have output like:
virtual size: 1.5M (1572864 bytes)
QEMU 4.1 and later have output like:
virtual size: 1.5 MiB (1572864 bytes)
Adjust the regular expression to allow for optional whitespace
between the magnitude and the unit.
Adjust the unit parsing to support the expanded "MiB" form.
Change-Id: I1f316d6982c0def3296af4835484ad2d81a87fd4
Closes-Bug: 1844050
Until Python 3.8 hmc.new() defaulted the digestmod argument to 'hmac-md5'.
This was deperecated, to be removed in Python 3.8 [1], so let's get
ready for new python.
Also switching to more secure sha1 algorithm, using md5 anywhere may
trigger alerts from automatic security tools.
[1] https://docs.python.org/3.8/library/hmac.html
Change-Id: I4b365cb05de98bdd498b3c2094e4a77ab3944b12
When EventletEvent.clear() is called twice in succession without an
intervening set(), there's no need to replace the underlying
eventlet.event.Event object, since it has never been sent. Doing so
would have woken other greenthreads waiting on the event to no
particular end.
When clear() is called after the event has been set(), we already did
not do anything special with the existing eventlet.event.Event as we
cannot call send() on it twice. We simply replace it with a new one; the
code in wait() will handle the situation correctly, since it will wake
up (due to the initial event having been sent) and begin waiting on the
new eventlet.event.Event instead. This is consistent with the observed
behaviour of threading.Event. A new unit test verifies this.
Change-Id: Ibd5324926431fc760c3dd0be064324e3009cc2c2
In commit cc8b51e1e16f6bdc7d6c0e571e2002e70cde098d we added a send
on the old event when clearing an EventletEvent. However, this was
done unconditionally, which means if the event was already sent
then we attempt to send it again. This fails with:
AssertionError: Trying to re-send() an already-triggered event.
Similar to 14a53c4d8a9d5605b14a503803859df0d6d4b820, we should check
if self._set is True and if so then we know that the event was
already sent and we don't need to do it again.
Change-Id: I660601383072d11e4a077aada8c1b8c30b9d8d1d
Closes-Bug: 1812922
The eventlet maintainers have made it clear that calling reset() on an
Event is not recommended:
715b2ced52
We don't really need to resend the event to wake up threads, because
Event.wait() will return immediately once the event has been sent. So
just rely on the internal _set flag to tell us whether we need to send
the event.
Change-Id: I466aa7cb64308e018598c3bb63a9d0cfbc833adc
The threading-compatible eventlet Event class has a race condition on
the wait method. If greenthread A is blocked on the wait, but another
greenthread B calls clear() and then set(), B calls self._event.send(),
but A is waiting on a different eventlet Event which is no longer used
by the oslo.service Event...
To resolve this, when clearing an Event trigger the underlying eventlet
Event immediately, then have the wait() method resume waiting on the new
eventlet Event.
Change-Id: I81579e2977bb965a5398a2cb4e3e24f5671e856a
Co-Authored-By: Victor Stinner <vstinner@redhat.com>
Co-Authored-By: Hervé Beraud <hberaud@redhat.com>
Closes-Bug: #1805706
A change to the global-requirements[1] has limited use of the monotonic
library to Python versions earlier than 3.3 (later versions have
built-in support for a monotonic clock), so no requirements changes can
be merged until we similarly limit it in requirements.txt.
[1] https://review.openstack.org/615441
Change-Id: Ib53d89ea820d21114d10280c9f4ab1b0c2c4a4bc
mask_dict_password doesn't actually have a dependency on the dict
type specifically. It can work on any subclass of collections.Mapping.
This changes the isinstance check to reflect that and adds a unit
test using a collections.Mapping subclass.
Change-Id: I28781acf027b9b34f8274196db5dd4d2a9adc9ba
Closes-Bug: 1804528
We have a need to use the eventlet Event class directly in
oslo.service. Currently it is copy-pasted from this project, but
we now have a duplicate bug due to that so let's just expose it so
one copy can be used in both places.
This should be safe as the class implements a stdlib interface so
we can't really alter the API, and it's not really private since
instances of it are returned to users.
Change-Id: If8e7a41f9fe5573a780f9faabdbaf1326631d37a
Related-Change: https://review.openstack.org/558879
Related-Bug: 1800879
Some components raise unrelated exceptions during rpdb session due to
unaware attribute handling of file-like objects
Change-Id: I04dd5a7d0f6ec2920671dfa612439427dffefd52
Closes-bug: #1791104
This doesn't actually appear in the docs because it's a private class,
but if we ever made it public we want it to format the code block
correctly.
Change-Id: Ia79b58d6d7847b65f946763c82a25ce8d8e581fb
As of oslotest version 3.5.0 moxstub will be deprecated,
so remove it where it has been used.
Change-Id: I9f038428cbea07a307f08c2251eafed7ab8bbea1
Signed-off-by: Chuck Short <chucks@redhat.com>
This method is called recursively (ie deeply) by default
so there doesn't seem to be a good reason to deepcopy over
and over and over at every recusion level especially since
a new output dictionary is getting created anyway.
Change-Id: I644ef881e487c06dc4db77d60cfe765b0e59b547
In python dict keys can be anything that is hashable; which
includes non-strings such as ints. Currently the code is blowing
up with these types of keys with exceptions like:
TypeError: argument of type 'int' is not iterable
So to fix that handle the case where non-string keys are found.
Change-Id: I4f576a089df6f68e43572bf0eee15e99f2b557fe
1. There are some problems about the test method.
problem 1:
Unit tests may not cover our function, it depends on the python version
that performed the test.
problem 2:
when using function 'constant_time_compare(first, second)', 'first' and
'second' params are usually HMAC digest values, it is not appropriate to
use utf-8 encoded values as mock data.
2. The previous commit `f1d332a` lead into a bug, but due to the problem 1
and the problem 2, we did not find out the error.
Change-Id: I1c29bfe69f8eda60f3c5caaf3e5447dd5b69b108
Closes-Bug: #1772851
Nova's create keypair operation will currently log the generated
keypair if debug logs are enabled.
Closes-Bug: #1770683
Change-Id: I7f889f0bf254fad43b1e26d32fa145f88c668b39
The threading.Event object allows calling set() multiple times, but
the eventlet.Event object only permits send() to be called once,
before a reset() is required to reuse the Event.
Calling eventletutils.Event.set() multiple times triggers an
AssertionError from eventlet.Event. This change resets the underlying
eventlet.Event if the set() method had already been called previously,
and ensures the eventletutils.Event behaves the same as the
threading.Event.
Change-Id: If761b237266bbfe7e65c56e152074b5d1ccac74b
The move from iso8601===0.1.11 to iso8601===0.1.12 broke unit
tests in oslo.utils.
iso8601 used to do:
from datetime import datetime
But now they call datetime.datetime():
import datetime
datetime.datetime()
Unfortunately the unit tests that mocked datetime.datetime() are now
mocking the one in iso8601. This causes a failure in the unit tests.
Fix this by using the 'wraps' argument to mock. So that the calls will
get passed through to datetime.datetime. Also changed to using the
decorator style of mock.
In addition Python 3 unit tests were broken due to changing how the
UTC time zone is represented from 'UTC' to 'UTC+00:00'.
Closes-Bug: #1747575
Closes-Bug: #1744160
Change-Id: Ia80ffb5e571cc5366bef2bc1a32c457a3c16843d
In some part in the code we import objects. In the Openstack style
guidelines they recommend to import only modules.
https://docs.openstack.org/hacking/0.10.3/
Change-Id: Ie0151c2878c6a0ae09b7efcd5ccc7b31c622c0e7
File checksums are used in projects like glance and
glance_store to verify image uploads and so on, so a
generic oslo utility method could be useful.
Change-Id: I1b76ee1876771e7965fd5704ab6281318f36e810