versionone / VersionOne.SDK.Python

A library for custom Python development against the VersionOne Platform's REST-based API.
BSD 3-Clause "New" or "Revised" License
23 stars 32 forks source link

multiple instance of V1Meta register new username/password given #24

Open little-button opened 9 years ago

little-button commented 9 years ago

If I create an instance of V1Meta with the correct username/password, and later on create another instance of V1Meta where the username/password is incorrect. The second instance of V1Meta will still be able to access the same information the first V1Meta instance can access.

v1 = V1Meta(address="www14.v1host.com", instance="v1sdktesting", username="api", password="api", scheme="https") v1.Member(20).Name 'Administrator' v2 = V1Meta(address="www14.v1host.com", instance="v1sdktesting", username="api", password="fake", scheme="https")
v2.Member(20).Name 'Administrator'

Now the same can go if I flip this around and use a bad password in the first instance. If I create a second instance with the correct password, it will no longer work. So it does not appear we can have more than one instance of a V1Meta that will work as expected.

from v1pysdk import V1Meta v1 = V1Meta(address="www14.v1host.com", instance="v1sdktesting", username="api", password="fake", scheme="https") v1.Member(20).Name Traceback (most recent call last): .... urllib2.HTTPError: HTTP Error 401: basic auth failed v2 = V1Meta(address="www14.v1host.com", instance="v1sdktesting", username="api", password="api", scheme="https") v2.Member(20).Name Traceback (most recent call last): .... urllib2.HTTPError: HTTP Error 401: basic auth failed

little-button commented 9 years ago

I didn`t get a chance to update this till now but this issue was caused by bad caching and the memoized decorator was persisting data between V1Meta instances even if the meta data changed.

So to resolve this all you need to do is just make sure the data variable under the cached_by_keyfunc method is created in the V1Meta instance.