diff --git a/README.md b/README.md index be46d616271f08903c97fd6492491d15eedcd315..2d57e1c349a2dc879038dc817f6a13499e84978d 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,28 @@ Professional support for Rdiffweb is available by contacting [Patrik Dufresne Se # Changelog +## 1.1.0 (2019-10-31) + +This release focus on improving the admin area and building the fundation for repository access control list (ACL). + + * Update documentation from PDSL web site + * Improve the navigation bar layout + * Update the login page headline + * Update jinja2 version to allow 2.10.x + * Show server log in admin area + * Reduce code smell + * Add System information in admin area + * Validate credential using local database before LDAP + * Reffactoring templates macros + * Enhance user's view search bar + * Change repository URL to username/repopath + * Add System information in admin area + * Improve testcases + * Clean-up obsolete code + * Fix issue with captital case encoding name + * Fix compilation of less files + * Fix google font import + ## 1.0.3 (2019-10-04) * Removing the auto update repos diff --git a/rdiffweb/controller/tests/test_page_settings_delete.py b/rdiffweb/controller/tests/test_page_settings_delete.py index 34dbac1855e18a7c7f89fd22113b2a13a35ff1df..687891b102ec6bd1bfad41d86d2f0bcc8391d5f9 100644 --- a/rdiffweb/controller/tests/test_page_settings_delete.py +++ b/rdiffweb/controller/tests/test_page_settings_delete.py @@ -56,6 +56,12 @@ class DeleteRepoTest(WebCase): self.assertStatus(303) self.assertEqual([], self.app.userdb.get_user('admin').repos) + def test_delete_with_slash(self): + self.app.userdb.get_user('admin').repos = ['/testcases'] + self._delete(self.REPO, 'testcases') + self.assertStatus(303) + self.assertEqual([], self.app.userdb.get_user('admin').repos) + def test_delete_wrong_confirm(self): """ Check failure to delete a repo with wrong confirmation. diff --git a/rdiffweb/core/user.py b/rdiffweb/core/user.py index 984f0de53c076d6353a8831604e3d7e8d44f800a..64ea1c755a2a7cb0abc122220dba6a2293da8b00 100644 --- a/rdiffweb/core/user.py +++ b/rdiffweb/core/user.py @@ -390,11 +390,9 @@ class RepoObject(RdiffRepo): def delete(self): """Properly remove the given repository by updating the user's repositories.""" - repos = self._user_obj.repos - repos.remove(self._repo) logger.info("deleting repository %s", self) - RdiffRepo.delete(self) - self._user_obj.repos = repos + self._user_obj._db.delete_repo(self._user_obj._username, self._repo) + RdiffRepo.delete(self) encoding = property(lambda x: x._encoding.name, _set_encoding) maxage = property(fget=lambda x: int(x._get_attr('maxage', default='0')), fset=lambda x, y: x._set_attr('maxage', int(y))) diff --git a/rdiffweb/core/user_sqlite.py b/rdiffweb/core/user_sqlite.py index cd5ccd9647ea65c53b1d5c5cdfb463dbd9599176..9eb7d728f0d936890e406c9c4b3ea92c4a278a8d 100755 --- a/rdiffweb/core/user_sqlite.py +++ b/rdiffweb/core/user_sqlite.py @@ -208,6 +208,13 @@ class SQLiteUserDB(): self._execute_query("DELETE FROM sshkeys WHERE UserID=?", (user_id,)) self._execute_query("DELETE FROM users WHERE UserID = ?", (user_id,)) + def delete_repo(self, username, repo): + # Query user + user_id = self._get_user_id(username) + assert user_id, "user [%s] doesn't exists" % username + assert self._execute_query( + "DELETE FROM repos WHERE UserID= ? AND RepoPath = ?", (user_id, repo)) + def remove_authorizedkey(self, username, fingerprint): assert isinstance(username, str) assert fingerprint @@ -326,10 +333,11 @@ class SQLiteUserDB(): try: cursor = conn.cursor() cursor.execute(query, args) - if query.startswith("UPDATE"): - results = cursor.rowcount - else: + # We want to return either the rowcount or the list or record. + if cursor.rowcount < 0: results = cursor.fetchall() + else: + results = cursor.rowcount finally: conn.close() return results @@ -408,4 +416,4 @@ UserID int(11) NOT NULL)""") def _get_tables(self): return [ column[0] for column in - self._execute_query('select name from sqlite_master where type="table"')] + self._execute_query('SELECT name FROM sqlite_master WHERE type="table"')]