예제 #1
0
 def test_post_copy_user(self):
     # The main purpose of this test is to check that user permissions are saved properly
     self.assertFalse(AnnalistUser.exists(self.testcoll, "copyuser"))
     f = annalistuser_view_form_data(
         action="copy",
         orig_id="_default_user_perms",
         user_id="copyuser",
         user_name="User copyuser",
         user_uri="mailto:[email protected]",
         user_permissions="VIEW CREATE UPDATE DELETE")
     u = entitydata_edit_url("copy",
                             "testcoll",
                             "_user",
                             entity_id="_default_user_perms",
                             view_id="User_view")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     self.assertEqual(r['location'], self.continuation_url)
     # Check that new record type exists
     self.assertTrue(AnnalistUser.exists(self.testcoll, "copyuser"))
     self._check_annalist_user_values(
         "copyuser", ["VIEW", "CREATE", "UPDATE", "DELETE"])
     return
예제 #2
0
 def test_annalistuser_create_load(self):
     usr = AnnalistUser.create(self.testcoll, "user1",
                               annalistuser_create_values(user_id="user1"))
     uld = AnnalistUser.load(self.testcoll, "user1").get_values()
     ued = annalistuser_read_values(user_id="user1")
     self.assertKeysMatch(uld, ued)
     self.assertDictionaryMatch(uld, ued)
     return
예제 #3
0
 def test_annalistuser_create_load(self):
     usr = AnnalistUser.create(
         self.testcoll, "user1", annalistuser_create_values(user_id="user1")
         )
     uld = AnnalistUser.load(self.testcoll, "user1").get_values()
     ued = annalistuser_read_values(user_id="user1")
     self.assertKeysMatch(ued, uld)
     self.assertDictionaryMatch(ued, uld)
     return
예제 #4
0
 def _check_annalist_user_values(self, user_id, user_permissions):
     "Helper function checks content of annalist user entry with supplied user_id"
     self.assertTrue(AnnalistUser.exists(self.testcoll, user_id))
     t = AnnalistUser.load(self.testcoll, user_id)
     self.assertEqual(t.get_id(), user_id)
     self.assertEqual(t.get_view_url_path(), annalistuser_url("testcoll", user_id))
     v = annalistuser_values(
         coll_id="testcoll", user_id=user_id,
         user_name="User %s"%user_id,
         user_uri="mailto:%[email protected]"%user_id, 
         user_permissions=user_permissions
         )
     self.assertDictionaryMatch(t.get_values(), v)
     return t
예제 #5
0
 def _check_annalist_user_values(self, user_id, user_permissions):
     "Helper function checks content of annalist user entry with supplied user_id"
     self.assertTrue(AnnalistUser.exists(self.testcoll, user_id))
     t = AnnalistUser.load(self.testcoll, user_id)
     self.assertEqual(t.get_id(), user_id)
     self.assertEqual(t.get_view_url_path(),
                      annalistuser_url("testcoll", user_id))
     v = annalistuser_values(coll_id="testcoll",
                             user_id=user_id,
                             user_name="User %s" % user_id,
                             user_uri="mailto:%[email protected]" % user_id,
                             user_permissions=user_permissions)
     self.assertDictionaryMatch(t.get_values(), v)
     return t
예제 #6
0
    def get_user_permissions(self, user_id, user_uri):
        """
        Get a user permissions record (AnnalistUser).

        To return a value, both the user_id and the user_uri (typically a mailto: URI, but
        may be any *authenticated* identifier) must match.  This is to prevent access to 
        records of a deleted account being granted to a new account created with the 
        same user_id (username).

        user_id         local identifier for the type to retrieve.
        user_uri        authenticated identifier associated with the user_id.  That is,
                        the authentication service used is presumed to confirm that
                        the identifier belongs to the user currently logged in with
                        the supplied username.

        returns an AnnalistUser object for the identified user, or None.  This object contains
                information about permissions granted to the user in the current collection.
        """
        user = AnnalistUser.load(self, user_id, altparent=self._parentsite)
        log.debug(
            "Collection.get_user_permissions: user_id %s, user_uri %s, user %r"
            % (user_id, user_uri, user))
        if user:
            for f in [
                    RDFS.CURIE.label, RDFS.CURIE.comment, ANNAL.CURIE.user_uri,
                    ANNAL.CURIE.user_permissions
            ]:
                if f not in user:
                    user = None
                    break
        if user and user[ANNAL.CURIE.user_uri] != user_uri:
            user = None  # URI mismatch: return None.
        return user
예제 #7
0
    def get_user_permissions(self, user_id, user_uri):
        """
        Get a user permissions record (AnnalistUser).

        To return a value, both the user_id and the user_uri (typically a mailto: URI, but
        may be any *authenticated* identifier) must match.  This is to prevent access to 
        records of a deleted account being granted to a new account created with the 
        same user_id (username).

        user_id         local identifier for the type to retrieve.
        user_uri        authenticated identifier associated with the user_id.  That is,
                        the authentication service used is presumed to confirm that
                        the identifier belongs to the user currently logged in with
                        the supplied username.

        returns an AnnalistUser object for the identified user, or None.  This object contains
                information about permissions granted to the user in the current collection.
        """
        user = AnnalistUser.load(self, user_id, altscope="user")
        # log.debug("Collection.get_user_permissions: user_id %s, user_uri %s, user %r"%
        #     (user_id, user_uri, user)
        #     )
        if user:
            for f in [RDFS.CURIE.label, RDFS.CURIE.comment, ANNAL.CURIE.user_uri, ANNAL.CURIE.user_permission]:
                if f not in user:
                    user = None
                    break
        if user and user[ANNAL.CURIE.user_uri] != user_uri:
            user = None         # URI mismatch: return None.
        return user
예제 #8
0
 def test_get_local_user_uri_mismatch(self):
     c = self.testcoll
     usr = AnnalistUser.create(c, "user1",
                               annalistuser_create_values(user_id="user1"))
     ugp = c.get_user_permissions("user1", "mailto:[email protected]")
     self.assertIsNone(ugp)
     return
예제 #9
0
파일: profile.py 프로젝트: rklyne/annalist
 def post(self, request):
     if request.POST.get('continue', None):
         # Check if user permissions are defined
         user_id, user_uri = self.get_user_identity()
         site_coll = self.site().site_data_collection()
         user_perms = site_coll.get_user_permissions(user_id, user_uri)
         if not user_perms:
             # Initialize new user permissions from system defaults
             # (NOTE: site-specific default permissions are incorporate dynamically)
             default_perms = site_coll.get_user_permissions(
                 default_user_id, default_user_uri)
             new_perms_values = default_perms.get_values()
             new_perms_values.update({
                 "annal:id":
                 None,
                 "rdfs:label":
                 "Permissions for %s" % user_id,
                 "rdfs:comment":
                 "# Permissions for %s\r\n\r\n" % user_id +
                 "Permissions for user %s (copied from default)" % user_id,
                 "annal:user_uri":
                 user_uri
             })
             new_perms = AnnalistUser.create(site_coll, user_id,
                                             new_perms_values)
     continuation_url = request.POST.get("continuation_url", "../")
     return HttpResponseRedirect(continuation_url)
예제 #10
0
 def post(self, request):
     if request.POST.get('continue', None):
         # Check if user permissions are defined
         user_id, user_uri = self.get_user_identity()
         site_coll = self.site().site_data_collection()
         user_perms = site_coll.get_user_permissions(user_id, user_uri)
         if not user_perms:
             default_perms = site_coll.get_user_permissions(
                 "_default_user_perms", "annal:User/_default_user_perms")
             new_perms_values = default_perms.get_values()
             new_perms_values.update({
                 "annal:id":
                 None,
                 "rdfs:label":
                 "Permissions for %s" % user_id,
                 "rdfs:comment":
                 "# Permissions for %s\r\n\r\n" % user_id +
                 "Permissions for user %s (copied from default)" % user_id,
                 "annal:user_uri":
                 user_uri
             })
             new_perms = AnnalistUser.create(site_coll, user_id,
                                             new_perms_values)
     continuation_url = request.POST.get("continuation_url", "../")
     return HttpResponseRedirect(continuation_url)
예제 #11
0
 def test_get_local_user_missing_fields(self):
     # E.g. what happens if user record is created through default view?  Don't return value.
     d = annalistuser_create_values(user_id="user1")
     d.pop(ANNAL.CURIE.user_permission)
     usr = AnnalistUser.create(self.testcoll, "user1", d)
     ugp = self.testcoll.get_user_permissions("user1", "mailto:[email protected]")
     self.assertIsNone(ugp)
     return
예제 #12
0
 def test_annalistuser1_data(self):
     usr = AnnalistUser(self.testcoll, "user1", self.testsite)
     self.assertEqual(usr.get_id(), "user1")
     self.assertEqual(usr.get_type_id(), "_user")
     self.assertIn("/c/testcoll/_annalist_collection/users/user1/",
                   usr.get_url())
     self.assertEqual(TestBaseUri + "/c/testcoll/d/_user/user1/",
                      usr.get_view_url())
     usr.set_values(annalistuser_create_values(user_id="user1"))
     td = usr.get_values()
     self.assertEqual(set(td.keys()), set(annalistuser_value_keys()))
     v = annalistuser_values(user_id="user1")
     self.assertDictionaryMatch(td, v)
     return
예제 #13
0
 def test_get_user_uri_mismatch(self):
     s = self.testsite
     c = s.site_data_collection()
     # Create local permissions
     usr = AnnalistUser.create(c, "user1", annalistuser_create_values(user_id="user1"))
     # Test access to permissions defined locally in collection
     ugp = s.get_user_permissions("user1", "mailto:[email protected]")
     self.assertIsNone(ugp)
     return
예제 #14
0
 def test_get_user_uri_mismatch(self):
     s = self.testsite
     c = s.site_data_collection()
     # Create local permissions
     usr = AnnalistUser.create(c, "user1", annalistuser_create_values(user_id="user1"))
     # Test access to permissions defined locally in collection
     ugp = s.get_user_permissions("user1", "mailto:[email protected]")
     self.assertIsNone(ugp)
     return
예제 #15
0
 def no_test_post_confirmed_remove_user(self):
     t = AnnalistUser.create(self.testcoll, "deleteuser",
                             annalistuser_create_values("deleteuser"))
     self.assertTrue(AnnalistUser.exists(self.testcoll, "deleteuser"))
     # Submit positive confirmation
     u = TestHostUri + annalistuser_edit_url("delete", "testcoll")
     f = annalistuser_delete_confirm_form_data("deleteuser")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code, 302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content, "")
     self.assertMatch(
         r['location'],
         "^" + TestHostUri + collection_edit_url("testcoll") +
         r"\?info_head=.*&info_message=.*deletetype.*testcoll.*$")
     # Confirm deletion
     self.assertFalse(AnnalistUser.exists(self.testcoll, "deletetype"))
     return
예제 #16
0
 def no_test_post_confirmed_remove_user(self):
     t = AnnalistUser.create(self.testcoll, "deleteuser", annalistuser_create_values("deleteuser"))
     self.assertTrue(AnnalistUser.exists(self.testcoll, "deleteuser"))
     # Submit positive confirmation
     u = TestHostUri + annalistuser_edit_url("delete", "testcoll")
     f = annalistuser_delete_confirm_form_data("deleteuser")
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,     302)
     self.assertEqual(r.reason_phrase,   "FOUND")
     self.assertEqual(r.content,         "")
     self.assertMatch(r['location'],    
         "^"+TestHostUri+
         collection_edit_url("testcoll")+
         r"\?info_head=.*&info_message=.*deletetype.*testcoll.*$"
         )
     # Confirm deletion
     self.assertFalse(AnnalistUser.exists(self.testcoll, "deletetype"))
     return
예제 #17
0
 def test_annalistuser2_data(self):
     usr = AnnalistUser(self.testcoll, "user2")
     self.assertEqual(usr.get_id(), "user2")
     self.assertEqual(usr.get_type_id(), layout.USER_TYPEID)
     self.assertIn("/c/testcoll/d/%(user_dir)s/user2/" % self.layout,
                   usr.get_url())
     self.assertEqual(
         TestBaseUri + "/c/testcoll/d/%(user_typeid)s/user2/" % self.layout,
         usr.get_view_url())
     usr.set_values(annalistuser_create_values(user_id="user2"))
     ugv = usr.get_values()
     self.assertEqual(set(ugv.keys()), set(annalistuser_value_keys()))
     uev = annalistuser_values(user_id="user2")
     self.assertDictionaryMatch(ugv, uev)
     return
예제 #18
0
def create_user_permissions(site, user_id, user_uri, user_name, user_comment, user_permissions):
    user_values = (
        { ANNAL.CURIE.type:             ANNAL.CURIE.User
        , RDFS.CURIE.label:             user_name
        , RDFS.CURIE.comment:           user_comment
        , ANNAL.CURIE.user_uri:         "%s"%(user_uri)
        , ANNAL.CURIE.user_permissions: user_permissions
        })
    user = AnnalistUser.create(site.site_data_collection(), user_id, user_values)
    return user
예제 #19
0
def create_user_permissions(site, user_id, user_uri, user_name, user_comment, user_permissions):
    user_values = (
        { ANNAL.CURIE.type:             ANNAL.CURIE.User
        , RDFS.CURIE.label:             user_name
        , RDFS.CURIE.comment:           user_comment
        , ANNAL.CURIE.user_uri:         "%s"%(user_uri)
        , ANNAL.CURIE.user_permissions: user_permissions
        })
    user = AnnalistUser.create(site, user_id, user_values, use_altpath=True)
    return user
예제 #20
0
 def test_get_local_user_permissions(self):
     # Create local permissions
     usr = AnnalistUser.create(self.testcoll, "user1", annalistuser_create_values(user_id="user1"))
     # Test access to permissions defined locally in collection
     ugp = self.testcoll.get_user_permissions("user1", "mailto:[email protected]")
     self.assertEqual(ugp[ANNAL.CURIE.id],                 "user1")
     self.assertEqual(ugp[ANNAL.CURIE.type_id],            "_user")
     self.assertEqual(ugp[RDFS.CURIE.label],               "Test User")
     self.assertEqual(ugp[RDFS.CURIE.comment],             "User user1: permissions for Test User in collection testcoll")
     self.assertEqual(ugp[ANNAL.CURIE.user_uri],           "mailto:[email protected]")
     self.assertEqual(ugp[ANNAL.CURIE.user_permission],    ["VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG", "ADMIN"])
     return
예제 #21
0
def create_user_permissions(site, user_id, user_uri, user_name, user_comment,
                            user_permissions):
    user_values = ({
        ANNAL.CURIE.type: ANNAL.CURIE.User,
        RDFS.CURIE.label: user_name,
        RDFS.CURIE.comment: user_comment,
        ANNAL.CURIE.user_uri: "%s" % (user_uri),
        ANNAL.CURIE.user_permissions: user_permissions
    })
    user = AnnalistUser.create(site.site_data_collection(), user_id,
                               user_values)
    return user
예제 #22
0
 def create_user_permissions(self, user_id, user_uri,
         user_name, user_description,
         user_permissions=["VIEW"]
         ):
     user_values = (
         { ANNAL.CURIE.type:             ANNAL.CURIE.User
         , RDFS.CURIE.label:             user_name
         , RDFS.CURIE.comment:           user_description
         , ANNAL.CURIE.user_uri:         user_uri
         , ANNAL.CURIE.user_permission:  user_permissions
         })
     user = AnnalistUser.create(self, user_id, user_values)
     return user
예제 #23
0
 def test_annalistuser_init(self):
     usr = AnnalistUser(self.testcoll, "testuser", self.testsite)
     url = annalistuser_coll_url(self.testsite,
                                 coll_id="testcoll",
                                 user_id="testuser")
     self.assertEqual(usr._entitytype, ANNAL.CURIE.User)
     self.assertEqual(usr._entityfile, layout.USER_META_FILE)
     self.assertEqual(usr._entityref, layout.META_USER_REF)
     self.assertEqual(usr._entityid, "testuser")
     self.assertEqual(usr._entityurl, url)
     self.assertEqual(usr._entitydir, annalistuser_dir(user_id="testuser"))
     self.assertEqual(usr._values, None)
     return
예제 #24
0
 def create_user_permissions(self, user_id, user_uri,
         user_name, user_description,
         user_permissions=["VIEW"]
         ):
     user_values = (
         { ANNAL.CURIE.type:             ANNAL.CURIE.User
         , RDFS.CURIE.label:             user_name
         , RDFS.CURIE.comment:           user_description
         , ANNAL.CURIE.user_uri:         user_uri
         , ANNAL.CURIE.user_permission:  user_permissions
         })
     user = AnnalistUser.create(self, user_id, user_values)
     return user
예제 #25
0
 def test_post_copy_user(self):
     # The main purpose of this test is to check that user permissions are saved properly
     self.assertFalse(AnnalistUser.exists(self.testcoll, "copyuser"))
     f = annalistuser_view_form_data(
         action="copy", orig_id="_default_user_perms",
         user_id="copyuser",
         user_name="User copyuser",
         user_uri="mailto:[email protected]",
         user_permissions="VIEW CREATE UPDATE DELETE"
         )
     u = entitydata_edit_url(
         "copy", "testcoll", 
         layout.USER_TYPEID, entity_id="_default_user_perms", 
         view_id="User_view"
         )
     r = self.client.post(u, f)
     self.assertEqual(r.status_code,   302)
     self.assertEqual(r.reason_phrase, "FOUND")
     self.assertEqual(r.content,       "")
     self.assertEqual(r['location'], self.continuation_url)
     # Check that new user exists
     self.assertTrue(AnnalistUser.exists(self.testcoll, "copyuser"))
     self._check_annalist_user_values("copyuser", ["VIEW", "CREATE", "UPDATE", "DELETE"])
     return
예제 #26
0
 def test_annalistuser2_data(self):
     usr = AnnalistUser(self.testcoll, "user2")
     self.assertEqual(usr.get_id(), "user2")
     self.assertEqual(usr.get_type_id(), layout.USER_TYPEID)
     self.assertIn(
         "/c/testcoll/_annalist_collection/%(user_dir)s/user2/"%self.layout, 
         usr.get_url()
         )
     self.assertEqual(
         TestBaseUri + "/c/testcoll/d/%(user_typeid)s/user2/"%self.layout, 
         usr.get_view_url()
         )
     usr.set_values(annalistuser_create_values(user_id="user2"))
     ugv = usr.get_values()
     self.assertEqual(set(ugv.keys()), set(annalistuser_value_keys()))
     uev = annalistuser_values(user_id="user2")
     self.assertDictionaryMatch(ugv, uev)
     return
예제 #27
0
def create_user_permissions(
        parent,
        user_id,
        user_permissions=["VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG"]):
    user_values = ({
        'annal:type':
        "annal:User",
        'rdfs:label':
        "Test User",
        'rdfs:comment':
        "User %s: permissions for %s in collection %s" %
        (user_id, "Test User", parent.get_id()),
        'annal:user_uri':
        "mailto:%s@%s" % (user_id, TestHost),
        'annal:user_permission':
        user_permissions
    })
    user = AnnalistUser.create(parent, user_id, user_values)
    return user
예제 #28
0
 def test_annalistuser_default_data(self):
     usr = AnnalistUser.load(self.testcoll,
                             "_unknown_user_perms",
                             altparent=self.testsite)
     self.assertEqual(usr.get_id(), "_unknown_user_perms")
     self.assertIn(
         "/c/testcoll/_annalist_collection/users/_unknown_user_perms",
         usr.get_url())
     self.assertEqual(usr.get_type_id(), "_user")
     uld = usr.get_values()
     self.assertEqual(set(uld.keys()), set(annalistuser_load_keys()))
     uev = annalistuser_read_values(user_id="_unknown_user_perms")
     uev.update({
         'rdfs:label': 'Unknown user',
         'rdfs:comment': 'Permissions for unauthenticated user.',
         'annal:user_uri': 'annal:User/_unknown_user_perms',
         'annal:user_permissions': ['VIEW']
     })
     self.assertDictionaryMatch(uld, uev)
     return
예제 #29
0
 def test_alt_parent_inherit_user(self):
     # Test inheritance of "user" scope definitions
     coll_id = "newcoll"
     newcoll = Collection.create(self.testsite, coll_id, collection_create_values(coll_id))
     user1   = AnnalistUser.create(self.testcoll, "user1", annalistuser_create_values(user_id="user1"))
     user2   = AnnalistUser.create(newcoll,       "user2", annalistuser_create_values(user_id="user2"))
     altparents = newcoll.set_alt_entities(self.testcoll)
     parentids  = [ p.get_id() for p in altparents ]
     self.assertEqual(parentids, ["newcoll", "testcoll", layout.SITEDATA_ID])
     self.assertFalse(AnnalistUser.exists(newcoll, "user1", altscope="user"))
     self.assertTrue(AnnalistUser.exists(newcoll, "_default_user_perms", altscope="user"))   # Access site data
     self.assertTrue(AnnalistUser.exists(newcoll, "user2", altscope="user"))
     testuser = AnnalistUser.load(newcoll, "user2", altscope="user")
     self.assertEquals(testuser["rdfs:label"], "Test User")
     return
예제 #30
0
 def post(self, request):
     if request.POST.get('continue', None):
         # Check if user permissions are defined
         user_id, user_uri = self.get_user_identity()
         site_coll  = self.site().site_data_collection()
         user_perms = site_coll.get_user_permissions(user_id, user_uri)
         if not user_perms:
             default_perms = site_coll.get_user_permissions(
                 "_default_user_perms", "annal:User/_default_user_perms"
                 )
             new_perms_values = default_perms.get_values()
             new_perms_values.update(
                 { "annal:id":               None
                 , "rdfs:label":             "Permissions for %s"%user_id
                 , "rdfs:comment":           "# Permissions for %s\r\n\r\n"%user_id+
                                             "Permissions for user %s (copied from default)"%user_id
                 , "annal:user_uri":         user_uri
                 })
             new_perms = AnnalistUser.create(site_coll, user_id, new_perms_values)
     continuation_url  = request.POST.get("continuation_url", "../")
     return HttpResponseRedirect(continuation_url)
예제 #31
0
파일: profile.py 프로젝트: gklyne/annalist
 def post(self, request):
     if request.POST.get('continue', None):
         # Check if user permissions are defined
         user_id, user_uri = self.get_user_identity()
         site_coll  = self.site().site_data_collection()
         user_perms = site_coll.get_user_permissions(user_id, user_uri)
         if not user_perms:
             # Initialize new user permissions from system defaults
             # (NOTE: site-specific default permissions are incorporate dynamically)
             default_perms = site_coll.get_user_permissions(
                 default_user_id, default_user_uri
                 )
             new_perms_values = default_perms.get_values()
             new_perms_values.update(
                 { "annal:id":               None
                 , "rdfs:label":             "Permissions for %s"%user_id
                 , "rdfs:comment":           "# Permissions for %s\r\n\r\n"%user_id+
                                             "Permissions for user %s (copied from default)"%user_id
                 , "annal:user_uri":         user_uri
                 })
             new_perms = AnnalistUser.create(site_coll, user_id, new_perms_values)
     continuation_url  = request.POST.get("continuation_url", "../")
     return HttpResponseRedirect(continuation_url)
예제 #32
0
 def test_annalistuser_default_data(self):
     usr = AnnalistUser.load(self.testcoll,
                             "_unknown_user_perms",
                             altscope="all")
     self.assertEqual(usr.get_id(), "_unknown_user_perms")
     self.assertIn(
         "/c/_annalist_site/_annalist_collection/%(user_dir)s/_unknown_user_perms/"
         % self.layout, usr.get_url())
     self.assertIn(
         "/c/testcoll/d/%(user_typeid)s/_unknown_user_perms" % self.layout,
         usr.get_view_url())
     self.assertEqual(usr.get_type_id(), layout.USER_TYPEID)
     uld = usr.get_values()
     self.assertEqual(set(uld.keys()), set(annalistuser_load_keys()))
     uev = annalistuser_read_values(user_id="_unknown_user_perms")
     uev.update({
         'rdfs:label': 'Unknown user',
         'annal:user_uri': 'annal:User/_unknown_user_perms',
         'annal:user_permission': ['VIEW']
     })
     uev.pop('rdfs:comment', None)
     self.assertDictionaryMatch(uld, uev)
     return
예제 #33
0
 def test_annalistuser_default_data(self):
     usr = AnnalistUser.load(self.testcoll, "_unknown_user_perms", altscope="all")
     self.assertEqual(usr.get_id(), "_unknown_user_perms")
     self.assertIn(
         "/c/_annalist_site/_annalist_collection/%(user_dir)s/_unknown_user_perms/"%self.layout, 
         usr.get_url()
         )
     self.assertIn(
         "/c/testcoll/d/%(user_typeid)s/_unknown_user_perms"%self.layout, 
         usr.get_view_url()
         )
     self.assertEqual(usr.get_type_id(), layout.USER_TYPEID)
     uld = usr.get_values()
     self.assertEqual(set(uld.keys()), set(annalistuser_load_keys()))
     uev = annalistuser_read_values(user_id="_unknown_user_perms")
     uev.update(
         { 'rdfs:label':             'Unknown user'
         , 'annal:user_uri':         'annal:User/_unknown_user_perms'
         , 'annal:user_permission':  ['VIEW']
         })
     uev.pop('rdfs:comment', None)
     self.assertDictionaryMatch(uld, uev)
     return
예제 #34
0
def delete_user_permissions(site, user_id):
    AnnalistUser.remove(site.site_data_collection(), user_id)
    return
예제 #35
0
 def test_get_local_user_uri_mismatch(self):
     usr = AnnalistUser.create(self.testcoll, "user1", annalistuser_create_values(user_id="user1"))
     ugp = self.testcoll.get_user_permissions("user1", "mailto:[email protected]")
     self.assertIsNone(ugp)
     return
예제 #36
0
 def _check_annalist_user_perms(self, user_id, user_perms):
     self.assertTrue(AnnalistUser.exists(self.testcoll, user_id))
     u = AnnalistUser.load(self.testcoll, user_id)
     self.assertEqual(u.get_id(), user_id)
     self.assertEqual(u[ANNAL.CURIE.user_permission], user_perms)
     return
예제 #37
0
def delete_user_permissions(site, user_id):
    AnnalistUser.remove(site, user_id)
    return
예제 #38
0
def delete_user_permissions(site, user_id):
    AnnalistUser.remove(site, user_id)
    return
예제 #39
0
def delete_user_permissions(site, user_id):
    AnnalistUser.remove(site, user_id, use_altpath=True)
    return
예제 #40
0
 def setUp(self):
     init_annalist_test_site()
     self.testsite = Site(TestBaseUri, TestBaseDir)
     self.testcoll = Collection(self.testsite, "testcoll")
     # populate site with different classes of users: admin, config, create, update, delete, view
     self.user_admin = AnnalistUser.create(
         self.testcoll, "user_admin",
         annalistuser_create_values(
             coll_id="testcoll",
             user_id="user_admin",
             user_name="Admin User",
             user_uri="mailto:user_admin@%s" % TestHost,
             user_permissions=[
                 "VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG", "ADMIN"
             ]))
     self.user_config = AnnalistUser.create(
         self.testcoll, "user_config",
         annalistuser_create_values(
             coll_id="testcoll",
             user_id="user_config",
             user_name="Admin User",
             user_uri="mailto:user_config@%s" % TestHost,
             user_permissions=[
                 "VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG"
             ]))
     self.user_create = AnnalistUser.create(
         self.testcoll, "user_create",
         annalistuser_create_values(
             coll_id="testcoll",
             user_id="user_create",
             user_name="Admin User",
             user_uri="mailto:user_create@%s" % TestHost,
             user_permissions=["VIEW", "UPDATE", "CREATE"]))
     self.user_update = AnnalistUser.create(
         self.testcoll, "user_update",
         annalistuser_create_values(coll_id="testcoll",
                                    user_id="user_update",
                                    user_name="Admin User",
                                    user_uri="mailto:user_update@%s" %
                                    TestHost,
                                    user_permissions=["VIEW", "UPDATE"]))
     self.user_delete = AnnalistUser.create(
         self.testcoll, "user_delete",
         annalistuser_create_values(
             coll_id="testcoll",
             user_id="user_delete",
             user_name="Admin User",
             user_uri="mailto:user_delete@%s" % TestHost,
             user_permissions=["VIEW", "UPDATE", "DELETE"]))
     self.user_view = AnnalistUser.create(
         self.testcoll, "user_view",
         annalistuser_create_values(coll_id="testcoll",
                                    user_id="user_view",
                                    user_name="Admin User",
                                    user_uri="mailto:user_view@%s" %
                                    TestHost,
                                    user_permissions=["VIEW"]))
     self.user_site_admin = AnnalistUser.create(
         self.testsite,
         "user_site_admin",
         annalistuser_create_values(
             coll_id="testcoll",
             user_id="user_site_admin",
             user_name="Site_admin User",
             user_uri="mailto:user_site_admin@%s" % TestHost,
             user_permissions=[
                 "VIEW", "CREATE", "UPDATE", "DELETE", "CONFIG", "ADMIN"
             ]),
         use_altpath=True)
     self.user_site_create_coll = AnnalistUser.create(
         self.testsite,
         "user_site_create_coll",
         annalistuser_create_values(
             coll_id="testcoll",
             user_id="user_site_create_coll",
             user_name="Site_create User",
             user_uri="mailto:user_site_create_coll@%s" % TestHost,
             user_permissions=["VIEW", "CREATE_COLLECTION"]),
         use_altpath=True)
     self.user_site_delete_coll = AnnalistUser.create(
         self.testsite,
         "user_site_delete_coll",
         annalistuser_create_values(
             coll_id="testcoll",
             user_id="user_site_delete_coll_coll",
             user_name="Site_delete User",
             user_uri="mailto:user_site_delete_coll@%s" % TestHost,
             user_permissions=[
                 "VIEW", "CREATE_COLLECTION", "DELETE_COLLECTION"
             ]),
         use_altpath=True)
     self.user_site_view = AnnalistUser.create(
         self.testsite,
         "user_site_view",
         annalistuser_create_values(coll_id="testcoll",
                                    user_id="user_site_view",
                                    user_name="Site_view User",
                                    user_uri="mailto:user_site_view@%s" %
                                    TestHost,
                                    user_permissions=["VIEW"]),
         use_altpath=True)
     return