summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2019-12-26 15:07:23 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2019-12-26 15:10:15 +0200
commita00cc73b1b250882e124340ca471d9ada036c326 (patch)
tree36b49c8d32270c0f4a92a62d13950d110c11153b
parente29f89936c9d4ad2b0913bca3cac873f22dd63ae (diff)
downloadpysaml2-a00cc73b1b250882e124340ca471d9ada036c326.tar.gz
Replace mongodb operation insert with inster_one
Fixes deprecation warning: """ DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead. """ Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r--src/saml2/mdbcache.py14
-rw-r--r--src/saml2/mongo_store.py6
2 files changed, 11 insertions, 9 deletions
diff --git a/src/saml2/mdbcache.py b/src/saml2/mdbcache.py
index 16f6ca07..6b294a4f 100644
--- a/src/saml2/mdbcache.py
+++ b/src/saml2/mdbcache.py
@@ -119,12 +119,14 @@ class Cache(object):
time.struct_time):
timestamp = time.strftime(TIME_FORMAT, timestamp)
- doc = {"subject_id": subject_id,
- "entity_id": entity_id,
- "info": info,
- "timestamp": timestamp}
-
- _ = self._cache.insert(doc)
+ doc = {
+ "subject_id": subject_id,
+ "entity_id": entity_id,
+ "info": info,
+ "timestamp": timestamp,
+ }
+
+ _ = self._cache.insert_one(doc)
def reset(self, subject_id, entity_id):
""" Scrap the assertions received from a IdP or an AA about a special
diff --git a/src/saml2/mongo_store.py b/src/saml2/mongo_store.py
index 903dd481..0cc33619 100644
--- a/src/saml2/mongo_store.py
+++ b/src/saml2/mongo_store.py
@@ -54,10 +54,10 @@ class SessionStorageMDB(object):
"name_id_key": nkey,
"assertion_id": assertion.id,
"assertion": to_dict(assertion, MMODS, True),
- "to_sign": to_sign
+ "to_sign": to_sign,
}
- _ = self.assertion.insert(doc)
+ _ = self.assertion.insert_one(doc)
def get_assertion(self, cid):
res = []
@@ -215,7 +215,7 @@ class MDB(object):
# Add timestamp to all documents to allow external garbage collecting
if "created_at" not in doc:
doc["created_at"] = datetime.datetime.utcnow()
- _ = self.db.insert(doc)
+ _ = self.db.insert_one(doc)
def get(self, value=None, **kwargs):
if value is not None: