aboutsummaryrefslogtreecommitdiffstats
path: root/python_moondb
diff options
context:
space:
mode:
authorMohamedAssem <rfawzy.ext@orange.com>2017-12-27 11:22:37 +0200
committerReemMahmoud <rfawzy.ext@orange.com>2018-01-02 09:31:53 +0200
commite1f5bd9e603ce0768937cc018256f2837c723502 (patch)
treeae0b3a68f8c0a1b83545990298015cc852b6f7af /python_moondb
parent6ca8af03c997444eaeda788b1e5a341a4cd8e8e5 (diff)
Add comment and fix on functions that contains bugs in pdp module
Change-Id: Idc88a54104d296c1f4ea9747953a32370485cdd3 Signed-off-by: MohamedAssem <rfawzy.ext@orange.com>
Diffstat (limited to 'python_moondb')
-rw-r--r--python_moondb/python_moondb/api/pdp.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/python_moondb/python_moondb/api/pdp.py b/python_moondb/python_moondb/api/pdp.py
index 5fb7aa78..07feab7e 100644
--- a/python_moondb/python_moondb/api/pdp.py
+++ b/python_moondb/python_moondb/api/pdp.py
@@ -7,7 +7,7 @@ from uuid import uuid4
from oslo_log import log as logging
from python_moonutilities.security_functions import filter_input, enforce
from python_moondb.api.managers import Managers
-
+from python_moonutilities import exceptions
LOG = logging.getLogger("moon.db.api.pdp")
@@ -24,10 +24,14 @@ class PDPManager(Managers):
@enforce(("read", "write"), "pdp")
def delete_pdp(self, user_id, pdp_id):
+ if pdp_id not in self.driver.get_pdp(pdp_id=pdp_id):
+ raise exceptions.PdpUnknown
return self.driver.delete_pdp(pdp_id=pdp_id)
@enforce(("read", "write"), "pdp")
def add_pdp(self, user_id, pdp_id=None, value=None):
+ if pdp_id in self.driver.get_pdp(pdp_id=pdp_id):
+ raise exceptions.PdpExisting
if not pdp_id:
pdp_id = uuid4().hex
return self.driver.add_pdp(pdp_id=pdp_id, value=value)
@@ -35,4 +39,3 @@ class PDPManager(Managers):
@enforce("read", "pdp")
def get_pdp(self, user_id, pdp_id=None):
return self.driver.get_pdp(pdp_id=pdp_id)
-