privilege tests for Slice and Deployment
diff --git a/xos/tosca/tests/basetest.py b/xos/tosca/tests/basetest.py
index db3ffb7..f7f04eb 100644
--- a/xos/tosca/tests/basetest.py
+++ b/xos/tosca/tests/basetest.py
@@ -80,6 +80,11 @@
                                       props = props,
                                       reqs= reqs)
 
+    def make_user_template(self):
+        return self.make_nodetemplate("test@user.com", "tosca.nodes.User",
+             props = {"firstname": "test", "lastname": "user", "password": "letmein"},
+             reqs = [("testsite", "tosca.relationships.MemberOfSite")])
+
     def make_random_string(self,desired_len):
         return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(desired_len))
 
diff --git a/xos/tosca/tests/deploymenttest.py b/xos/tosca/tests/deploymenttest.py
index a08b2f9..b194b64 100644
--- a/xos/tosca/tests/deploymenttest.py
+++ b/xos/tosca/tests/deploymenttest.py
@@ -1,6 +1,6 @@
 from basetest import BaseToscaTest
 
-from core.models import Deployment, Image
+from core.models import Deployment, Image, User, DeploymentPrivilege
 
 class DeploymentTest(BaseToscaTest):
     tests = ["create_deployment_minimal",
@@ -9,6 +9,7 @@
              "create_deployment_two_flavors",
              "create_deployment_one_image",
              "create_deployment_two_images",
+             "create_deployment_privilege",
              "destroy_deployment",
                            ]
 
@@ -16,6 +17,7 @@
         self.try_to_delete(Deployment, name="testdep")
         self.try_to_delete(Image, name="testimg1")
         self.try_to_delete(Image, name="testimg2")
+        self.try_to_delete(User, email="test@user.com")
 
     def create_deployment_minimal(self):
         self.assert_noobj(Deployment, "testdep")
@@ -73,6 +75,18 @@
                                    accessControl="allow all")
         assert( sorted([f.name for f in dep.images.all()]) == ["testimg1", "testimg2"] )
 
+    def create_deployment_privilege(self):
+        self.assert_noobj(Deployment, "testdep")
+        self.execute(self.make_nodetemplate("testsite", "tosca.nodes.Site") +
+                     self.make_user_template() +
+                     self.make_nodetemplate("testdep", "tosca.nodes.Deployment",
+                                            reqs=[("test@user.com", "tosca.relationships.AdminPrivilege")]))
+        dep = self.assert_obj(Deployment, "testdep")
+        user = User.objects.get(email="test@user.com")
+
+        dps = DeploymentPrivilege.objects.filter(user=user, deployment=dep)
+        assert(len(dps) == 1)
+
     def destroy_deployment(self):
         self.assert_noobj(Deployment, "testdep")
         self.execute(self.make_nodetemplate("testdep", "tosca.nodes.Deployment"))
diff --git a/xos/tosca/tests/slicetest.py b/xos/tosca/tests/slicetest.py
index 484d7c8..315f862 100644
--- a/xos/tosca/tests/slicetest.py
+++ b/xos/tosca/tests/slicetest.py
@@ -1,10 +1,11 @@
 from basetest import BaseToscaTest
 
-from core.models import Slice, Site
+from core.models import Slice, Site, User, SlicePrivilege
 
 class SliceTest(BaseToscaTest):
     tests = ["create_slice_minimal",
              "create_slice_maximal",
+             "create_slice_privilege",
              "destroy_slice"]
 
     def cleanup(self):
@@ -29,6 +30,19 @@
                                              reqs=[("testsite", "tosca.relationships.MemberOfSite")]))
         self.assert_obj(Slice, "testsite_testslice", enabled=False, description="foo", slice_url="http://foo.com/", max_instances=11)
 
+    def create_slice_privilege(self):
+        self.assert_noobj(Slice, "testsite_testslice")
+        self.execute(self.get_base_templates() +
+                     self.make_user_template() +
+                     self.make_nodetemplate("testsite_testslice", "tosca.nodes.Slice",
+                                            reqs=[("testsite", "tosca.relationships.MemberOfSite"),
+                                                  ("test@user.com", "tosca.relationships.AdminPrivilege")]))
+        slice = self.assert_obj(Slice, "testsite_testslice")
+        user = User.objects.get(email="test@user.com")
+
+        dps = SlicePrivilege.objects.filter(user=user, slice=slice)
+        assert(len(dps) == 1)
+
     def destroy_slice(self):
         self.assert_noobj(Slice, "testsite_testslice")
         self.execute(self.get_base_templates() +