]> source.dussan.org Git - redmine.git/commitdiff
Makes Redmine.pm handle project status (#3640).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 25 Jun 2012 20:08:49 +0000 (20:08 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 25 Jun 2012 20:08:49 +0000 (20:08 +0000)
Repositories of archived projects are no longer accessible. Repositories of closed projects are read-only.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9887 e93f8b46-1217-0410-a6f0-8f06a7374b81

extra/svn/Redmine.pm
test/extra/redmine_pm/repository_subversion_test.rb

index a370c3a47e4d3b17ef400165543af2f6b7392e9b..2aeb352d4f5f37e425ca7a4f2e3d430dd75740d6 100644 (file)
@@ -239,7 +239,7 @@ sub RedmineDSN {
   my ($self, $parms, $arg) = @_;
   $self->{RedmineDSN} = $arg;
   my $query = "SELECT 
-                 hashed_password, salt, auth_source_id, permissions
+                 users.hashed_password, users.salt, users.auth_source_id, roles.permissions, projects.status
               FROM projects, users, roles
               WHERE 
                 users.login=? 
@@ -381,7 +381,7 @@ sub is_public_project {
 
     my $dbh = connect_database($r);
     my $sth = $dbh->prepare(
-        "SELECT is_public FROM projects WHERE projects.identifier = ?;"
+        "SELECT is_public FROM projects WHERE projects.identifier = ? AND projects.status <> 9;"
     );
 
     $sth->execute($project_id);
@@ -460,7 +460,10 @@ sub is_member {
   $sth->execute($redmine_user, $project_id);
 
   my $ret;
-  while (my ($hashed_password, $salt, $auth_source_id, $permissions) = $sth->fetchrow_array) {
+  while (my ($hashed_password, $salt, $auth_source_id, $permissions, $project_status) = $sth->fetchrow_array) {
+      if ($project_status eq "9" || ($project_status ne "1" && $access_mode eq "W")) {
+        last;
+      }
 
       unless ($auth_source_id) {
                                my $method = $r->method;
index 2c3e8de260e809ca1f2bb1f5feac701c5e37ffa3..7be3d3821a8d53f63d6ffe45b443ace4a14e3da6 100644 (file)
@@ -168,6 +168,49 @@ class RedminePmTest::RepositorySubversionTest < RedminePmTest::TestCase
     end
   end
 
+  def test_read_on_archived_projects_should_fail
+    Project.find(1).update_attribute :status, Project::STATUS_ARCHIVED
+    assert_failure "ls", svn_url
+  end
+
+  def test_read_on_archived_private_projects_should_fail
+    Project.find(1).update_attribute :status, Project::STATUS_ARCHIVED
+    Project.find(1).update_attribute :is_public, false
+    with_credentials "dlopper", "foo" do
+      assert_failure "ls", svn_url
+    end
+  end
+
+  def test_read_on_closed_projects_should_succeed
+    Project.find(1).update_attribute :status, Project::STATUS_CLOSED
+    assert_success "ls", svn_url
+  end
+
+  def test_read_on_closed_private_projects_should_succeed
+    Project.find(1).update_attribute :status, Project::STATUS_CLOSED
+    Project.find(1).update_attribute :is_public, false
+    with_credentials "dlopper", "foo" do
+      assert_success "ls", svn_url
+    end
+  end
+
+  def test_commit_on_closed_projects_should_fail
+    Project.find(1).update_attribute :status, Project::STATUS_CLOSED
+    Role.find(2).add_permission! :commit_access
+    with_credentials "dlopper", "foo" do
+      assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+    end
+  end
+
+  def test_commit_on_closed_private_projects_should_fail
+    Project.find(1).update_attribute :status, Project::STATUS_CLOSED
+    Project.find(1).update_attribute :is_public, false
+    Role.find(2).add_permission! :commit_access
+    with_credentials "dlopper", "foo" do
+      assert_failure "mkdir --message Creating_a_directory", svn_url(random_filename)
+    end
+  end
+
   if ldap_configured?
     def test_user_with_ldap_auth_source_should_authenticate_with_ldap_credentials
       ldap_user = User.new(:mail => 'example1@redmine.org', :firstname => 'LDAP', :lastname => 'user', :auth_source_id => 1)